changeset 3515:d5a824a5853f

exthelper: add support for "requires" argument for template keyword This will help use to support the new template API.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 04 Mar 2018 17:07:53 -0500
parents 498f782ccb4b
children 359734049764
files hgext3rd/evolve/exthelper.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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