[PATCH 1 of 2] ui: add optional choices parameter to prompt()
Greg Ward
greg-hg at gerg.ca
Tue Apr 28 09:26:27 CDT 2009
On Tue, Apr 28, 2009 at 12:11 AM, Steve Borho <steve at borho.org> wrote:
> # HG changeset patch
> # User Steve Borho <steve at borho.org>
> # Date 1240890417 18000
> # Node ID 2787668ae94d642a9ace6d9b37826d2f22581be7
> # Parent 344751cd8cb88bac208d630f4825068a3170c92f
> ui: add optional choices parameter to prompt()
>
> The choices dict is not used by ui.prompt(), but is intended
> to be used by GUI subclasses of ui() that can turn the multiple
> choices into buttons for user selection.
>
> diff -r 344751cd8cb8 -r 2787668ae94d mercurial/ui.py
> --- a/mercurial/ui.py Sun Apr 26 16:50:44 2009 -0500
> +++ b/mercurial/ui.py Mon Apr 27 22:46:57 2009 -0500
> @@ -267,9 +267,9 @@
> line = line[:-1]
> return line
>
> - def prompt(self, msg, pat=None, default="y"):
> + def prompt(self, msg, pat=None, default="y", choices={}):
If you use a dict here, doesn't that make your GUI subject to the
whims of hash order? Either that or alphabetical sorting, which is
sometimes almost as arbitrary. Why not a list?
> """Prompt user with msg, read response, and ensure it matches pat
> -
> + choices is intended for use by GUI implementations of ui()
> If not interactive -- the default is returned
> """
For the docstring, how about
"""Prompt user with msg, read response, and ensure it matches pat.
choices is a list of values intended for use by GUI
implementations of ui();
it is redundant with pat. If not interactive, default is returned.
"""
(It might be nice to say what pat is supposed to be -- a regex object?
A string containing a regex? Something else? (I haven't read the
code: should not be necessary to use the method!))
Greg
More information about the Mercurial-devel
mailing list