Patchwork D5632: setdiscovery: pass srvheads into partialdiscovery constructor

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2019, 6:20 p.m.
Message ID <differential-rev-PHID-DREV-tc54wev4xrvjvsamghlk-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/37879/
State New
Headers show

Comments

phabricator - Jan. 18, 2019, 6:20 p.m.
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




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 25, 2019, 7:01 p.m.
martinvonz planned changes to this revision.
martinvonz added a comment.


  This needs updating since it conflicts with changes made on the stable branch.

REPOSITORY
  rHG Mercurial

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

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

Patch

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