# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1519553157 -32400
#      Sun Feb 25 19:05:57 2018 +0900
# Node ID fcf9fc91b3a946757e70171f388e6ea5e23db50f
# Parent  5600b9bc3e406a1523b81688fded42b090defa0d
templatekw: switch obsfate-related template keywords to new API

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -352,12 +352,16 @@ def linerange(req):
 def formatlinerange(fromline, toline):
     return '%d:%d' % (fromline + 1, toline)
 
-def succsandmarkers(repo, ctx, **args):
-    for item in templatekw.showsuccsandmarkers(repo, ctx, **args):
+def succsandmarkers(context, mapping):
+    repo = context.resource(mapping, 'repo')
+    for item in templatekw.showsuccsandmarkers(context, mapping):
         item['successors'] = _siblings(repo[successor]
                                        for successor in item['successors'])
         yield item
 
+# teach templater succsandmarkers is switched to (context, mapping) API
+succsandmarkers._requires = {'repo', 'ctx', 'templ'}
+
 def commonentry(repo, ctx):
     node = ctx.node()
     return {
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -656,23 +656,21 @@ def showmanifest(**args):
     # rev and node are completely different from changeset's.
     return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
 
-@templatekeyword('obsfate')
-def showobsfate(**args):
+@templatekeyword('obsfate', requires={'ui', 'repo', 'ctx', 'templ'})
+def showobsfate(context, mapping):
     # this function returns a list containing pre-formatted obsfate strings.
     #
     # This function will be replaced by templates fragments when we will have
     # the verbosity templatekw available.
-    succsandmarkers = showsuccsandmarkers(**args)
+    succsandmarkers = showsuccsandmarkers(context, mapping)
 
-    args = pycompat.byteskwargs(args)
-    ui = args['ui']
-
+    ui = context.resource(mapping, 'ui')
     values = []
 
     for x in succsandmarkers:
         values.append(obsutil.obsfateprinter(x['successors'], x['markers'], 
ui))
 
-    return showlist("fate", values, args)
+    return compatlist(context, mapping, "fate", values)
 
 def shownames(context, mapping, namespace):
     """helper method to generate a template keyword for a namespace"""
@@ -794,13 +792,16 @@ def showsuccessorssets(context, mapping)
     return _hybrid(gen(data), data, lambda x: {'successorset': x},
                    pycompat.identity)
 
-@templatekeyword("succsandmarkers")
-def showsuccsandmarkers(repo, ctx, **args):
+@templatekeyword("succsandmarkers", requires={'repo', 'ctx', 'templ'})
+def showsuccsandmarkers(context, mapping):
     """Returns a list of dict for each final successor of ctx. The dict
     contains successors node id in "successors" keys and the list of
     obs-markers from ctx to the set of successors in "markers".
     (EXPERIMENTAL)
     """
+    repo = context.resource(mapping, 'repo')
+    ctx = context.resource(mapping, 'ctx')
+    templ = context.resource(mapping, 'templ')
 
     values = obsutil.successorsandmarkers(repo, ctx)
 
@@ -831,8 +832,7 @@ def showsuccsandmarkers(repo, ctx, **arg
 
         data.append({'successors': successors, 'markers': finalmarkers})
 
-    args = pycompat.byteskwargs(args)
-    f = _showlist('succsandmarkers', data, args['templ'], args)
+    f = _showlist('succsandmarkers', data, templ, mapping)
     return _hybrid(f, data, lambda x: x, pycompat.identity)
 
 @templatekeyword('p1rev', requires={'ctx'})
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to