diff mercurial/cmdutil.py @ 36242:33ed8b511185

cmdutil: pass ctx to makefilename() in place of repo/node pair (API)
author Yuya Nishihara <yuya@tcha.org>
date Thu, 02 Apr 2015 23:32:28 +0900
parents 01280638bdb1
children 976e1cfb2f64
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Apr 02 23:22:02 2015 +0900
+++ b/mercurial/cmdutil.py	Thu Apr 02 23:32:28 2015 +0900
@@ -891,8 +891,10 @@
     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 @@
         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 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: