Show More
@@ -22,27 +22,27 b' class namespaces(object):' | |||||
22 | def __init__(self): |
|
22 | def __init__(self): | |
23 | self._names = util.sortdict() |
|
23 | self._names = util.sortdict() | |
24 |
|
24 | |||
25 | # shorten the class name for less indentation |
|
|||
26 | ns = namespace |
|
|||
27 |
|
||||
28 | # we need current mercurial named objects (bookmarks, tags, and |
|
25 | # we need current mercurial named objects (bookmarks, tags, and | |
29 | # branches) to be initialized somewhere, so that place is here |
|
26 | # branches) to be initialized somewhere, so that place is here | |
30 | n = ns("bookmarks", "bookmark", |
|
27 | bmknames = lambda repo: repo._bookmarks.keys() | |
31 |
|
|
28 | bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name)) | |
32 |
|
|
29 | bmknodemap = lambda repo, name: repo.nodebookmarks(name) | |
33 | lambda repo, name: repo.nodebookmarks(name)) |
|
30 | n = namespace("bookmarks", templatename="bookmark", listnames=bmknames, | |
|
31 | namemap=bmknamemap, nodemap=bmknodemap) | |||
34 | self.addnamespace(n) |
|
32 | self.addnamespace(n) | |
35 |
|
33 | |||
36 | n = ns("tags", "tag", |
|
34 | tagnames = lambda repo: [t for t, n in repo.tagslist()] | |
37 | lambda repo: [t for t, n in repo.tagslist()], |
|
35 | tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name)) | |
38 |
|
|
36 | tagnodemap = lambda repo, name: repo.nodetags(name) | |
39 | lambda repo, name: repo.nodetags(name)) |
|
37 | n = namespace("tags", templatename="tag", listnames=tagnames, | |
|
38 | namemap=tagnamemap, nodemap=tagnodemap) | |||
40 | self.addnamespace(n) |
|
39 | self.addnamespace(n) | |
41 |
|
40 | |||
42 | n = ns("branches", "branch", |
|
41 | bnames = lambda repo: repo.branchmap().keys() | |
43 |
|
|
42 | bnamemap = lambda repo, name: tolist(repo.branchtip(name, True)) | |
44 |
|
|
43 | bnodemap = lambda repo, node: [repo[node].branch()] | |
45 | lambda repo, node: [repo[node].branch()]) |
|
44 | n = namespace("branches", templatename="branch", listnames=bnames, | |
|
45 | namemap=bnamemap, nodemap=bnodemap) | |||
46 | self.addnamespace(n) |
|
46 | self.addnamespace(n) | |
47 |
|
47 | |||
48 | def __getitem__(self, namespace): |
|
48 | def __getitem__(self, namespace): |
@@ -1567,12 +1567,13 b' Check that adding an arbitrary name show' | |||||
1567 | > |
|
1567 | > | |
1568 | > def reposetup(ui, repo): |
|
1568 | > def reposetup(ui, repo): | |
1569 | > foo = {'foo': repo[0].node()} |
|
1569 | > foo = {'foo': repo[0].node()} | |
1570 | > ns = namespace("bars", "bar", |
|
1570 | > names = lambda r: foo.keys() | |
1571 | > lambda r: foo.keys(), |
|
1571 | > namemap = lambda r, name: foo.get(name) | |
1572 | > lambda r, name: foo.get(name), |
|
1572 | > nodemap = lambda r, node: [name for name, n in foo.iteritems() | |
1573 | > lambda r, node: [name for name, n |
|
1573 | > if n == node] | |
1574 | > in foo.iteritems() |
|
1574 | > ns = namespace("bars", templatename="bar", listnames=names, | |
1575 | > if n == node]) |
|
1575 | > namemap=namemap, nodemap=nodemap) | |
|
1576 | > | |||
1576 |
|
|
1577 | > repo.names.addnamespace(ns) | |
1577 | > EOF |
|
1578 | > EOF | |
1578 |
|
1579 |
General Comments 0
You need to be logged in to leave comments.
Login now