Patchwork [3,of,3,batching] discovery: always use batching now that all peers support batching

login
register
mail settings
Submitter Augie Fackler
Date Aug. 5, 2015, 7:29 p.m.
Message ID <ca283e051f24bb2c8e4d.1438802998@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/10110/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 5, 2015, 7:29 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1438798906 14400
#      Wed Aug 05 14:21:46 2015 -0400
# Node ID ca283e051f24bb2c8e4d9840febad0c7f0f59d62
# Parent  88593e1112f0eb4cc4f2b35258cf2b9ad02ac4e0
discovery: always use batching now that all peers support batching

Some peers will transparently downgrade batched requests to
non-batched ones, but that simplifies code for everyone using
batching.
Pierre-Yves David - Aug. 6, 2015, 10:22 p.m.
On 08/05/2015 12:29 PM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1438798906 14400
> #      Wed Aug 05 14:21:46 2015 -0400
> # Node ID ca283e051f24bb2c8e4d9840febad0c7f0f59d62
> # Parent  88593e1112f0eb4cc4f2b35258cf2b9ad02ac4e0
> discovery: always use batching now that all peers support batching

These are pushed to the clowncopter. Thanks.

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -138,22 +138,12 @@  def findcommonheads(ui, local, remote,
     sample = _limitsample(ownheads, initialsamplesize)
     # indices between sample and externalized version must match
     sample = list(sample)
-    if remote.local():
-        # stopgap until we have a proper localpeer that supports batch()
-        srvheadhashes = remote.heads()
-        yesno = remote.known(dag.externalizeall(sample))
-    elif remote.capable('batch'):
-        batch = remote.batch()
-        srvheadhashesref = batch.heads()
-        yesnoref = batch.known(dag.externalizeall(sample))
-        batch.submit()
-        srvheadhashes = srvheadhashesref.value
-        yesno = yesnoref.value
-    else:
-        # compatibility with pre-batch, but post-known remotes during 1.9
-        # development
-        srvheadhashes = remote.heads()
-        sample = []
+    batch = remote.batch()
+    srvheadhashesref = batch.heads()
+    yesnoref = batch.known(dag.externalizeall(sample))
+    batch.submit()
+    srvheadhashes = srvheadhashesref.value
+    yesno = yesnoref.value
 
     if cl.tip() == nullid:
         if srvheadhashes != [nullid]: