changeset 26105:d67341f55429

templater: introduce unified filter syntax for unary functions "filter(expr)" is allowed already. This patch adds the opposite, "expr|func".
author Yuya Nishihara <yuya@tcha.org>
date Sat, 04 Jul 2015 16:03:36 +0900
parents 0f1bc7faa50d
children c568c4db036f
files mercurial/templater.py tests/test-command-template.t
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Sat Jul 04 15:59:03 2015 +0900
+++ b/mercurial/templater.py	Sat Jul 04 16:03:36 2015 +0900
@@ -252,6 +252,9 @@
     if n in context._filters:
         filt = context._filters[n]
         return (runfilter, (func, data, filt))
+    if n in funcs:
+        f = funcs[n]
+        return (f, [(func, data)])
     raise error.ParseError(_("unknown function '%s'") % n)
 
 def runfilter(context, mapping, data):
--- a/tests/test-command-template.t	Sat Jul 04 15:59:03 2015 +0900
+++ b/tests/test-command-template.t	Sat Jul 04 16:03:36 2015 +0900
@@ -3117,6 +3117,8 @@
   e777603221
   bcc7ff960b
   f7769ec2ab
+  $ hg log --template '{node|shortest}\n' -l1
+  e777
 
 Test pad function