revlog: move tiprev() from changelog up to revlog
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 05 Nov 2019 14:42:08 -0800
changeset 43440 ec7ba79bf3db
parent 43439 0a0bad6d7ac0
child 43441 d630c5710801
revlog: move tiprev() from changelog up to revlog This makes the changelog override simpler and it seems more consistent. Differential Revision: https://phab.mercurial-scm.org/D7250
mercurial/changelog.py
mercurial/revlog.py
--- a/mercurial/changelog.py	Tue Nov 05 18:25:13 2019 -0500
+++ b/mercurial/changelog.py	Tue Nov 05 14:42:08 2019 -0800
@@ -406,14 +406,11 @@
         self._copiesstorage = opener.options.get(b'copies-storage')
 
     def tiprev(self):
+        """filtered version of revlog.tiprev"""
         for i in pycompat.xrange(len(self) - 1, -2, -1):
             if i not in self.filteredrevs:
                 return i
 
-    def tip(self):
-        """filtered version of revlog.tip"""
-        return self.node(self.tiprev())
-
     def __contains__(self, rev):
         """filtered version of revlog.__contains__"""
         return 0 <= rev < len(self) and rev not in self.filteredrevs
--- a/mercurial/revlog.py	Tue Nov 05 18:25:13 2019 -0500
+++ b/mercurial/revlog.py	Tue Nov 05 14:42:08 2019 -0800
@@ -593,8 +593,11 @@
             with func() as fp:
                 yield fp
 
+    def tiprev(self):
+        return len(self.index) - 1
+
     def tip(self):
-        return self.node(len(self.index) - 1)
+        return self.node(self.tiprev())
 
     def __contains__(self, rev):
         return 0 <= rev < len(self)