Mercurial > hg
diff mercurial/repoview.py @ 43454:c8e5b3094a1d
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
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 05 Nov 2019 15:00:44 -0800 |
parents | 61c372100008 |
children | bad4a26b4607 |
line wrap: on
line diff
--- a/mercurial/repoview.py Tue Nov 05 14:33:02 2019 -0800 +++ b/mercurial/repoview.py Tue Nov 05 15:00:44 2019 -0800 @@ -26,7 +26,6 @@ obsolete, phases, pycompat, - revlog, tags as tagsmod, util, ) @@ -241,9 +240,6 @@ 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 @@ 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 @@ 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 @@ 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