namespaces: pass repo to __init__
authorSean Farley <sean.michael.farley@gmail.com>
Sun, 14 Dec 2014 15:35:57 -0800
changeset 23556 7e1da5d004eb
parent 23555 f08f6a7d4d5f
child 23557 b04b27aa6da3
namespaces: pass repo to __init__ We store repo as a weakref so that we can prevent a cycle between namespaces and localrepo.
mercurial/namespaces.py
--- a/mercurial/namespaces.py	Sun Dec 14 15:04:40 2014 -0800
+++ b/mercurial/namespaces.py	Sun Dec 14 15:35:57 2014 -0800
@@ -1,4 +1,5 @@
 from mercurial import util
+import weakref
 
 def tolist(val):
     """
@@ -30,8 +31,9 @@
 
     _names_version = 0
 
-    def __init__(self):
+    def __init__(self, repo):
         self._names = util.sortdict()
+        self._repo = weakref.ref(repo)
 
     def addnamespace(self, namespace, namemap, order=None):
         """