compat: register a version of 'obsfatedata' template that works with 4.6
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 04 Mar 2018 17:41:45 -0500
changeset 3517 dc31ec3ef042
parent 3516 359734049764
child 3518 d938808e31bc
compat: register a version of 'obsfatedata' template that works with 4.6 Since showlist is deprecated, let us use compatlist.
hgext3rd/evolve/templatekw.py
--- a/hgext3rd/evolve/templatekw.py	Sun Mar 04 17:09:41 2018 -0500
+++ b/hgext3rd/evolve/templatekw.py	Sun Mar 04 17:41:45 2018 -0500
@@ -260,13 +260,33 @@
 
     return "\n".join(lines)
 
-@eh.templatekw("obsfatedata")
-def showobsfatedata(repo, ctx, **args):
-    # Get the needed obsfate data
-    values = obsfatedata(repo, ctx)
+
+if util.safehasattr(templatekw, 'compatlist'):
+    @eh.templatekw('obsfatedata', requires=set(['ctx', 'templ']))
+    def showobsfatedata(context, mapping):
+        ctx = context.resource(mapping, 'ctx')
+        repo = ctx.repo()
+        values = obsfatedata(repo, ctx)
 
-    if values is None:
-        return templatekw.showlist("obsfatedata", [], args)
+        if values is None:
+            return templatekw.compatlist(context, mapping, "obsfatedata", [])
+        args = mapping.copy()
+        args.pop('ctx')
+        args['templ'] = context.resource(mapping, 'templ')
+        return _showobsfatedata(repo, ctx, values, **args)
+else:
+    # pre hg-4.6
+    @eh.templatekw("obsfatedata")
+    def showobsfatedata(repo, ctx, **args):
+        # Get the needed obsfate data
+        values = obsfatedata(repo, ctx)
+
+        if values is None:
+            return templatekw.showlist("obsfatedata", [], args)
+
+        return _showobsfatedata(repo, ctx, values, **args)
+
+def _showobsfatedata(repo, ctx, values, **args):
 
     # Format each successorset successors list
     for raw in values: