templatekw: keep compatibility with Mercurial 4.5 stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 05 Jun 2019 19:45:35 +0200
branchstable
changeset 4662 87d60fed455a
parent 4661 df41605bd26c
child 4663 a1a8adcd5155
child 4670 d0d8c0e2f3fc
templatekw: keep compatibility with Mercurial 4.5 This is simple enough to do.
hgext3rd/evolve/templatekw.py
--- a/hgext3rd/evolve/templatekw.py	Wed Jun 05 17:21:45 2019 +0200
+++ b/hgext3rd/evolve/templatekw.py	Wed Jun 05 19:45:35 2019 +0200
@@ -55,11 +55,15 @@
                                    plural='troubles')
 
 _sp = templatekw.showpredecessors
-def showprecursors(context, mapping):
-    return _sp(context, mapping)
-showprecursors.__doc__ = _sp._origdoc
-_tk = templatekw.templatekeyword("precursors", requires=_sp._requires)
-_tk(showprecursors)
+if util.safehasattr(_sp, '_requires'):
+    def showprecursors(context, mapping):
+        return _sp(context, mapping)
+    showprecursors.__doc__ = _sp._origdoc
+    _tk = templatekw.templatekeyword("precursors", requires=_sp._requires)
+    _tk(showprecursors)
+else:
+    templatekw.keywords["precursors"] = _sp
+
 
 def closestsuccessors(repo, nodeid):
     """ returns the closest visible successors sets instead.
@@ -67,11 +71,14 @@
     return directsuccessorssets(repo, nodeid)
 
 _ss = templatekw.showsuccessorssets
-def showsuccessors(context, mapping):
-    return _ss(context, mapping)
-showsuccessors.__doc__ = _ss._origdoc
-_tk = templatekw.templatekeyword("successors", requires=_ss._requires)
-_tk(showsuccessors)
+if util.safehasattr(_ss, '_requires'):
+    def showsuccessors(context, mapping):
+        return _ss(context, mapping)
+    showsuccessors.__doc__ = _ss._origdoc
+    _tk = templatekw.templatekeyword("successors", requires=_ss._requires)
+    _tk(showsuccessors)
+else:
+    templatekw.keywords["successors"] = _ss
 
 def _getusername(ui):
     """the default username in the config or None"""