changeset 41113:9815d3337f9b

discovery: move common heads computation inside partialdiscovery object This remove one of the private attribute access. In additions, head tracking and computation is a typical operation we can speed up using Rust.
author Boris Feld <boris.feld@octobus.net>
date Fri, 28 Dec 2018 03:28:02 +0100
parents 3023bc4b3da0
children b31a41f24864
files mercurial/setdiscovery.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/setdiscovery.py	Fri Dec 28 03:14:34 2018 +0100
+++ b/mercurial/setdiscovery.py	Fri Dec 28 03:28:02 2018 +0100
@@ -182,6 +182,13 @@
         """return True is we have any clue about the remote state"""
         return self._common.hasbases()
 
+    def commonheads(self):
+        """the heads of the known common set"""
+        # heads(common) == heads(common.bases) since common represents
+        # common.bases and all its ancestors
+        # The presence of nullrev will confuse heads(). So filter it out.
+        return set(self._repo.revs('heads(%ld)',
+                   self._common.bases - {nullrev}))
 
 def findcommonheads(ui, local, remote,
                     initialsamplesize=100,
@@ -311,10 +318,7 @@
             disco.addcommons(commoninsample)
             disco._common.removeancestorsfrom(undecided)
 
-    # heads(common) == heads(common.bases) since common represents common.bases
-    # and all its ancestors
-    # The presence of nullrev will confuse heads(). So filter it out.
-    result = set(local.revs('heads(%ld)', disco._common.bases - {nullrev}))
+    result = disco.commonheads()
     elapsed = util.timer() - start
     progress.complete()
     ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed))