[PATCH 2 of 2] copy shared command options to prevent duplicates (issue2772)

Idan Kamara idankk86 at gmail.com
Thu May 26 17:05:27 CDT 2011


On Fri, May 27, 2011 at 12:44 AM, Matt Mackall <mpm at selenic.com> wrote:

> On Thu, 2011-05-26 at 19:57 +0300, Idan Kamara wrote:
> > # HG changeset patch
> > # User Idan Kamara <idankk86 at gmail.com>
> > # Date 1306428989 -10800
> > # Node ID c0b716bb34d346c3c76589e3537430934898d0bd
> > # Parent  838230858bfba5abfa76e9ed3b57ef0681cba1a2
> > copy shared command options to prevent duplicates (issue2772)
>
> Doesn't this do this much more simply, now that we've got the decorator?
>
> diff -r 63c3c8783e54 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py      Thu May 26 19:00:47 2011 +0300
> +++ b/mercurial/cmdutil.py      Thu May 26 16:43:21 2011 -0500
> @@ -1215,9 +1215,9 @@
>     def cmd(name, options, synopsis=None):
>         def decorator(func):
>             if synopsis:
> -                table[name] = func, options, synopsis
> +                table[name] = func, options[:], synopsis
>             else:
> -                table[name] = func, options
> +                table[name] = func, options[:]
>             return func
>         return decorator


Yes that is nicer.

Although this way we'll end up copying it for every command, rather than
those who actually need it. Not sure that means anything performance wise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110527/8b34d9db/attachment.htm>


More information about the Mercurial-devel mailing list