[PATCH] fix output file format %r

Christian Ebert blacktrash at gmx.net
Mon Jul 31 07:16:24 UTC 2006


Following up on myself here:

* Christian Ebert on Saturday, July 29, 2006 at 18:16:43 +0200:
> # HG changeset patch
> # User Christian Ebert <blacktrash at gmx.net>
> # Date 1154189708 -7200
> # Node ID 66b6f9b367158f7feaf8c5a955ae7462f303d13b
> # Parent  51c296f61b6eb1e1276fd9cb22fce3db45721f83
> fix output file format %r
> 
> diff -r 51c296f61b6e -r 66b6f9b36715 mercurial/commands.py
> --- a/mercurial/commands.py	Sat Jul 29 08:11:41 2006 +0200
> +++ b/mercurial/commands.py	Sat Jul 29 18:15:08 2006 +0200
> @@ -287,7 +287,8 @@ def make_filename(repo, pat, node,
>          if node:
>              expander.update(node_expander)
>          if node and revwidth is not None:
> -            expander['r'] = lambda: str(r.rev(node)).zfill(revwidth)
> +            expander['r'] = (lambda:
> +                    str(repo.changelog.rev(node)).zfill(revwidth))
>          if total is not None:
>              expander['N'] = lambda: str(total)
>          if seqno is not None:

I just want to draw attention to the context of this patch, so
the pros can decide whether this can be done in a better way:

def make_filename(repo, pat, node,
                  total=None, seqno=None, revwidth=None, pathname=None):
    node_expander = {
        'H': lambda: hex(node),
        'R': lambda: str(repo.changelog.rev(node)),
#                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        'h': lambda: short(node),
        }
    expander = {
        '%': lambda: '%',
        'b': lambda: os.path.basename(repo.root),
        }

    try:
        if node:
            expander.update(node_expander)
#                    ^^^^^^^^^^^^^^^^^^^^
        if node and revwidth is not None:
            expander['r'] = (lambda:
                    str(repo.changelog.rev(node)).zfill(revwidth))
#                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

My thought was that there would not be any overhead as "it is in
a lambda". So, while this seems to be working, my thought (and
style) might be idiotic ;-)

c
-- 
_B A U S T E L L E N_ lesen!  --->> <http://www.blacktrash.org/baustellen.html>



More information about the Mercurial mailing list