# HG changeset patch # User Yuya Nishihara # Date 2015-04-02 14:22:02 # Node ID 01280638bdb14f6dd3ab4929cc20f8c6196e8266 # Parent 707aba4d48b5bdf7a51e4e23b5fcc399c65c2aa2 cmdutil: make node parameter of makefileobj() mandatory (API) (repo, node) pair will be replaced with ctx, so makefilename() can be easily ported to templater. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -893,23 +893,17 @@ def getcommiteditor(edit=False, finishde 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 @@ class _unclosablefile(object): 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): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -486,7 +486,7 @@ def archive(ui, repo, dest, **opts): 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'