changeset 36985:66e64681e0a8

annotate: add support for template keywords and functions depending on ctx
author Yuya Nishihara <yuya@tcha.org>
date Sun, 11 Mar 2018 21:36:28 +0900
parents 939e0983c1d9
children afac8ab37c2c
files mercurial/commands.py tests/test-annotate.t
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Mar 11 21:26:15 2018 +0900
+++ b/mercurial/commands.py	Sun Mar 11 21:36:28 2018 +0900
@@ -405,14 +405,15 @@
                 formats.append(['%s' for x in l])
             pieces.append(l)
 
-        for f, p, l in zip(zip(*formats), zip(*pieces), lines):
+        for f, p, (n, l) in zip(zip(*formats), zip(*pieces), lines):
             fm.startitem()
+            fm.context(fctx=n.fctx)
             fm.write(fields, "".join(f), *p)
-            if l[0].skip:
+            if n.skip:
                 fmt = "* %s"
             else:
                 fmt = ": %s"
-            fm.write('line', fmt, l[1])
+            fm.write('line', fmt, l)
 
         if not lines[-1][1].endswith('\n'):
             fm.plain('\n')
--- a/tests/test-annotate.t	Sun Mar 11 21:26:15 2018 +0900
+++ b/tests/test-annotate.t	Sun Mar 11 21:36:28 2018 +0900
@@ -71,6 +71,11 @@
    }
   ]
 
+log-like templating
+
+  $ hg annotate -T'{lines % "{rev} {node|shortest}: {line}"}' a
+  0 8435: a
+
   $ cat <<EOF >>a
   > a
   > a