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

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Feb 1 15:48:48 EST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG98b746a1ebe3: setdiscovery: don't call "heads" 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

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



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


More information about the Mercurial-devel mailing list