Patchwork [2,of,3] templater: factor out type conversion of revset() result

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 20, 2016, 10:09 a.m.
Message ID <734094ea47c56da70c0d.1455962965@mimosa>
Download mbox | patch
Permalink /patch/13269/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 20, 2016, 10:09 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1455269988 -32400
#      Fri Feb 12 18:39:48 2016 +0900
# Node ID 734094ea47c56da70c0d22d81cceba968f9b260f
# Parent  6b9ac7eb3428685c41672c8a859e58a896490722
templater: factor out type conversion of revset() result

This makes it clear why we have to do repo[int(x)].
Pierre-Yves David - Feb. 21, 2016, 10:36 a.m.
On 02/20/2016 11:09 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1455269988 -32400
> #      Fri Feb 12 18:39:48 2016 +0900
> # Node ID 734094ea47c56da70c0d22d81cceba968f9b260f
> # Parent  6b9ac7eb3428685c41672c8a859e58a896490722
> templater: factor out type conversion of revset() result

I've pushed this first two to the clownctoper. I'll have a closer look 
at patch 3 later.

Cheers,

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -490,6 +490,7 @@  def showrevslist(name, revs, **args):
     """helper to generate a list of revisions in which a mapped template will
     be evaluated"""
     repo = args['ctx'].repo()
+    revs = [str(r) for r in revs]  # ifcontains() needs a list of str
     f = _showlist(name, revs, **args)
     return _hybrid(f, revs,
                    lambda x: {name: x, 'ctx': repo[int(x)], 'revcache': {}})
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -581,14 +581,14 @@  def revset(context, mapping, args):
     if len(args) > 1:
         formatargs = list([a[0](context, mapping, a[1]) for a in args[1:]])
         revs = query(revsetmod.formatspec(raw, *formatargs))
-        revs = list([str(r) for r in revs])
+        revs = list(revs)
     else:
         revsetcache = mapping['cache'].setdefault("revsetcache", {})
         if raw in revsetcache:
             revs = revsetcache[raw]
         else:
             revs = query(raw)
-            revs = list([str(r) for r in revs])
+            revs = list(revs)
             revsetcache[raw] = revs
 
     return templatekw.showrevslist("revision", revs, **mapping)