D7248: repoview: avoid wrapping changelog if there's nothing to filter
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Nov 6 00:59:49 UTC 2019
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D7248
AFFECTED FILES
mercurial/repoview.py
CHANGE DETAILS
diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -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)):
if i not in self.filteredrevs:
@@ -279,7 +275,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
@@ -287,8 +283,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):
@@ -402,7 +397,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
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list