[PATCH 3 of 4] templater: fix revset() to evaluate format arguments eagerly

Yuya Nishihara yuya at tcha.org
Wed Mar 2 10:35:03 EST 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1455377229 -32400
#      Sun Feb 14 00:27:09 2016 +0900
# Node ID 93252935f1b4490e6061865c45245173855bfb02
# Parent  272349484b283018a01c3c580eee3e35c9b2d541
templater: fix revset() to evaluate format arguments eagerly

See the previous patch for why. This patch also removes redundant list()
construction from a list.

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -578,7 +578,7 @@ def revset(context, mapping, args):
         return m(repo)
 
     if len(args) > 1:
-        formatargs = list([a[0](context, mapping, a[1]) for a in args[1:]])
+        formatargs = [evalfuncarg(context, mapping, a) for a in args[1:]]
         revs = query(revsetmod.formatspec(raw, *formatargs))
         revs = list(revs)
     else:
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
@@ -3305,6 +3305,9 @@ Test revset function
   $ hg log --template '{revset("TIP"|lower)}\n' -l1
   2
 
+  $ hg log -T '{revset("%s", "t{"ip"}")}\n' -l1
+  2
+
  a list template is evaluated for each item of revset/parents
 
   $ hg log -T '{rev} p: {revset("p1(%s)", rev) % "{rev}:{node|short}"}\n'


More information about the Mercurial-devel mailing list