Show More
@@ -28,16 +28,19 b' class namespaces(object):' | |||||
28 | # we need current mercurial named objects (bookmarks, tags, and |
|
28 | # we need current mercurial named objects (bookmarks, tags, and | |
29 | # branches) to be initialized somewhere, so that place is here |
|
29 | # branches) to be initialized somewhere, so that place is here | |
30 | n = ns("bookmarks", "bookmark", |
|
30 | n = ns("bookmarks", "bookmark", | |
|
31 | lambda repo: repo._bookmarks.keys(), | |||
31 | lambda repo, name: tolist(repo._bookmarks.get(name)), |
|
32 | lambda repo, name: tolist(repo._bookmarks.get(name)), | |
32 | lambda repo, name: repo.nodebookmarks(name)) |
|
33 | lambda repo, name: repo.nodebookmarks(name)) | |
33 | self.addnamespace(n) |
|
34 | self.addnamespace(n) | |
34 |
|
35 | |||
35 | n = ns("tags", "tag", |
|
36 | n = ns("tags", "tag", | |
|
37 | lambda repo: [t for t, n in repo.tagslist()], | |||
36 | lambda repo, name: tolist(repo._tagscache.tags.get(name)), |
|
38 | lambda repo, name: tolist(repo._tagscache.tags.get(name)), | |
37 | lambda repo, name: repo.nodetags(name)) |
|
39 | lambda repo, name: repo.nodetags(name)) | |
38 | self.addnamespace(n) |
|
40 | self.addnamespace(n) | |
39 |
|
41 | |||
40 | n = ns("branches", "branch", |
|
42 | n = ns("branches", "branch", | |
|
43 | lambda repo: repo.branchmap().keys(), | |||
41 | lambda repo, name: tolist(repo.branchtip(name)), |
|
44 | lambda repo, name: tolist(repo.branchtip(name)), | |
42 | lambda repo, node: [repo[node].branch()]) |
|
45 | lambda repo, node: [repo[node].branch()]) | |
43 | self.addnamespace(n) |
|
46 | self.addnamespace(n) | |
@@ -104,15 +107,18 b' class namespace(object):' | |||||
104 | 'name': the namespace (plural form) |
|
107 | 'name': the namespace (plural form) | |
105 | 'templatename': name to use for templating (usually the singular form |
|
108 | 'templatename': name to use for templating (usually the singular form | |
106 | of the plural namespace name) |
|
109 | of the plural namespace name) | |
|
110 | 'listnames': list of all names in the namespace (usually the keys of a | |||
|
111 | dictionary) | |||
107 | 'namemap': function that takes a name and returns a list of nodes |
|
112 | 'namemap': function that takes a name and returns a list of nodes | |
108 | 'nodemap': function that takes a node and returns a list of names |
|
113 | 'nodemap': function that takes a node and returns a list of names | |
109 |
|
114 | |||
110 | """ |
|
115 | """ | |
111 |
|
116 | |||
112 | def __init__(self, name, templatename, namemap, nodemap): |
|
117 | def __init__(self, name, templatename, listnames, namemap, nodemap): | |
113 | """create a namespace |
|
118 | """create a namespace | |
114 |
|
119 | |||
115 | name: the namespace to be registered (in plural form) |
|
120 | name: the namespace to be registered (in plural form) | |
|
121 | listnames: function to list all names | |||
116 | templatename: the name to use for templating |
|
122 | templatename: the name to use for templating | |
117 | namemap: function that inputs a node, output name(s) |
|
123 | namemap: function that inputs a node, output name(s) | |
118 | nodemap: function that inputs a name, output node(s) |
|
124 | nodemap: function that inputs a name, output node(s) | |
@@ -120,6 +126,7 b' class namespace(object):' | |||||
120 | """ |
|
126 | """ | |
121 | self.name = name |
|
127 | self.name = name | |
122 | self.templatename = templatename |
|
128 | self.templatename = templatename | |
|
129 | self.listnames = listnames | |||
123 | self.namemap = namemap |
|
130 | self.namemap = namemap | |
124 | self.nodemap = nodemap |
|
131 | self.nodemap = nodemap | |
125 |
|
132 |
General Comments 0
You need to be logged in to leave comments.
Login now