changeset 39801:979e9f124caa

filelog: stop proxying headrevs() (API) The previous commit removed the last user of this method. It is redundant with heads() and adds little to no value other than convenience. Let's nuke it. Differential Revision: https://phab.mercurial-scm.org/D4663
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 18 Sep 2018 19:26:44 -0700
parents be0f32ca2671
children d50125dec2c1
files mercurial/filelog.py mercurial/repository.py mercurial/testing/storage.py tests/simplestorerepo.py
diffstat 4 files changed, 2 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filelog.py	Tue Sep 18 19:00:17 2018 -0700
+++ b/mercurial/filelog.py	Tue Sep 18 19:26:44 2018 -0700
@@ -70,10 +70,6 @@
     def descendants(self, revs):
         return self._revlog.descendants(revs)
 
-    # Used by hgweb.
-    def headrevs(self):
-        return self._revlog.headrevs()
-
     def heads(self, start=None, stop=None):
         return self._revlog.heads(start, stop)
 
--- a/mercurial/repository.py	Tue Sep 18 19:00:17 2018 -0700
+++ b/mercurial/repository.py	Tue Sep 18 19:26:44 2018 -0700
@@ -525,14 +525,6 @@
         If ``nullrev`` is in the set, this is equivalent to ``revs()``.
         """
 
-    def headrevs():
-        """Obtain a list of revision numbers that are DAG heads.
-
-        The list is sorted oldest to newest.
-
-        TODO determine if sorting is required.
-        """
-
     def heads(start=None, stop=None):
         """Obtain a list of nodes that are DAG heads, with control.
 
--- a/mercurial/testing/storage.py	Tue Sep 18 19:00:17 2018 -0700
+++ b/mercurial/testing/storage.py	Tue Sep 18 19:26:44 2018 -0700
@@ -130,7 +130,6 @@
 
         self.assertEqual(list(f.descendants([nullrev])), [])
 
-        self.assertEqual(f.headrevs(), [nullrev])
         self.assertEqual(f.heads(), [nullid])
         self.assertEqual(f.heads(nullid), [nullid])
         self.assertEqual(f.heads(None, [nullid]), [nullid])
@@ -215,8 +214,6 @@
 
         self.assertEqual(list(f.descendants([0])), [])
 
-        self.assertEqual(f.headrevs(), [0])
-
         self.assertEqual(f.heads(), [node])
         self.assertEqual(f.heads(node), [node])
         self.assertEqual(f.heads(stop=[node]), [node])
@@ -327,8 +324,6 @@
         self.assertEqual(list(f.descendants([1])), [2])
         self.assertEqual(list(f.descendants([0, 1])), [1, 2])
 
-        self.assertEqual(f.headrevs(), [2])
-
         self.assertEqual(f.heads(), [node2])
         self.assertEqual(f.heads(node0), [node2])
         self.assertEqual(f.heads(node1), [node2])
@@ -372,8 +367,6 @@
         self.assertEqual(list(f.descendants([0, 1])), [1, 2, 3, 4, 5])
         self.assertEqual(list(f.descendants([1, 3])), [2, 4])
 
-        self.assertEqual(f.headrevs(), [2, 4, 5])
-
         self.assertEqual(f.heads(), [node2, node4, node5])
         self.assertEqual(f.heads(node0), [node2, node4, node5])
         self.assertEqual(f.heads(node1), [node2])
--- a/tests/simplestorerepo.py	Tue Sep 18 19:00:17 2018 -0700
+++ b/tests/simplestorerepo.py	Tue Sep 18 19:26:44 2018 -0700
@@ -564,18 +564,6 @@
                 revision=revision,
                 delta=delta)
 
-    def headrevs(self):
-        # Assume all revisions are heads by default.
-        revishead = {rev: True for rev in self._indexbyrev}
-
-        for rev, entry in self._indexbyrev.items():
-            # Unset head flag for all seen parents.
-            revishead[self.rev(entry[b'p1'])] = False
-            revishead[self.rev(entry[b'p2'])] = False
-
-        return [rev for rev, ishead in sorted(revishead.items())
-                if ishead]
-
     def heads(self, start=None, stop=None):
         # This is copied from revlog.py.
         if start is None and stop is None:
@@ -628,8 +616,8 @@
 
         heads = {}
         futurelargelinkrevs = set()
-        for head in self.headrevs():
-            headlinkrev = self.linkrev(head)
+        for head in self.heads():
+            headlinkrev = self.linkrev(self.rev(head))
             heads[head] = headlinkrev
             if headlinkrev >= minlink:
                 futurelargelinkrevs.add(headlinkrev)