changeset 18884:0615b22da148

template: allow unquoted int function arguments
author Brendan Cully <brendan@kublai.com>
date Sun, 07 Apr 2013 23:25:50 -0700
parents 667441789d25
children cf1304fbc184
files mercurial/templater.py tests/test-command-template.t
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Mon Apr 08 09:44:26 2013 -0700
+++ b/mercurial/templater.py	Sun Apr 07 23:25:50 2013 -0700
@@ -66,7 +66,10 @@
                     break
                 pos += 1
             sym = program[s:pos]
-            yield ('symbol', sym, s)
+            try:
+                yield('string', str(int(sym)), s)
+            except ValueError:
+                yield ('symbol', sym, s)
             pos -= 1
         elif c == '}':
             pos += 1
--- a/tests/test-command-template.t	Mon Apr 08 09:44:26 2013 -0700
+++ b/tests/test-command-template.t	Sun Apr 07 23:25:50 2013 -0700
@@ -1360,6 +1360,12 @@
   $ hg log -l1 --template '{date|age}\n'
   7 years from now
 
+Filter with int function argument:
+
+  $ hg log --template '{fill(author, 20)}\n' -r 0
+  User Name
+  <user@hostname>
+
 Error on syntax:
 
   $ echo 'x = "f' >> t