changeset 36203:01280638bdb1

cmdutil: make node parameter of makefileobj() mandatory (API) (repo, node) pair will be replaced with ctx, so makefilename() can be easily ported to templater.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 02 Apr 2015 23:22:02 +0900
parents 707aba4d48b5
children 33ed8b511185
files mercurial/cmdutil.py mercurial/commands.py
diffstat 2 files changed, 5 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Feb 14 21:36:15 2018 +0900
+++ b/mercurial/cmdutil.py	Thu Apr 02 23:22:02 2015 +0900
@@ -893,23 +893,17 @@
 
 def makefilename(repo, pat, node, desc=None,
                   total=None, seqno=None, revwidth=None, pathname=None):
-    node_expander = {
+    expander = {
         'H': lambda: hex(node),
         'R': lambda: '%d' % repo.changelog.rev(node),
         'h': lambda: short(node),
-        'm': lambda: re.sub('[^\w]', '_', desc or '')
-        }
-    expander = {
+        'm': lambda: re.sub('[^\w]', '_', desc or ''),
+        'r': lambda: ('%d' % repo.changelog.rev(node)).zfill(revwidth or 0),
         '%': lambda: '%',
         'b': lambda: os.path.basename(repo.root),
         }
 
     try:
-        if node:
-            expander.update(node_expander)
-        if node:
-            expander['r'] = (lambda:
-                    ('%d' % repo.changelog.rev(node)).zfill(revwidth or 0))
         if total is not None:
             expander['N'] = lambda: '%d' % total
         if seqno is not None:
@@ -960,7 +954,7 @@
     def __exit__(self, exc_type, exc_value, exc_tb):
         pass
 
-def makefileobj(repo, pat, node=None, desc=None, total=None,
+def makefileobj(repo, pat, node, desc=None, total=None,
                 seqno=None, revwidth=None, mode='wb', modemap=None,
                 pathname=None):
 
--- a/mercurial/commands.py	Wed Feb 14 21:36:15 2018 +0900
+++ b/mercurial/commands.py	Thu Apr 02 23:22:02 2015 +0900
@@ -486,7 +486,7 @@
     if dest == '-':
         if kind == 'files':
             raise error.Abort(_('cannot archive plain files to stdout'))
-        dest = cmdutil.makefileobj(repo, dest)
+        dest = cmdutil.makefileobj(repo, dest, node)
         if not prefix:
             prefix = os.path.basename(repo.root) + '-%h'