Patchwork [6,of,8] discovery: add a `iscomplete` method to the `partialdiscovery` object

login
register
mail settings
Submitter Boris Feld
Date Dec. 31, 2018, 5:35 p.m.
Message ID <b1294a6cb1b4c1d30ef9.1546277753@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/37410/
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 1545964783 -3600
#      Fri Dec 28 03:39:43 2018 +0100
# Node ID b1294a6cb1b4c1d30ef9840bf023b95337603158
# Parent  53455b1ab93ea86f6c7ad1b57716f44753447ab4
# EXP-Topic discovery-refactor
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b1294a6cb1b4
discovery: add a `iscomplete` method to the `partialdiscovery` object

The method is used by higher level logic to know if the initial discovery
question has been answered.

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -187,6 +187,10 @@  class partialdiscovery(object):
         """return True is we have any clue about the remote state"""
         return self._common.hasbases()
 
+    def iscomplete(self):
+        """True is all the necessary data have been gathered"""
+        return self._undecided is not None and not self._undecided
+
     @property
     def undecided(self):
         if self._undecided is not None:
@@ -276,7 +280,7 @@  def findcommonheads(ui, local, remote,
 
     full = False
     progress = ui.makeprogress(_('searching'), unit=_('queries'))
-    while disco.undecided:
+    while not disco.iscomplete():
 
         if sample:
             missinginsample = [n for i, n in enumerate(sample) if not yesno[i]]
@@ -289,7 +293,7 @@  def findcommonheads(ui, local, remote,
 
             disco.undecided.difference_update(missing)
 
-        if not disco.undecided:
+        if disco.iscomplete():
             break
 
         if full or disco.hasinfo():