Bug 965114 - Stop using ui.promptchoice, r=ted
authorSteve Fink <sfink@mozilla.com>
Fri, 31 Jan 2014 12:14:55 -0800
changeset 132 f1b2724ebc97
parent 131 3420668a4f37
child 133 ff9678ca0c74
push id62
push usersfink@mozilla.com
push date2014-01-31 20:16 +0000
reviewersted
bugs965114
Bug 965114 - Stop using ui.promptchoice, r=ted
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -85,41 +85,29 @@ def get_default_version(ui, api_server, 
     # "unspecified" in the list, prefer that for now, until bzapi gets fixed.
     # https://bugzilla.mozilla.org/show_bug.cgi?id=723170
     uns = [ v for v in versions if v.startswith("un") ]
     if uns:
         return uns[-1]
     return versions[-1]
 
 
-# ui.promptchoice only allows single-character responses. If we have more than
-# 10 options, that won't work, so fall back to ui.prompt.
+# ui.promptchoice only allows single-character responses and was changed in
+# 2.7.1 to not be backwards compatible. So ignore it completely and just use
+# ui.prompt.
 def prompt_manychoice(ui, message, prompts):
-    seen = set()
-    found_multi = False
-    for p in prompts:
-        pos = p.index('&')
-        if pos >= 0:
-            if p[pos + 1] in seen:
-                found_multi = True
-            else:
-                seen.add(p[pos + 1])
-
-    while found_multi:
+    while True:
         choice = ui.prompt(message, 'default')
         if choice == 'default':
             return 0
         choice = '&' + choice
         if choice in prompts:
             return prompts.index(choice)
         ui.write("unrecognized response\n")
 
-    return ui.promptchoice(message, prompts, len(prompts) - 1)
-
-
 def prompt_menu(ui, name, values,
                 readable_values=None,
                 message='',
                 allow_none=False):
     if message and not message.endswith('\n'):
         message += "\n"
     prompts = []
     for i in range(0, len(values)):