changeset 43499:476754edac1f

repoview: move changelog.headrevs() override to filteredchangelog Differential Revision: https://phab.mercurial-scm.org/D7241
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 05 Nov 2019 14:16:46 -0800
parents 5ade47284dda
children c31fa28d1843
files mercurial/changelog.py mercurial/repoview.py
diffstat 2 files changed, 35 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Tue Nov 05 14:14:45 2019 -0800
+++ b/mercurial/changelog.py	Tue Nov 05 14:16:46 2019 -0800
@@ -21,7 +21,6 @@
     error,
     pycompat,
     revlog,
-    util,
 )
 from .utils import (
     dateutil,
@@ -405,40 +404,6 @@
         self.filteredrevs = frozenset()
         self._copiesstorage = opener.options.get(b'copies-storage')
 
-    def _checknofilteredinrevs(self, revs):
-        """raise the appropriate error if 'revs' contains a filtered revision
-
-        This returns a version of 'revs' to be used thereafter by the caller.
-        In particular, if revs is an iterator, it is converted into a set.
-        """
-        safehasattr = util.safehasattr
-        if safehasattr(revs, '__next__'):
-            # Note that inspect.isgenerator() is not true for iterators,
-            revs = set(revs)
-
-        filteredrevs = self.filteredrevs
-        if safehasattr(revs, 'first'):  # smartset
-            offenders = revs & filteredrevs
-        else:
-            offenders = filteredrevs.intersection(revs)
-
-        for rev in offenders:
-            raise error.FilteredIndexError(rev)
-        return revs
-
-    def headrevs(self, revs=None):
-        if revs is None and self.filteredrevs:
-            try:
-                return self.index.headrevsfiltered(self.filteredrevs)
-            # AttributeError covers non-c-extension environments and
-            # old c extensions without filter handling.
-            except AttributeError:
-                return self._headrevs()
-
-        if self.filteredrevs:
-            revs = self._checknofilteredinrevs(revs)
-        return super(changelog, self).headrevs(revs)
-
     def strip(self, *args, **kwargs):
         # XXX make something better than assert
         # We can't expect proper strip behavior if we are filtered.
--- a/mercurial/repoview.py	Tue Nov 05 14:14:45 2019 -0800
+++ b/mercurial/repoview.py	Tue Nov 05 14:16:46 2019 -0800
@@ -18,6 +18,7 @@
     setattr,
 )
 from . import (
+    error,
     obsolete,
     phases,
     pycompat,
@@ -253,6 +254,40 @@
                 if i not in self.filteredrevs:
                     yield i
 
+        def _checknofilteredinrevs(self, revs):
+            """raise the appropriate error if 'revs' contains a filtered revision
+
+            This returns a version of 'revs' to be used thereafter by the caller.
+            In particular, if revs is an iterator, it is converted into a set.
+            """
+            safehasattr = util.safehasattr
+            if safehasattr(revs, '__next__'):
+                # Note that inspect.isgenerator() is not true for iterators,
+                revs = set(revs)
+
+            filteredrevs = self.filteredrevs
+            if safehasattr(revs, 'first'):  # smartset
+                offenders = revs & filteredrevs
+            else:
+                offenders = filteredrevs.intersection(revs)
+
+            for rev in offenders:
+                raise error.FilteredIndexError(rev)
+            return revs
+
+        def headrevs(self, revs=None):
+            if revs is None and self.filteredrevs:
+                try:
+                    return self.index.headrevsfiltered(self.filteredrevs)
+                # AttributeError covers non-c-extension environments and
+                # old c extensions without filter handling.
+                except AttributeError:
+                    return self._headrevs()
+
+            if self.filteredrevs:
+                revs = self._checknofilteredinrevs(revs)
+            return super(filteredchangelog, self).headrevs(revs)
+
     cl.__class__ = filteredchangelog
 
     return cl