[PATCH 2 of 3] patchbomb: customize promptchoice to allow localization of choices
Mads Kiilerich
mads at kiilerich.com
Fri Aug 27 17:01:37 CDT 2010
Christian Ebert wrote, On 08/27/2010 06:01 PM:
> # 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)
The non-interactive/default handling of ui.promptchoice isn't sufficient?
> 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
--diffstat apparently does something quite similar to what you introduce
with --confirm.
What is your thoughts regarding that? Are both of them needed and do
they supplement each other? Could --diffstat be expanded instead of
introducing a new option - or should --diffstat be deprecated?
/Mads
bikeshedder
More information about the Mercurial-devel
mailing list