# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1427985148 -32400
#      Thu Apr 02 23:32:28 2015 +0900
# Node ID 8798e4243a204bfd2f19373abf6bddd9fdb0b155
# Parent  87127b53c63a948b24461862e6d7a02862ecdaa2
cmdutil: pass ctx to makefilename() in place of repo/node pair (API)

diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -256,8 +256,8 @@ def dodiff(ui, repo, cmdline, pats, opts
             cmdutil.export(repo, [repo[node1a].rev(), repo[node2].rev()],
                            fntemplate=repo.vfs.reljoin(tmproot, template),
                            match=matcher)
-            label1a = cmdutil.makefilename(repo, template, node1a)
-            label2 = cmdutil.makefilename(repo, template, node2)
+            label1a = cmdutil.makefilename(repo[node1a], template)
+            label2 = cmdutil.makefilename(repo[node2], template)
             dir1a = repo.vfs.reljoin(tmproot, label1a)
             dir2 = repo.vfs.reljoin(tmproot, label2)
             dir1b = None
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -265,11 +265,10 @@ def makepatch(ui, repo, rev, patchlines,
             if patchtags:
                 patchname = patchtags[0]
             elif total > 1:
-                patchname = cmdutil.makefilename(repo, '%b-%n.patch',
-                                                 binnode, seqno=idx,
-                                                 total=total)
+                patchname = cmdutil.makefilename(repo[node], '%b-%n.patch',
+                                                 seqno=idx, total=total)
             else:
-                patchname = cmdutil.makefilename(repo, '%b.patch', binnode)
+                patchname = cmdutil.makefilename(repo[node], '%b.patch')
         disposition = 'inline'
         if opts.get('attach'):
             disposition = 'attachment'
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -891,8 +891,10 @@ def getcommiteditor(edit=False, finishde
     else:
         return commiteditor
 
-def makefilename(repo, pat, node, desc=None,
+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),
@@ -966,7 +968,8 @@ def makefileobj(repo, pat, node, desc=No
         else:
             fp = repo.ui.fin
         return _unclosablefile(fp)
-    fn = makefilename(repo, pat, node, desc, total, seqno, revwidth, pathname)
+    ctx = repo[node]
+    fn = makefilename(ctx, pat, desc, total, seqno, revwidth, pathname)
     if modemap is not None:
         mode = modemap.get(fn, mode)
         if mode == 'wb':
@@ -2163,7 +2166,7 @@ def cat(ui, repo, ctx, matcher, basefm, 
     def write(path):
         filename = None
         if fntemplate:
-            filename = makefilename(repo, fntemplate, ctx.node(),
+            filename = makefilename(ctx, fntemplate,
                                     pathname=os.path.join(prefix, path))
             # attempt to create the directory if it does not already exist
             try:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -476,7 +476,7 @@ def archive(ui, repo, dest, **opts):
     if not ctx:
         raise error.Abort(_('no working directory: please specify a revision'))
     node = ctx.node()
-    dest = cmdutil.makefilename(repo, dest, node)
+    dest = cmdutil.makefilename(ctx, dest)
     if os.path.realpath(dest) == repo.root:
         raise error.Abort(_('repository root cannot be destination'))
 
@@ -490,7 +490,7 @@ def archive(ui, repo, dest, **opts):
         if not prefix:
             prefix = os.path.basename(repo.root) + '-%h'
 
-    prefix = cmdutil.makefilename(repo, prefix, node)
+    prefix = cmdutil.makefilename(ctx, prefix)
     match = scmutil.match(ctx, [], opts)
     archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
                      match, prefix, subrepos=opts.get('subrepos'))
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to