diff mercurial/templatekw.py @ 28270:650c9f69a744

templatekw: switch ctx of list expression to rev of {parents} (BC) This is the same semantics as revset() introduced at e4609ec959f8. Before this patch, {parents} provided nothing useful in new-style template. For example, '{parents % "{parent}"}' generated cryptic string like "rev12345node0123abcdef...". This patch drops {parent} variable since it was useless. We can get a revision number by '{parents % "{rev}"}'.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 12 Feb 2016 19:16:09 +0900
parents 7279e0132347
children 009f58f1ea75
line wrap: on
line diff
--- a/mercurial/templatekw.py	Fri Feb 26 20:22:05 2016 +0900
+++ b/mercurial/templatekw.py	Fri Feb 12 19:16:09 2016 +0900
@@ -474,11 +474,14 @@
     revision) nothing is shown."""
     repo = args['repo']
     ctx = args['ctx']
+    pctxs = scmutil.meaningfulparents(repo, ctx)
+    prevs = [str(p.rev()) for p in pctxs]  # ifcontains() needs a list of str
     parents = [[('rev', p.rev()),
                 ('node', p.hex()),
                 ('phase', p.phasestr())]
-               for p in scmutil.meaningfulparents(repo, ctx)]
-    return showlist('parent', parents, **args)
+               for p in pctxs]
+    f = _showlist('parent', parents, **args)
+    return _hybrid(f, prevs, lambda x: {'ctx': repo[int(x)], 'revcache': {}})
 
 def showphase(repo, ctx, templ, **args):
     """:phase: String. The changeset phase name."""