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

login
register
mail settings
Submitter Yuya Nishihara
Date March 2, 2018, 1:51 a.m.
Message ID <00b4baafd47b4fb77c79.1519955513@mimosa>
Download mbox | patch
Permalink /patch/28648/
State Accepted
Headers show

Comments

Yuya Nishihara - March 2, 2018, 1:51 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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