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 @@ -658,23 +658,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""" @@ -796,13 +794,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) @@ -833,8 +834,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'})