##// END OF EJS Templates
repoview: extract a factory function of proxy class...
Yuya Nishihara -
r35248:c752fbe2 default
parent child Browse files
Show More
@@ -502,9 +502,6 b' class localrepository(object):'
502 # post-dirstate-status hooks
502 # post-dirstate-status hooks
503 self._postdsstatus = []
503 self._postdsstatus = []
504
504
505 # Cache of types representing filtered repos.
506 self._filteredrepotypes = weakref.WeakKeyDictionary()
507
508 # generic mapping between names and nodes
505 # generic mapping between names and nodes
509 self.names = namespaces.namespaces()
506 self.names = namespaces.namespaces()
510
507
@@ -680,20 +677,8 b' class localrepository(object):'
680
677
681 def filtered(self, name):
678 def filtered(self, name):
682 """Return a filtered version of a repository"""
679 """Return a filtered version of a repository"""
683 # Python <3.4 easily leaks types via __mro__. See
680 cls = repoview.newtype(self.unfiltered().__class__)
684 # https://bugs.python.org/issue17950. We cache dynamically
681 return cls(self, name)
685 # created types so this method doesn't leak on every
686 # invocation.
687
688 key = self.unfiltered().__class__
689 if key not in self._filteredrepotypes:
690 # Build a new type with the repoview mixin and the base
691 # class of this repo.
692 class filteredrepo(repoview.repoview, key):
693 pass
694 self._filteredrepotypes[key] = filteredrepo
695
696 return self._filteredrepotypes[key](self, name)
697
682
698 @repofilecache('bookmarks', 'bookmarks.current')
683 @repofilecache('bookmarks', 'bookmarks.current')
699 def _bookmarks(self):
684 def _bookmarks(self):
@@ -9,6 +9,7 b''
9 from __future__ import absolute_import
9 from __future__ import absolute_import
10
10
11 import copy
11 import copy
12 import weakref
12
13
13 from .node import nullrev
14 from .node import nullrev
14 from . import (
15 from . import (
@@ -240,3 +241,16 b' class repoview(object):'
240
241
241 def __delattr__(self, attr):
242 def __delattr__(self, attr):
242 return delattr(self._unfilteredrepo, attr)
243 return delattr(self._unfilteredrepo, attr)
244
245 # Python <3.4 easily leaks types via __mro__. See
246 # https://bugs.python.org/issue17950. We cache dynamically created types
247 # so they won't be leaked on every invocation of repo.filtered().
248 _filteredrepotypes = weakref.WeakKeyDictionary()
249
250 def newtype(base):
251 """Create a new type with the repoview mixin and the given base class"""
252 if base not in _filteredrepotypes:
253 class filteredrepo(repoview, base):
254 pass
255 _filteredrepotypes[base] = filteredrepo
256 return _filteredrepotypes[base]
@@ -166,8 +166,6 b' class statichttprepository(localrepo.loc'
166 self.encodepats = None
166 self.encodepats = None
167 self.decodepats = None
167 self.decodepats = None
168 self._transref = None
168 self._transref = None
169 # Cache of types representing filtered repos.
170 self._filteredrepotypes = {}
171
169
172 def _restrictcapabilities(self, caps):
170 def _restrictcapabilities(self, caps):
173 caps = super(statichttprepository, self)._restrictcapabilities(caps)
171 caps = super(statichttprepository, self)._restrictcapabilities(caps)
General Comments 0
You need to be logged in to leave comments. Login now