##// END OF EJS Templates
namespaces: add a namespace object...
Sean Farley -
r23715:eee55c09 default
parent child Browse files
Show More
@@ -109,3 +109,41 b' class namespaces(object):'
109 """method that returns a (sorted) list of names in a namespace that
109 """method that returns a (sorted) list of names in a namespace that
110 match a given node"""
110 match a given node"""
111 return sorted(self._names[namespace]['nodemap'](repo, node))
111 return sorted(self._names[namespace]['nodemap'](repo, node))
112
113 class namespace(object):
114 """provides an interface to a namespace
115
116 Namespaces are basically generic many-to-many mapping between some
117 (namespaced) names and nodes. The goal here is to control the pollution of
118 jamming things into tags or bookmarks (in extension-land) and to simplify
119 internal bits of mercurial: log output, tab completion, etc.
120
121 More precisely, we define a mapping of names to nodes, and a mapping from
122 nodes to names. Each mapping returns a list.
123
124 Furthermore, each name mapping will be passed a name to lookup which might
125 not be in its domain. In this case, each method should return an empty list
126 and not raise an error.
127
128 This namespace object will define the properties we need:
129 'name': the namespace (plural form)
130 'templatename': name to use for templating (usually the singular form
131 of the plural namespace name)
132 'namemap': function that takes a name and returns a list of nodes
133 'nodemap': function that takes a node and returns a list of names
134
135 """
136
137 def __init__(self, name, templatename, namemap, nodemap):
138 """create a namespace
139
140 name: the namespace to be registered (in plural form)
141 templatename: the name to use for templating
142 namemap: function that inputs a node, output name(s)
143 nodemap: function that inputs a name, output node(s)
144
145 """
146 self.name = name
147 self.templatename = templatename
148 self.namemap = namemap
149 self.nodemap = nodemap
General Comments 0
You need to be logged in to leave comments. Login now