Show More
@@ -430,6 +430,9 b' class localrepository(object):' | |||||
430 | # post-dirstate-status hooks |
|
430 | # post-dirstate-status hooks | |
431 | self._postdsstatus = [] |
|
431 | self._postdsstatus = [] | |
432 |
|
432 | |||
|
433 | # Cache of types representing filtered repos. | |||
|
434 | self._filteredrepotypes = weakref.WeakKeyDictionary() | |||
|
435 | ||||
433 | # generic mapping between names and nodes |
|
436 | # generic mapping between names and nodes | |
434 | self.names = namespaces.namespaces() |
|
437 | self.names = namespaces.namespaces() | |
435 |
|
438 | |||
@@ -539,11 +542,21 b' class localrepository(object):' | |||||
539 |
|
542 | |||
540 | def filtered(self, name): |
|
543 | def filtered(self, name): | |
541 | """Return a filtered version of a repository""" |
|
544 | """Return a filtered version of a repository""" | |
542 | # build a new class with the mixin and the current class |
|
545 | # Python <3.4 easily leaks types via __mro__. See | |
543 | # (possibly subclass of the repo) |
|
546 | # https://bugs.python.org/issue17950. We cache dynamically | |
544 | class filteredrepo(repoview.repoview, self.unfiltered().__class__): |
|
547 | # created types so this method doesn't leak on every | |
545 | pass |
|
548 | # invocation. | |
546 | return filteredrepo(self, name) |
|
549 | ||
|
550 | key = self.unfiltered().__class__ | |||
|
551 | if key not in self._filteredrepotypes: | |||
|
552 | # Build a new type with the repoview mixin and the base | |||
|
553 | # class of this repo. Give it a name containing the | |||
|
554 | # filter name to aid debugging. | |||
|
555 | bases = (repoview.repoview, key) | |||
|
556 | cls = type('%sfilteredrepo' % name, bases, {}) | |||
|
557 | self._filteredrepotypes[key] = cls | |||
|
558 | ||||
|
559 | return self._filteredrepotypes[key](self, name) | |||
547 |
|
560 | |||
548 | @repofilecache('bookmarks', 'bookmarks.current') |
|
561 | @repofilecache('bookmarks', 'bookmarks.current') | |
549 | def _bookmarks(self): |
|
562 | def _bookmarks(self): |
@@ -165,6 +165,8 b' class statichttprepository(localrepo.loc' | |||||
165 | self.encodepats = None |
|
165 | self.encodepats = None | |
166 | self.decodepats = None |
|
166 | self.decodepats = None | |
167 | self._transref = None |
|
167 | self._transref = None | |
|
168 | # Cache of types representing filtered repos. | |||
|
169 | self._filteredrepotypes = {} | |||
168 |
|
170 | |||
169 | def _restrictcapabilities(self, caps): |
|
171 | def _restrictcapabilities(self, caps): | |
170 | caps = super(statichttprepository, self)._restrictcapabilities(caps) |
|
172 | caps = super(statichttprepository, self)._restrictcapabilities(caps) |
General Comments 0
You need to be logged in to leave comments.
Login now