Patchwork D1962: setdiscovery: don't call "heads" wire command when heads specified

login
register
mail settings
Submitter phabricator
Date Feb. 1, 2018, 8:48 p.m.
Message ID <9fc3b08c8d0a92806303da07d0d38e44@localhost.localdomain>
Download mbox | patch
Permalink /patch/27147/
State Not Applicable
Headers show

Comments

phabricator - Feb. 1, 2018, 8:48 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG98b746a1ebe3: setdiscovery: don&#039;t call &quot;heads&quot; wire command when heads specified (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1962?vs=5036&id=5078

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

AFFECTED FILES
  mercurial/discovery.py
  mercurial/setdiscovery.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -130,7 +130,7 @@ 
         sample = set(random.sample(sample, desiredlen))
     return sample
 
-def findcommonheads(ui, local, remote,
+def findcommonheads(ui, local, remote, heads=None,
                     initialsamplesize=100,
                     fullsamplesize=200,
                     abortwhenunrelated=True,
@@ -155,11 +155,15 @@ 
     sample = _limitsample(ownheads, initialsamplesize)
     # indices between sample and externalized version must match
     sample = list(sample)
-    batch = remote.iterbatch()
-    batch.heads()
-    batch.known(dag.externalizeall(sample))
-    batch.submit()
-    srvheadhashes, yesno = batch.results()
+    if heads:
+        srvheadhashes = heads
+        yesno = remote.known(dag.externalizeall(sample))
+    else:
+        batch = remote.iterbatch()
+        batch.heads()
+        batch.known(dag.externalizeall(sample))
+        batch.submit()
+        srvheadhashes, yesno = batch.results()
 
     if cl.tip() == nullid:
         if srvheadhashes != [nullid]:
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -62,7 +62,7 @@ 
         if allknown:
             return (heads, False, heads)
 
-    res = setdiscovery.findcommonheads(repo.ui, repo, remote,
+    res = setdiscovery.findcommonheads(repo.ui, repo, remote, heads,
                                        abortwhenunrelated=not force,
                                        ancestorsof=ancestorsof)
     common, anyinc, srvheads = res