Patchwork D7250: revlog: move tiprev() from changelog up to revlog

login
register
mail settings
Submitter phabricator
Date Nov. 6, 2019, 1:02 a.m.
Message ID <differential-rev-PHID-DREV-jaki7emnpfwhsdcl3ahi-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42776/
State Superseded
Headers show

Comments

phabricator - Nov. 6, 2019, 1:02 a.m.
martinvonz created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This makes the changelog override simpler and it seems more
  consistent.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changelog.py
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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)
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -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