[PATCH 03 of 10] namespace: use registrar to add template keyword

Yuya Nishihara yuya at tcha.org
Thu Mar 1 20:51:53 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1519552566 -32400
#      Sun Feb 25 18:56:06 2018 +0900
# Node ID 00b4baafd47b4fb77c7946ccadefb69bc1525e41
# Parent  d82d2b2d91a5742b57f0b29d7ce3bcb0cd5da90b
namespace: use registrar to add template keyword

Prepares for switching to the new API.

diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py
--- a/mercurial/namespaces.py
+++ b/mercurial/namespaces.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import
 
 from .i18n import _
 from . import (
+    registrar,
     templatekw,
     util,
 )
@@ -87,11 +88,11 @@ class namespaces(object):
 
         # 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


More information about the Mercurial-devel mailing list