exthelper: add support for "requires" argument for template keyword
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 04 Mar 2018 17:07:53 -0500
changeset 3515 d5a824a5853f
parent 3514 498f782ccb4b
child 3516 359734049764
exthelper: add support for "requires" argument for template keyword This will help use to support the new template API.
hgext3rd/evolve/exthelper.py
--- a/hgext3rd/evolve/exthelper.py	Sat Mar 03 23:17:26 2018 -0500
+++ b/hgext3rd/evolve/exthelper.py	Sun Mar 04 17:07:53 2018 -0500
@@ -128,8 +128,11 @@
         revset.loadpredicate(ui, 'evolve', revsetpredicate)
 
         templatekeyword = registrar.templatekeyword()
-        for name, kw in self._templatekws:
-            templatekeyword(name)(kw)
+        for name, kw, requires in self._templatekws:
+            if requires is not None:
+                templatekeyword(name, requires=requires)(kw)
+            else:
+                templatekeyword(name)(kw)
         templatekw.loadkeyword(ui, 'evolve', templatekeyword)
 
         for ext, command, wrapper, opts in self._extcommandwrappers:
@@ -215,7 +218,7 @@
             return symbol
         return dec
 
-    def templatekw(self, keywordname):
+    def templatekw(self, keywordname, requires=None):
         """Decorated function is a template keyword
 
         The name of the keyword must be given as the decorator argument.
@@ -228,7 +231,7 @@
                 return 'babar'
         """
         def dec(keyword):
-            self._templatekws.append((keywordname, keyword))
+            self._templatekws.append((keywordname, keyword, requires))
             return keyword
         return dec