Commit dd4f4817 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

cmdutil: pass ctx to makefilename() in place of repo/node pair (API)

parent 01280638bdb1
......@@ -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
......
......@@ -265,11 +265,10 @@ def makepatch(ui, repo, rev, patchlines, opts, _charsets, idx, total, numbered,
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'
......
......@@ -891,8 +891,10 @@ def getcommiteditor(edit=False, finishdesc=None, extramsg=None,
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=None, total=None,
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, fntemplate, prefix, **opts):
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:
......
......@@ -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'))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment