Show More
@@ -409,7 +409,7 b' class changectx(basectx):' | |||||
409 |
|
409 | |||
410 | # lookup bookmarks through the name interface |
|
410 | # lookup bookmarks through the name interface | |
411 | try: |
|
411 | try: | |
412 | self._node = repo.names.singlenode(changeid) |
|
412 | self._node = repo.names.singlenode(repo, changeid) | |
413 | self._rev = repo.changelog.rev(self._node) |
|
413 | self._rev = repo.changelog.rev(self._node) | |
414 | return |
|
414 | return | |
415 | except KeyError: |
|
415 | except KeyError: |
@@ -299,7 +299,7 b' class localrepository(object):' | |||||
299 | self.filteredrevcache = {} |
|
299 | self.filteredrevcache = {} | |
300 |
|
300 | |||
301 | # generic mapping between names and nodes |
|
301 | # generic mapping between names and nodes | |
302 |
self.names = namespaces.namespaces( |
|
302 | self.names = namespaces.namespaces() | |
303 |
|
303 | |||
304 | def close(self): |
|
304 | def close(self): | |
305 | pass |
|
305 | pass |
@@ -1,6 +1,5 b'' | |||||
1 | from i18n import _ |
|
1 | from i18n import _ | |
2 | from mercurial import util |
|
2 | from mercurial import util | |
3 | import weakref |
|
|||
4 |
|
3 | |||
5 | def tolist(val): |
|
4 | def tolist(val): | |
6 | """ |
|
5 | """ | |
@@ -32,19 +31,14 b' class namespaces(object):' | |||||
32 |
|
31 | |||
33 | _names_version = 0 |
|
32 | _names_version = 0 | |
34 |
|
33 | |||
35 |
def __init__(self |
|
34 | def __init__(self): | |
36 | self._names = util.sortdict() |
|
35 | self._names = util.sortdict() | |
37 | self._repo = weakref.ref(repo) |
|
|||
38 |
|
36 | |||
39 | # we need current mercurial named objects (bookmarks, tags, and |
|
37 | # we need current mercurial named objects (bookmarks, tags, and | |
40 | # branches) to be initialized somewhere, so that place is here |
|
38 | # branches) to be initialized somewhere, so that place is here | |
41 | self.addnamespace("bookmarks", |
|
39 | self.addnamespace("bookmarks", | |
42 | lambda repo, name: tolist(repo._bookmarks.get(name))) |
|
40 | lambda repo, name: tolist(repo._bookmarks.get(name))) | |
43 |
|
41 | |||
44 | @property |
|
|||
45 | def repo(self): |
|
|||
46 | return self._repo() |
|
|||
47 |
|
||||
48 | def addnamespace(self, namespace, namemap, order=None): |
|
42 | def addnamespace(self, namespace, namemap, order=None): | |
49 | """ |
|
43 | """ | |
50 | register a namespace |
|
44 | register a namespace | |
@@ -60,7 +54,7 b' class namespaces(object):' | |||||
60 | else: |
|
54 | else: | |
61 | self._names[namespace] = val |
|
55 | self._names[namespace] = val | |
62 |
|
56 | |||
63 | def singlenode(self, name): |
|
57 | def singlenode(self, repo, name): | |
64 | """ |
|
58 | """ | |
65 | Return the 'best' node for the given name. Best means the first node |
|
59 | Return the 'best' node for the given name. Best means the first node | |
66 | in the first nonempty list returned by a name-to-nodes mapping function |
|
60 | in the first nonempty list returned by a name-to-nodes mapping function | |
@@ -69,11 +63,11 b' class namespaces(object):' | |||||
69 | Raises a KeyError if there is no such node. |
|
63 | Raises a KeyError if there is no such node. | |
70 | """ |
|
64 | """ | |
71 | for ns, v in self._names.iteritems(): |
|
65 | for ns, v in self._names.iteritems(): | |
72 |
n = v['namemap']( |
|
66 | n = v['namemap'](repo, name) | |
73 | if n: |
|
67 | if n: | |
74 | # return max revision number |
|
68 | # return max revision number | |
75 | if len(n) > 1: |
|
69 | if len(n) > 1: | |
76 |
cl = |
|
70 | cl = repo.changelog | |
77 | maxrev = max(cl.rev(node) for node in n) |
|
71 | maxrev = max(cl.rev(node) for node in n) | |
78 | return cl.node(maxrev) |
|
72 | return cl.node(maxrev) | |
79 | return n[0] |
|
73 | return n[0] |
@@ -106,7 +106,7 b' class statichttprepository(localrepo.loc' | |||||
106 | self.vfs = self.opener |
|
106 | self.vfs = self.opener | |
107 | self._phasedefaults = [] |
|
107 | self._phasedefaults = [] | |
108 |
|
108 | |||
109 |
self.names = namespaces.namespaces( |
|
109 | self.names = namespaces.namespaces() | |
110 |
|
110 | |||
111 | try: |
|
111 | try: | |
112 | requirements = scmutil.readrequires(self.opener, self.supported) |
|
112 | requirements = scmutil.readrequires(self.opener, self.supported) |
General Comments 0
You need to be logged in to leave comments.
Login now