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

Christian Ebert blacktrash at gmx.net
Fri Aug 27 19:03:42 CDT 2010


* Mads Kiilerich on Saturday, August 28, 2010 at 00:01:37 +0200
> 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?

No. I discovered that when running test-patchbomb.t. I guess
that's also the reason for the custom prompt function in
patchbomb.

>> 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.

It asks for confirmation of the diffstat of each patch. 3 patches
-> 3 prompts. confirm: 3 patches: 1 prompt. And, well, diffstat
shows the diffstat, and confirm shows the message details,
sender, recipients, subjects.
 
> 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?

Frankly, I don't understand you there. Sorry.

> /Mads
> bikeshedder

hehe

c
-- 
_BAUSTELLEN_ lesen! --->> http://www.blacktrash.org/baustellen/


More information about the Mercurial-devel mailing list