namespace: use registrar to add template keyword
authorYuya Nishihara <yuya@tcha.org>
Sun, 25 Feb 2018 18:56:06 +0900
changeset 36621 b0054f3c055a
parent 36620 121a20e5da56
child 36622 900e5ee44307
namespace: use registrar to add template keyword Prepares for switching to the new API.
mercurial/namespaces.py
--- a/mercurial/namespaces.py	Sun Feb 25 16:45:44 2018 +0900
+++ b/mercurial/namespaces.py	Sun Feb 25 18:56:06 2018 +0900
@@ -2,6 +2,7 @@
 
 from .i18n import _
 from . import (
+    registrar,
     templatekw,
     util,
 )
@@ -87,11 +88,11 @@
 
         # we only generate a template keyword if one does not already exist
         if namespace.name not in templatekw.keywords:
+            templatekeyword = registrar.templatekeyword(templatekw.keywords)
+            @templatekeyword(namespace.name)
             def generatekw(**args):
                 return templatekw.shownames(namespace.name, **args)
 
-            templatekw.keywords[namespace.name] = generatekw
-
     def singlenode(self, repo, name):
         """
         Return the 'best' node for the given name. Best means the first node