Patchwork [1,of,2,STABLE] templater: evaluate "query" argument passed to revset()

login
register
mail settings
Submitter Yuya Nishihara
Date June 21, 2015, 7:42 a.m.
Message ID <2676242b76c64647b687.1434872575@mimosa>
Download mbox | patch
Permalink /patch/9739/
State Accepted
Headers show

Comments

Yuya Nishihara - June 21, 2015, 7:42 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1434809614 -32400
#      Sat Jun 20 23:13:34 2015 +0900
# Branch stable
# Node ID 2676242b76c64647b68701d927ff7d4288644a61
# Parent  9452112c8eb070aab43334807d2565634952fb4d
templater: evaluate "query" argument passed to revset()

revset() had the same issue as 9452112c8eb0. It crashed by passing non-string
expression.

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -417,7 +417,7 @@  def revset(context, mapping, args):
         # i18n: "revset" is a keyword
         raise error.ParseError(_("revset expects one or more arguments"))
 
-    raw = args[0][1]
+    raw = stringify(args[0][0](context, mapping, args[0][1]))
     ctx = mapping['ctx']
     repo = ctx.repo()
 
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
@@ -2527,6 +2527,9 @@  Test revset function
   Rev: 0
   Ancestor: 0
   
+  $ hg log --template '{revset("TIP"|lower)}\n' -l1
+  2
+
 Test current bookmark templating
 
   $ hg book foo