diff mercurial/ui.py @ 19226:c58b6ab4c26f

ui: merge prompt text components into a singe string This will help avoid problems with partial or mismatched translation of the components.
author Matt Mackall <mpm@selenic.com>
date Wed, 22 May 2013 17:31:43 -0500
parents 9311cd5c09ed
children ab3cf67740d6 ba2be32d14f2
line wrap: on
line diff
--- a/mercurial/ui.py	Tue May 21 15:32:15 2013 -0500
+++ b/mercurial/ui.py	Wed May 22 17:31:43 2013 -0500
@@ -639,13 +639,20 @@
         except EOFError:
             raise util.Abort(_('response expected'))
 
-    def promptchoice(self, msg, choices, default=0):
-        """Prompt user with msg, read response, and ensure it matches
-        one of the provided choices. The index of the choice is returned.
-        choices is a sequence of acceptable responses with the format:
-        ('&None', 'E&xec', 'Sym&link') Responses are case insensitive.
-        If ui is not interactive, the default is returned.
+    def promptchoice(self, prompt, default=0):
+        """Prompt user with a message, read response, and ensure it matches
+        one of the provided choices. The prompt is formatted as follows:
+
+           "would you like fries with that (Yn)? $$ &Yes $$ &No"
+
+        The index of the choice is returned. Responses are case
+        insensitive. If ui is not interactive, the default is
+        returned.
         """
+
+        parts = prompt.split('$$')
+        msg = parts[0].rstrip(' ')
+        choices = [p.strip(' ') for p in parts[1:]]
         resps = [s[s.index('&') + 1].lower() for s in choices]
         while True:
             r = self.prompt(msg, resps[default])