Patchwork [07,of,10,V3] discovery: add a `iscomplete` method to the `partialdiscovery` object

login
register
mail settings
Submitter Boris Feld
Date Jan. 4, 2019, 10:45 p.m.
Message ID <337d8bcf6807c2e0c217.1546641926@localhost.localdomain>
Download mbox | patch
Permalink /patch/37475/
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 1545964783 -3600
#      Fri Dec 28 03:39:43 2018 +0100
# Node ID 337d8bcf6807c2e0c21771851fe960218c1a9fd2
# Parent  b9f78a736cf666a008de914ab30ff84c4a9c973e
# EXP-Topic discovery-refactor
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 337d8bcf6807
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.
Yuya Nishihara - Jan. 10, 2019, 11:59 a.m.
On Fri, 04 Jan 2019 23:45:26 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1545964783 -3600
> #      Fri Dec 28 03:39:43 2018 +0100
> # Node ID 337d8bcf6807c2e0c21771851fe960218c1a9fd2
> # Parent  b9f78a736cf666a008de914ab30ff84c4a9c973e
> # EXP-Topic discovery-refactor
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 337d8bcf6807
> discovery: add a `iscomplete` method to the `partialdiscovery` object

Queued the remainder patches, thanks.

> +    def iscomplete(self):
> +        """True is all the necessary data have been gathered"""

s/True is/True if/. Fixed in flight.

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -186,6 +186,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:
@@ -275,7 +279,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]]
@@ -288,7 +292,7 @@  def findcommonheads(ui, local, remote,
 
             disco.undecided.difference_update(missing)
 
-        if not disco.undecided:
+        if disco.iscomplete():
             break
 
         if full or disco.hasinfo():