Show More
@@ -17,8 +17,9 b' class namespaces(object):' | |||
|
17 | 17 | pollution of jamming things into tags or bookmarks (in extension-land) and |
|
18 | 18 | to simplify internal bits of mercurial: log output, tab completion, etc. |
|
19 | 19 | |
|
20 |
More precisely, we define a list of names (the namespace) |
|
|
21 |
names to nodes |
|
|
20 | More precisely, we define a list of names (the namespace), a mapping of | |
|
21 | names to nodes, and a mapping from nodes to names. Each mapping | |
|
22 | returns a list of nodes. | |
|
22 | 23 | |
|
23 | 24 | Furthermore, each name mapping will be passed a name to lookup which might |
|
24 | 25 | not be in its domain. In this case, each method should return an empty list |
@@ -29,6 +30,7 b' class namespaces(object):' | |||
|
29 | 30 | 'templatename': name to use for templating (usually the singular form |
|
30 | 31 | of the plural namespace name) |
|
31 | 32 | 'namemap': function that takes a name and returns a list of nodes |
|
33 | 'nodemap': function that takes a node and returns a list of names | |
|
32 | 34 | """ |
|
33 | 35 | |
|
34 | 36 | _names_version = 0 |
@@ -41,26 +43,32 b' class namespaces(object):' | |||
|
41 | 43 | # we need current mercurial named objects (bookmarks, tags, and |
|
42 | 44 | # branches) to be initialized somewhere, so that place is here |
|
43 | 45 | addns("bookmarks", "bookmark", |
|
44 |
lambda repo, name: tolist(repo._bookmarks.get(name)) |
|
|
46 | lambda repo, name: tolist(repo._bookmarks.get(name)), | |
|
47 | lambda repo, name: repo.nodebookmarks(name)) | |
|
45 | 48 | |
|
46 | 49 | addns("tags", "tag", |
|
47 |
lambda repo, name: tolist(repo._tagscache.tags.get(name)) |
|
|
50 | lambda repo, name: tolist(repo._tagscache.tags.get(name)), | |
|
51 | lambda repo, name: repo.nodetags(name)) | |
|
48 | 52 | |
|
49 | 53 | addns("branches", "branch", |
|
50 |
lambda repo, name: tolist(repo.branchtip(name)) |
|
|
54 | lambda repo, name: tolist(repo.branchtip(name)), | |
|
55 | lambda repo, node: [repo[node].branch()]) | |
|
51 | 56 | |
|
52 |
def addnamespace(self, namespace, templatename, namemap, |
|
|
57 | def addnamespace(self, namespace, templatename, namemap, nodemap, | |
|
58 | order=None): | |
|
53 | 59 | """ |
|
54 | 60 | register a namespace |
|
55 | 61 | |
|
56 | 62 | namespace: the name to be registered (in plural form) |
|
57 | 63 | templatename: the name to use for templating |
|
58 | 64 | namemap: function that inputs a node, output name(s) |
|
65 | nodemap: function that inputs a name, output node(s) | |
|
59 | 66 | order: optional argument to specify the order of namespaces |
|
60 | 67 | (e.g. 'branches' should be listed before 'bookmarks') |
|
61 | 68 | """ |
|
62 | 69 | val = {'templatename': templatename, |
|
63 |
'namemap': namemap |
|
|
70 | 'namemap': namemap, | |
|
71 | 'nodemap': nodemap} | |
|
64 | 72 | if order is not None: |
|
65 | 73 | self._names.insert(order, namespace, val) |
|
66 | 74 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now