Patchwork D7241: repoview: move changelog.headrevs() override to filteredchangelog

login
register
mail settings
Submitter phabricator
Date Nov. 6, 2019, 3:38 a.m.
Message ID <caf2197c1df024cb09308c37fb8048f6@localhost.localdomain>
Download mbox | patch
Permalink /patch/42787/
State Not Applicable
Headers show

Comments

phabricator - Nov. 6, 2019, 3:38 a.m.
Closed by commit rHGdbcd0b043d4f: repoview: move changelog.headrevs() override to filteredchangelog (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7241?vs=17571&id=17591

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7241/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7241

AFFECTED FILES
  mercurial/changelog.py
  mercurial/repoview.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -18,6 +18,7 @@ 
     setattr,
 )
 from . import (
+    error,
     obsolete,
     phases,
     pycompat,
@@ -252,6 +253,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
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -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.