identify: provide changectx to templater
authorYuya Nishihara <yuya@tcha.org>
Mon, 26 Jun 2017 09:37:16 +0900
changeset 33091 73dfc72704b6
parent 33090 04b3743c1d7c
child 33092 d170f59f6f55
identify: provide changectx to templater
mercurial/commands.py
tests/test-identify.t
--- a/mercurial/commands.py	Mon Jun 26 09:33:01 2017 +0900
+++ b/mercurial/commands.py	Mon Jun 26 09:37:16 2017 +0900
@@ -2795,6 +2795,7 @@
                 fn.startitem()
                 fn.data(rev=p.rev())
                 fn.data(node=p.hex())
+                fn.context(ctx=p)
             fn.end()
         else:
             hexoutput = hexfunc(ctx.node())
@@ -2834,6 +2835,7 @@
         fm.data(branch=ctx.branch())
         fm.data(tags=fm.formatlist(taglist, name='tag', sep=':'))
         fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name='bookmark'))
+        fm.context(ctx=ctx)
 
     fm.plain("%s\n" % ' '.join(output))
     fm.end()
--- a/tests/test-identify.t	Mon Jun 26 09:33:01 2017 +0900
+++ b/tests/test-identify.t	Mon Jun 26 09:37:16 2017 +0900
@@ -56,6 +56,13 @@
    }
   ]
 
+test template keywords and functions which require changectx:
+
+  $ hg id -T '{rev} {node|shortest}\n'
+  2147483647 ffff
+  $ hg id -T '{parents % "{rev} {node|shortest} {desc}\n"}'
+  0 cb9a a
+
 with modifications
 
   $ echo b > a