comparison mercurial/namespaces.py @ 36592:b0054f3c055a

namespace: use registrar to add template keyword Prepares for switching to the new API.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 25 Feb 2018 18:56:06 +0900
parents c7b45db8f317
children 900e5ee44307
comparison
equal deleted inserted replaced
36591:121a20e5da56 36592:b0054f3c055a
1 from __future__ import absolute_import 1 from __future__ import absolute_import
2 2
3 from .i18n import _ 3 from .i18n import _
4 from . import ( 4 from . import (
5 registrar,
5 templatekw, 6 templatekw,
6 util, 7 util,
7 ) 8 )
8 9
9 def tolist(val): 10 def tolist(val):
85 else: 86 else:
86 self._names[namespace.name] = namespace 87 self._names[namespace.name] = namespace
87 88
88 # we only generate a template keyword if one does not already exist 89 # we only generate a template keyword if one does not already exist
89 if namespace.name not in templatekw.keywords: 90 if namespace.name not in templatekw.keywords:
91 templatekeyword = registrar.templatekeyword(templatekw.keywords)
92 @templatekeyword(namespace.name)
90 def generatekw(**args): 93 def generatekw(**args):
91 return templatekw.shownames(namespace.name, **args) 94 return templatekw.shownames(namespace.name, **args)
92
93 templatekw.keywords[namespace.name] = generatekw
94 95
95 def singlenode(self, repo, name): 96 def singlenode(self, repo, name):
96 """ 97 """
97 Return the 'best' node for the given name. Best means the first node 98 Return the 'best' node for the given name. Best means the first node
98 in the first nonempty list returned by a name-to-nodes mapping function 99 in the first nonempty list returned by a name-to-nodes mapping function