Patchwork [3,of,8] discovery: move common heads computation inside partialdiscovery object

login
register
mail settings
Submitter Boris Feld
Date Dec. 31, 2018, 5:35 p.m.
Message ID <d4896a8672cb719ac2cf.1546277750@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/37406/
State Superseded
Headers show

Comments

Boris Feld - Dec. 31, 2018, 5:35 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1545964082 -3600
#      Fri Dec 28 03:28:02 2018 +0100
# Node ID d4896a8672cb719ac2cf43f1a7035a335e43665c
# Parent  db1f1838096a110cc4735aeaffac0e65bde37b50
# EXP-Topic discovery-refactor
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d4896a8672cb
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.

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -182,6 +182,10 @@  class partialdiscovery(object):
         """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"""
+        return set(self._repo.revs('heads(%ld)',
+                   self._common.bases - {nullrev}))
 
 def findcommonheads(ui, local, remote,
                     initialsamplesize=100,
@@ -314,7 +318,7 @@  def findcommonheads(ui, local, remote,
     # 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))