From patchwork Mon Dec 15 00:37:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,8] namespaces: pass repo to __init__ From: Sean Farley X-Patchwork-Id: 7097 Message-Id: <4d7a45c8487a63ac5497.1418603872@laptop.local> To: mercurial-devel@selenic.com Date: Sun, 14 Dec 2014 16:37:52 -0800 # HG changeset patch # User Sean Farley # Date 1418600157 28800 # Sun Dec 14 15:35:57 2014 -0800 # Node ID 4d7a45c8487a63ac54971c4dbeddf2dac922a91f # Parent 519aa5b4f74d5604b2d3d34c4e75b99d698b01b5 namespaces: pass repo to __init__ We store repo as a weakref so that we can prevent a cycle between namespaces and localrepo. diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py --- a/mercurial/namespaces.py +++ b/mercurial/namespaces.py @@ -1,6 +1,7 @@ from mercurial import util +import weakref def multify(val): """ a convenience method to return an empty list instead of None """ @@ -39,12 +40,13 @@ class namespaces(object): 'nodemap': function that inputs a node and returns a list of names """ _names_version = 0 - def __init__(self): + def __init__(self, repo): self._names = util.sortdict() + self._repo = weakref.ref(repo) def addnamespace(self, namespace, singular, names, namemap, nodemap, order=None): """ register a namespace