changeset 36206:9ddc884e9a32

cmdutil: rewrite makefilename() to use ctx methods
author Yuya Nishihara <yuya@tcha.org>
date Thu, 02 Apr 2015 23:37:07 +0900
parents 976e1cfb2f64
children cc46e68f050f
files mercurial/cmdutil.py
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Apr 02 23:28:16 2015 +0900
+++ b/mercurial/cmdutil.py	Thu Apr 02 23:37:07 2015 +0900
@@ -893,16 +893,14 @@
 
 def makefilename(ctx, pat, desc=None,
                   total=None, seqno=None, revwidth=None, pathname=None):
-    repo = ctx.repo()
-    node = ctx.node()
     expander = {
-        'H': lambda: hex(node),
-        'R': lambda: '%d' % repo.changelog.rev(node),
-        'h': lambda: short(node),
+        'H': lambda: ctx.hex(),
+        'R': lambda: '%d' % ctx.rev(),
+        'h': lambda: short(ctx.node()),
         'm': lambda: re.sub('[^\w]', '_', desc or ''),
-        'r': lambda: ('%d' % repo.changelog.rev(node)).zfill(revwidth or 0),
+        'r': lambda: ('%d' % ctx.rev()).zfill(revwidth or 0),
         '%': lambda: '%',
-        'b': lambda: os.path.basename(repo.root),
+        'b': lambda: os.path.basename(ctx.repo().root),
         }
 
     try: