Submitter | Sean Farley |
---|---|
Date | Dec. 15, 2014, 12:37 a.m. |
Message ID | <4d7a45c8487a63ac5497.1418603872@laptop.local> |
Download | mbox | patch |
Permalink | /patch/7097/ |
State | Accepted |
Headers | show |
Comments
On 12/14/2014 04:37 PM, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # 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. Note: I'm not super fan of the weakref thing. But this topic have been laying around for so long that I prefer to see it moving forward. We can adjust the weakref afterward.
Patch
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