[PATCH 4 of 5] annotate: pass around full hex node until formatting plain output
Yuya Nishihara
yuya at tcha.org
Sun Sep 23 09:28:20 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1536999982 -32400
# Sat Sep 15 17:26:22 2018 +0900
# Node ID d9a367af9890ff10b1c46fc036b541945182756f
# Parent 0027f3043539df28672a15c7579393150ae8ff6e
annotate: pass around full hex node until formatting plain output
In short, this patch moves h[:12] from hexfn() to formathex() so that
formathex() can test if h is the wdirhex or not. This helps switching the
wdir value to wdirrev/wdirhex. See the next patch.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -303,6 +303,11 @@ def annotate(ui, repo, *pats, **opts):
ctx = scmutil.revsingle(repo, rev)
rootfm = ui.formatter('annotate', opts)
+ if ui.debugflag:
+ shorthex = pycompat.identity
+ else:
+ def shorthex(h):
+ return h[:12]
if ui.quiet:
datefunc = dateutil.shortdate
else:
@@ -312,7 +317,7 @@ def annotate(ui, repo, *pats, **opts):
if node is None:
return None
else:
- return rootfm.hexfunc(node)
+ return hex(node)
if opts.get('changeset'):
# omit "+" suffix which is appended to node hex
def formatrev(rev):
@@ -326,14 +331,15 @@ def annotate(ui, repo, *pats, **opts):
return '%d+' % ctx.p1().rev()
else:
return '%d ' % rev
- def formathex(hex):
- if hex is None:
- return '%s+' % rootfm.hexfunc(ctx.p1().node())
+ def formathex(h):
+ if h is None:
+ return '%s+' % shorthex(hex(ctx.p1().node()))
else:
- return '%s ' % hex
+ return '%s ' % shorthex(h)
else:
- hexfn = rootfm.hexfunc
- formatrev = formathex = pycompat.bytestr
+ hexfn = hex
+ formatrev = b'%d'.__mod__
+ formathex = shorthex
opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser),
('rev', ' ', lambda x: x.fctx.rev(), formatrev),
More information about the Mercurial-devel
mailing list