Show More
@@ -12,26 +12,9 b' def tolist(val):' | |||||
12 | return [val] |
|
12 | return [val] | |
13 |
|
13 | |||
14 | class namespaces(object): |
|
14 | class namespaces(object): | |
15 | """ |
|
15 | """provides an interface to register and operate on multiple namespaces. See | |
16 | provides an interface to register a generic many-to-many mapping between |
|
16 | the namespace class below for details on the namespace object. | |
17 | some (namespaced) names and nodes. The goal here is to control the |
|
|||
18 | pollution of jamming things into tags or bookmarks (in extension-land) and |
|
|||
19 | to simplify internal bits of mercurial: log output, tab completion, etc. |
|
|||
20 |
|
||||
21 | More precisely, we define a list of names (the namespace), a mapping of |
|
|||
22 | names to nodes, and a mapping from nodes to names. Each mapping |
|
|||
23 | returns a list of nodes. |
|
|||
24 |
|
17 | |||
25 | Furthermore, each name mapping will be passed a name to lookup which might |
|
|||
26 | not be in its domain. In this case, each method should return an empty list |
|
|||
27 | and not raise an error. |
|
|||
28 |
|
||||
29 | We'll have a dictionary '_names' where each key is a namespace and |
|
|||
30 | its value is a dictionary of functions: |
|
|||
31 | 'templatename': name to use for templating (usually the singular form |
|
|||
32 | of the plural namespace name) |
|
|||
33 | 'namemap': function that takes a name and returns a list of nodes |
|
|||
34 | 'nodemap': function that takes a node and returns a list of names |
|
|||
35 | """ |
|
18 | """ | |
36 |
|
19 | |||
37 | _names_version = 0 |
|
20 | _names_version = 0 | |
@@ -60,15 +43,12 b' class namespaces(object):' | |||||
60 | self.addnamespace(n) |
|
43 | self.addnamespace(n) | |
61 |
|
44 | |||
62 | def addnamespace(self, namespace, order=None): |
|
45 | def addnamespace(self, namespace, order=None): | |
63 | """ |
|
46 | """register a namespace | |
64 | register a namespace |
|
|||
65 |
|
47 | |||
66 | namespace: the name to be registered (in plural form) |
|
48 | namespace: the name to be registered (in plural form) | |
67 | templatename: the name to use for templating |
|
|||
68 | namemap: function that inputs a node, output name(s) |
|
|||
69 | nodemap: function that inputs a name, output node(s) |
|
|||
70 | order: optional argument to specify the order of namespaces |
|
49 | order: optional argument to specify the order of namespaces | |
71 | (e.g. 'branches' should be listed before 'bookmarks') |
|
50 | (e.g. 'branches' should be listed before 'bookmarks') | |
|
51 | ||||
72 | """ |
|
52 | """ | |
73 | if order is not None: |
|
53 | if order is not None: | |
74 | self._names.insert(order, namespace.name, namespace) |
|
54 | self._names.insert(order, namespace.name, namespace) |
General Comments 0
You need to be logged in to leave comments.
Login now