Patchwork [08,of,10,V3] discovery: move missing tracking inside the partialdiscovery object

login
register
mail settings
Submitter Boris Feld
Date Jan. 4, 2019, 10:45 p.m.
Message ID <0665d9a3f120a37f5c87.1546641927@localhost.localdomain>
Download mbox | patch
Permalink /patch/37476/
State Accepted
Headers show

Comments

Boris Feld - Jan. 4, 2019, 10:45 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1545965280 -3600
#      Fri Dec 28 03:48:00 2018 +0100
# Node ID 0665d9a3f120a37f5c8755f465eae7d8d51ead15
# Parent  337d8bcf6807c2e0c21771851fe960218c1a9fd2
# EXP-Topic discovery-refactor
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0665d9a3f120
discovery: move missing tracking inside the partialdiscovery object

This is the final set that we need to track to have a fully up to date
information within the object.

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -169,6 +169,7 @@  class partialdiscovery(object):
 
     - common:    own nodes I know we both know
     - undecided: own nodes where I don't know if remote knows them
+    - missing:   own nodes I know remote lacks
     """
 
     def __init__(self, repo, targetheads):
@@ -176,12 +177,24 @@  class partialdiscovery(object):
         self._targetheads = targetheads
         self._common = repo.changelog.incrementalmissingrevs()
         self._undecided = None
+        self.missing = set()
 
     def addcommons(self, commons):
         """registrer nodes known as common"""
         self._common.addbases(commons)
         self._common.removeancestorsfrom(self.undecided)
 
+    def addmissings(self, missings):
+        """registrer some nodes as missing"""
+        if self.missing:
+            new = self._repo.revs('descendants(%ld) - descendants(%ld)',
+                                  missings, self.missing)
+            self.missing.update(new)
+        else:
+            self.missing.update(self._repo.revs('descendants(%ld)', missings))
+
+        self.undecided.difference_update(self.missing)
+
     def hasinfo(self):
         """return True is we have any clue about the remote state"""
         return self._common.hasbases()
@@ -274,8 +287,6 @@  def findcommonheads(ui, local, remote,
     disco.addcommons(srvheads)
     commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
     disco.addcommons(commoninsample)
-    # own nodes I know remote lacks
-    missing = set()
 
     full = False
     progress = ui.makeprogress(_('searching'), unit=_('queries'))
@@ -283,14 +294,8 @@  def findcommonheads(ui, local, remote,
 
         if sample:
             missinginsample = [n for i, n in enumerate(sample) if not yesno[i]]
+            disco.addmissings(missinginsample)
 
-            if missing:
-                missing.update(local.revs('descendants(%ld) - descendants(%ld)',
-                                          missinginsample, missing))
-            else:
-                missing.update(local.revs('descendants(%ld)', missinginsample))
-
-            disco.undecided.difference_update(missing)
 
         if disco.iscomplete():
             break