[PATCH 2 of 3] patchbomb: customize promptchoice to allow localization of choices

Christian Ebert blacktrash at gmx.net
Fri Aug 27 16:01:51 UTC 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1282923990 -3600
# Node ID 9e79771529eb3aaea6f30267fb50a6d73b5309fa
# Parent  bb8e3ec21a684934f42da0a9bf2a5fddff261928
patchbomb: customize promptchoice to allow localization of choices

Format boolean prompt for diffstat as in filemerge.py.

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -96,13 +96,18 @@
             return default
         ui.warn(_('Please enter a valid value.\n'))
 
+def promptchoice(ui, msg, choices, default=0):
+    if not ui.interactive():
+        return default
+    return ui.promptchoice(msg, choices, default)
+
 def cdiffstat(ui, summary, patchlines):
     s = patch.diffstat(patchlines)
     if summary:
         ui.write(summary, '\n')
         ui.write(s, '\n')
-    ans = prompt(ui, _('does the diffstat above look okay?'), 'y')
-    if not ans.lower().startswith('y'):
+    if promptchoice(ui, _('does the diffstat above look okay (yn)?'),
+                    (_('&Yes'), ('&No'))):
         raise util.Abort(_('diffstat rejected'))
     return s
 



More information about the Mercurial-devel mailing list