[PATCH 1 of 3] ui: prompt() takes set of responses in lieu of regexp
Steve Borho
steve at borho.org
Wed Apr 29 15:43:28 CDT 2009
On Wed, Apr 29, 2009 at 3:29 PM, Greg Ward <greg-hg at gerg.ca> wrote:
> On Wed, Apr 29, 2009 at 1:09 AM, Steve Borho <steve at borho.org> wrote:
>> # HG changeset patch
>> # User Steve Borho <steve at borho.org>
>> # Date 1240978831 18000
>> # Node ID 1264366a42f88ed95499f95ef635dc107bfa9c22
>> # Parent 344751cd8cb88bac208d630f4825068a3170c92f
>> ui: prompt() takes set of responses in lieu of regexp
> [...]
>> --- a/mercurial/ui.py Sun Apr 26 16:50:44 2009 -0500
>> +++ b/mercurial/ui.py Tue Apr 28 23:20:31 2009 -0500
>> @@ -267,20 +267,22 @@
>> line = line[:-1]
>> return line
>>
>> - def prompt(self, msg, pat=None, default="y"):
>> - """Prompt user with msg, read response, and ensure it matches pat
>> -
>> - If not interactive -- the default is returned
>> + def prompt(self, msg, choices=(), default="y"):
>> + """Prompt user with msg, read response, and ensure it matches
>> + one of the provided choices. choices is a set of resp, name
>
> Actually, 'choices' is a *sequence* of (resp, name) tuples. And while
> having an empty tuple as the default avoids the danger of a mutable
> default value, it seems a little too much like programming by
> coincidence. It doesn't cost much to make the default None and handle
> None in the code.
Fair enough. Anyone have any problems with the API change otherwise?
If not, I won't bother reposting the other two patches.
--
Steve Borho
More information about the Mercurial-devel
mailing list