D1577: localrepo: fix cache repo._filteredrepotypes by adding filtername in key
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Sat Dec 2 00:32:59 UTC 2017
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Before this patch,
In [13]: repo.filtered('visible').__class__
Out[13]: mercurial.localrepo.visiblefilteredrepo
In [14]: repo.filtered('served').__class__
Out[14]: mercurial.localrepo.visiblefilteredrepo
`repo.unfiltered().__class__` can be same for two different repoviews, so that's
not a good key for the cache. We need to include the filtername in the key so
that we can have different keys for different repoview classes. After this
patch,
In [13]: repo.filtered('visible').__class__
Out[13]: mercurial.localrepo.visiblefilteredrepo
In [14]: repo.filtered('served').__class__
Out[14]: mercurial.localrepo.servedfilteredrepo
The above behaviour can also be noticed using `hg debugshell`.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D1577
AFFECTED FILES
mercurial/localrepo.py
CHANGE DETAILS
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -503,7 +503,7 @@
self._postdsstatus = []
# Cache of types representing filtered repos.
- self._filteredrepotypes = weakref.WeakKeyDictionary()
+ self._filteredrepotypes = weakref.WeakValueDictionary()
# generic mapping between names and nodes
self.names = namespaces.namespaces()
@@ -685,12 +685,13 @@
# created types so this method doesn't leak on every
# invocation.
- key = self.unfiltered().__class__
+ unfibase = self.unfiltered().__class__
+ key = str(self.unfiltered().__class__) + name
if key not in self._filteredrepotypes:
# Build a new type with the repoview mixin and the base
# class of this repo. Give it a name containing the
# filter name to aid debugging.
- bases = (repoview.repoview, key)
+ bases = (repoview.repoview, unfibase)
cls = type(r'%sfilteredrepo' % name, bases, {})
self._filteredrepotypes[key] = cls
To: pulkit, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list