[PATCH] template: allow unquoted int function arguments

Brendan Cully brendan at kublai.com
Mon Apr 8 01:26:21 CDT 2013


# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1365402350 25200
#      Sun Apr 07 23:25:50 2013 -0700
# Node ID 5e8ca3d6df6c2c92ad6e30ebb05ace3c36f59be7
# Parent  565482e2ac6b71125e74adf409939bf54bad274f
template: allow unquoted int function arguments

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -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
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -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 at hostname>
+
 Error on syntax:
 
   $ echo 'x = "f' >> t


More information about the Mercurial-devel mailing list