Patchwork [06,of,10] templatekw: switch revset() to new API

login
register
mail settings
Submitter Yuya Nishihara
Date March 2, 2018, 1:51 a.m.
Message ID <2918050dfb1503e9ebcb.1519955516@mimosa>
Download mbox | patch
Permalink /patch/28650/
State Accepted
Headers show

Comments

Yuya Nishihara - March 2, 2018, 1:51 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519553282 -32400
#      Sun Feb 25 19:08:02 2018 +0900
# Node ID 2918050dfb1503e9ebcba830e4584288e4ab4a40
# Parent  fcf9fc91b3a946757e70171f388e6ea5e23db50f
templatekw: switch revset() to new API

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -901,12 +901,12 @@  def showrev(context, mapping):
     ctx = context.resource(mapping, 'ctx')
     return scmutil.intrev(ctx)
 
-def showrevslist(name, revs, **args):
+def showrevslist(context, mapping, name, revs):
     """helper to generate a list of revisions in which a mapped template will
     be evaluated"""
-    args = pycompat.byteskwargs(args)
-    repo = args['ctx'].repo()
-    f = _showlist(name, ['%d' % r for r in revs], args['templ'], args)
+    repo = context.resource(mapping, 'repo')
+    templ = context.resource(mapping, 'templ')
+    f = _showlist(name, ['%d' % r for r in revs], templ, mapping)
     return _hybrid(f, revs,
                    lambda x: {name: x, 'ctx': repo[x], 'revcache': {}},
                    pycompat.identity, keytype=int)
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1129,12 +1129,7 @@  def revset(context, mapping, args):
             revs = query(raw)
             revs = list(revs)
             revsetcache[raw] = revs
-
-    # TODO: pass (context, mapping) pair to keyword function
-    props = context._resources.copy()
-    props.update(mapping)
-    return templatekw.showrevslist("revision", revs,
-                                   **pycompat.strkwargs(props))
+    return templatekw.showrevslist(context, mapping, "revision", revs)
 
 @templatefunc('rstdoc(text, style)')
 def rstdoc(context, mapping, args):