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