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