discovery: move missing tracking inside the partialdiscovery object
authorBoris Feld <boris.feld@octobus.net>
Fri, 28 Dec 2018 03:48:00 +0100
changeset 41170 96201120cdf5
parent 41169 3ce5b96482c6
child 41171 f46ffd23dae8
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.
mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py	Fri Dec 28 03:39:43 2018 +0100
+++ b/mercurial/setdiscovery.py	Fri Dec 28 03:48:00 2018 +0100
@@ -169,6 +169,7 @@
 
     - 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 @@
         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()
@@ -277,8 +290,6 @@
     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'))
@@ -286,14 +297,8 @@
 
         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