# HG changeset patch # User Martin von Zweigbergk # Date 2019-11-05 23:00:44 # Node ID c8e5b3094a1dbca6cdc58486011fbc7fdac60539 # Parent 61c37210000837b9488aa763de669a3a69a905f3 repoview: avoid wrapping changelog if there's nothing to filter This simplifies the code a bit by moving the optimizaton for no filtered revisions to one place. I assume it also makes working with repos without obsmarkers a little faster, but it doesn't seem significant. Differential Revision: https://phab.mercurial-scm.org/D7248 diff --git a/mercurial/repoview.py b/mercurial/repoview.py --- a/mercurial/repoview.py +++ b/mercurial/repoview.py @@ -26,7 +26,6 @@ from . import ( obsolete, phases, pycompat, - revlog, tags as tagsmod, util, ) @@ -241,9 +240,6 @@ def wrapchangelog(unfichangelog, filtere def __iter__(self): """filtered version of revlog.__iter__""" - if len(self.filteredrevs) == 0: - return revlog.revlog.__iter__(self) - def filterediter(): for i in pycompat.xrange(len(self)): @@ -280,7 +276,7 @@ def wrapchangelog(unfichangelog, filtere return revs def headrevs(self, revs=None): - if revs is None and self.filteredrevs: + if revs is None: try: return self.index.headrevsfiltered(self.filteredrevs) # AttributeError covers non-c-extension environments and @@ -288,8 +284,7 @@ def wrapchangelog(unfichangelog, filtere except AttributeError: return self._headrevs() - if self.filteredrevs: - revs = self._checknofilteredinrevs(revs) + revs = self._checknofilteredinrevs(revs) return super(filteredchangelog, self).headrevs(revs) def strip(self, *args, **kwargs): @@ -404,7 +399,8 @@ class repoview(object): cl = None # could have been made None by the previous if if cl is None: - cl = wrapchangelog(unfichangelog, revs) + # Only filter if there's something to filter + cl = wrapchangelog(unfichangelog, revs) if revs else unfichangelog object.__setattr__(self, r'_clcache', cl) object.__setattr__(self, r'_clcachekey', newkey) return cl