Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 39814:ddca38941b2b
annotate: pass in wdir rev and node to formatter (BC)
This is a part of the unification series. The 'ff..' hash is preferred over
None as it is a valid revision specifier.
https://www.mercurial-scm.org/wiki/GenericTemplatingPlan#Sanity_check_output
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 15 Sep 2018 17:26:23 +0900 |
parents | a677261e7422 |
children | f6874567a93b |
line wrap: on
line diff
--- a/mercurial/commands.py Sat Sep 15 17:26:22 2018 +0900 +++ b/mercurial/commands.py Sat Sep 15 17:26:23 2018 +0900 @@ -19,6 +19,8 @@ nullid, nullrev, short, + wdirhex, + wdirrev, ) from . import ( archival, @@ -313,37 +315,31 @@ else: datefunc = dateutil.datestr if ctx.rev() is None: - def hexfn(node): - if node is None: - return None - else: - return hex(node) if opts.get('changeset'): # omit "+" suffix which is appended to node hex def formatrev(rev): - if rev is None: + if rev == wdirrev: return '%d' % ctx.p1().rev() else: return '%d' % rev else: def formatrev(rev): - if rev is None: + if rev == wdirrev: return '%d+' % ctx.p1().rev() else: return '%d ' % rev def formathex(h): - if h is None: + if h == wdirhex: return '%s+' % shorthex(hex(ctx.p1().node())) else: return '%s ' % shorthex(h) else: - hexfn = hex formatrev = b'%d'.__mod__ formathex = shorthex opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser), - ('rev', ' ', lambda x: x.fctx.rev(), formatrev), - ('node', ' ', lambda x: hexfn(x.fctx.node()), formathex), + ('rev', ' ', lambda x: scmutil.intrev(x.fctx), formatrev), + ('node', ' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex), ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)), ('path', ' ', lambda x: x.fctx.path(), pycompat.bytestr), ('line_number', ':', lambda x: x.lineno, pycompat.bytestr),