Mercurial > public > mercurial-scm > hg
diff mercurial/templatekw.py @ 34327:4647e0a8d3d7
scmutil: extract helper functions that returns human-readable change id
We do "'%d:%s' % (ctx...)" at several places, so let's formalize it. A low-
level function, formatrevnode(ui, rev, node), is extracted so we can pass
a manifest rev/node pair.
Note that hex() for manifest output can be replaced with hexfunc() because
it is printed only when debugflag is set.
i18n/de.po is updated so test-log.t passes with no error.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 24 Sep 2017 12:43:57 +0900 |
parents | e278d6d2d7d2 |
children | dd28b1f55eb8 |
line wrap: on
line diff
--- a/mercurial/templatekw.py Sat Sep 02 23:13:54 2017 +0900 +++ b/mercurial/templatekw.py Sun Sep 24 12:43:57 2017 +0900 @@ -11,7 +11,6 @@ from .node import ( hex, nullid, - short, ) from . import ( @@ -163,16 +162,6 @@ if endname in templ: yield templ(endname, **strmapping) -def _formatrevnode(ctx): - """Format changeset as '{rev}:{node|formatnode}', which is the default - template provided by cmdutil.changeset_templater""" - repo = ctx.repo() - if repo.ui.debugflag: - hexfunc = hex - else: - hexfunc = short - return '%d:%s' % (scmutil.intrev(ctx), hexfunc(scmutil.binnode(ctx))) - def getfiles(repo, ctx, revcache): if 'files' not in revcache: revcache['files'] = repo.status(ctx.p1(), ctx)[:3] @@ -640,7 +629,7 @@ return _hybrid(None, predecessors, lambda x: {'ctx': repo[x], 'revcache': {}}, - lambda d: _formatrevnode(d['ctx'])) + lambda d: scmutil.formatchangeid(d['ctx'])) @templatekeyword("successorssets") def showsuccessorssets(repo, ctx, **args): @@ -658,7 +647,7 @@ data = [] for ss in ssets: h = _hybrid(None, ss, lambda x: {'ctx': repo[x], 'revcache': {}}, - lambda d: _formatrevnode(d['ctx'])) + lambda d: scmutil.formatchangeid(d['ctx'])) data.append(h) # Format the successorssets @@ -698,7 +687,7 @@ successors = [hex(n) for n in successors] successors = _hybrid(None, successors, lambda x: {'ctx': repo[x], 'revcache': {}}, - lambda d: _formatrevnode(d['ctx'])) + lambda d: scmutil.formatchangeid(d['ctx'])) # Format markers finalmarkers = [] @@ -759,7 +748,7 @@ for p in pctxs] f = _showlist('parent', parents, args) return _hybrid(f, prevs, lambda x: {'ctx': repo[int(x)], 'revcache': {}}, - lambda d: _formatrevnode(d['ctx'])) + lambda d: scmutil.formatchangeid(d['ctx'])) @templatekeyword('phase') def showphase(repo, ctx, templ, **args):