templater: make pad function evaluate both string and rawstring templates
authorYuya Nishihara <yuya@tcha.org>
Mon, 08 Jun 2015 18:48:45 +0900
changeset 25509 576d6c74784b
parent 25508 b8fd605b0c88
child 25510 dd511b5cb818
templater: make pad function evaluate both string and rawstring templates "pad" function and "rawstring" type were introduced in parallel, aa51392da507 in default and 5ab28a2e9962 in stable respectively. Therefore, "pad" function lacked handling of "rawstring" unintentionally.
mercurial/templater.py
tests/test-command-template.t
--- a/mercurial/templater.py	Sat Jun 06 22:10:18 2015 -0400
+++ b/mercurial/templater.py	Mon Jun 08 18:48:45 2015 +0900
@@ -310,10 +310,7 @@
 
     width = int(args[1][1])
 
-    text = stringify(args[0][0](context, mapping, args[0][1]))
-    if args[0][0] == runstring:
-        text = stringify(runtemplate(context, mapping,
-            compiletemplate(text, context)))
+    text = stringify(_evalifliteral(args[0], context, mapping))
 
     right = False
     fillchar = ' '
--- a/tests/test-command-template.t	Sat Jun 06 22:10:18 2015 -0400
+++ b/tests/test-command-template.t	Mon Jun 08 18:48:45 2015 +0900
@@ -3042,6 +3042,14 @@
   1------------------- {node|short}
   0------------------- test
 
+Test template string in pad function
+
+  $ hg log -r 0 -T '{pad("\{{rev}}", 10)} {author|user}\n'
+  {0}        test
+
+  $ hg log -r 0 -T '{pad(r"\{rev}", 10)} {author|user}\n'
+  \0         test
+
 Test ifcontains function
 
   $ hg log --template '{rev} {ifcontains(rev, "2 two 0", "is in the string", "is not")}\n'