changeset 3517:dc31ec3ef042

compat: register a version of 'obsfatedata' template that works with 4.6 Since showlist is deprecated, let us use compatlist.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 04 Mar 2018 17:41:45 -0500
parents 359734049764
children d938808e31bc
files hgext3rd/evolve/templatekw.py
diffstat 1 files changed, 26 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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: