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

login
register
mail settings
Submitter Yuya Nishihara
Date March 2, 2016, 3:35 p.m.
Message ID <93252935f1b4490e6061.1456932903@mimosa>
Download mbox | patch
Permalink /patch/13536/
State Accepted
Headers show

Comments

Yuya Nishihara - March 2, 2016, 3:35 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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'