evolve: use registrar.templatekeyword to register template keyword functions
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Mon, 07 Aug 2017 23:22:41 +0900
changeset 2926 1abafae41fe2
parent 2925 9efedcedd9dd
child 2927 01cf426bd458
evolve: use registrar.templatekeyword to register template keyword functions Now, using registrar.templatekeyword of Mercurial directly in evolve extension should be safe enough. because it has been available since Mercurial 3.8, and minimum Mercurial version for evolve extension is 3.8, too. BTW, this also fixes an issue of "hg help templates" output that template keywords "precursors" and "successors" are not displayed as same as others, because they do not have ":KEYWORD:" prefix in their docstring.
hgext3rd/evolve/exthelper.py
hgext3rd/evolve/templatekw.py
--- a/hgext3rd/evolve/exthelper.py	Sun Sep 10 20:06:52 2017 +0900
+++ b/hgext3rd/evolve/exthelper.py	Mon Aug 07 23:22:41 2017 +0900
@@ -99,8 +99,11 @@
             revsetpredicate(name)(symbol)
         revset.loadpredicate(ui, 'evolve', revsetpredicate)
 
+        templatekeyword = registrar.templatekeyword()
         for name, kw in self._templatekws:
-            templatekw.keywords[name] = kw
+            templatekeyword(name)(kw)
+        templatekw.loadkeyword(ui, 'evolve', templatekeyword)
+
         for ext, command, wrapper, opts in self._extcommandwrappers:
             if ext not in knownexts:
                 try:
--- a/hgext3rd/evolve/templatekw.py	Sun Sep 10 20:06:52 2017 +0900
+++ b/hgext3rd/evolve/templatekw.py	Mon Aug 07 23:22:41 2017 +0900
@@ -28,7 +28,7 @@
 
 @eh.templatekw('obsolete')
 def obsoletekw(repo, ctx, templ, **args):
-    """:obsolete: String. Whether the changeset is ``obsolete``.
+    """String. Whether the changeset is ``obsolete``.
     """
     if ctx.obsolete():
         return 'obsolete'
@@ -36,7 +36,7 @@
 
 @eh.templatekw('troubles')
 def showtroubles(**args):
-    """:troubles: List of strings. Evolution troubles affecting the changeset
+    """List of strings. Evolution troubles affecting the changeset
     (zero or more of "unstable", "divergent" or "bumped")."""
     ctx = args['ctx']
     try: