D5632: setdiscovery: pass srvheads into partialdiscovery constructor

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Jan 18 18:20:37 UTC 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I found it hard to follow how disco._undecided was initialized (the
  call to disco.addbases(srvheads) caused the disco.undecided property
  to be access, which initialized disco._undecided). I think this patch
  makes it easier.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5632

AFFECTED FILES
  mercurial/setdiscovery.py

CHANGE DETAILS

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -173,11 +173,11 @@
     (all tracked revisions are known locally)
     """
 
-    def __init__(self, repo, targetheads):
+    def __init__(self, repo, targetheads, srvheads):
         self._repo = repo
         self._targetheads = targetheads
-        self._common = repo.changelog.incrementalmissingrevs()
-        self._undecided = None
+        self._common = repo.changelog.incrementalmissingrevs(srvheads)
+        self.undecided = set(self._common.missingancestors(self._targetheads))
         self.missing = set()
 
     def addcommons(self, commons):
@@ -212,14 +212,7 @@
 
     def iscomplete(self):
         """True if 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:
-            return self._undecided
-        self._undecided = set(self._common.missingancestors(self._targetheads))
-        return self._undecided
+        return not self.undecided
 
     def commonheads(self):
         """the heads of the known common set"""
@@ -293,10 +286,9 @@
 
     # full blown discovery
 
-    disco = partialdiscovery(local, ownheads)
     # treat remote heads (and maybe own heads) as a first implicit sample
     # response
-    disco.addcommons(srvheads)
+    disco = partialdiscovery(local, ownheads, srvheads)
     disco.addinfo(zip(sample, yesno))
 
     full = False



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list