templater: evaluate arguments passed to diff() appropriately stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 13 Jun 2015 20:14:22 +0900
branchstable
changeset 25562 9452112c8eb0
parent 25561 50a6c3c55db1
child 25580 a69983942fb4
child 25636 bfe9ed85f27c
templater: evaluate arguments passed to diff() appropriately Before this patch, diff() crashed by passing non-string expression because it didn't evaluate arguments at all.
mercurial/templater.py
tests/test-command-template.t
--- a/mercurial/templater.py	Fri Jun 12 14:43:59 2015 -0700
+++ b/mercurial/templater.py	Sat Jun 13 20:14:22 2015 +0900
@@ -248,7 +248,7 @@
 
     def getpatterns(i):
         if i < len(args):
-            s = args[i][1].strip()
+            s = stringify(args[i][0](context, mapping, args[i][1])).strip()
             if s:
                 return [s]
         return []
--- a/tests/test-command-template.t	Fri Jun 12 14:43:59 2015 -0700
+++ b/tests/test-command-template.t	Sat Jun 13 20:14:22 2015 +0900
@@ -2050,6 +2050,13 @@
   @@ -0,0 +1,1 @@
   +third
 
+  $ hg log -r 8 -T "{diff('FOURTH'|lower)}"
+  diff -r 29114dbae42b -r 95c24699272e fourth
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/fourth	Wed Jan 01 10:01:00 2020 +0000
+  @@ -0,0 +1,1 @@
+  +second
+
   $ cd ..