Patchwork [2,of,2,stable] incoming: don't request heads that already are common

login
register
mail settings
Submitter Mads Kiilerich
Date Aug. 15, 2014, 1:25 a.m.
Message ID <508100176a0ee38a4dcd.1408065928@mk-desktop>
Download mbox | patch
Permalink /patch/5407/
State Accepted
Headers show

Comments

Mads Kiilerich - Aug. 15, 2014, 1:25 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1408065880 -7200
#      Fri Aug 15 03:24:40 2014 +0200
# Branch stable
# Node ID 508100176a0ee38a4dcd1972bba4d5363ca0d4d7
# Parent  1075a3096d38c94366bbf7bcd4171f25e3e62172
incoming: don't request heads that already are common

Pull would send a getbundle command where common heads were sent both as common
and head, even though there is no reason to request a common head.
The request was thus twice as big as necessary and more likely to hit HTTP
header size limits.

Instead, don't request heads that already are common.

This is fixed in bundlerepo.getremotechanges . It could perhaps also have been
fixed in discovery.findcommonincoming but that would have a bigger impact.
Matt Mackall - Aug. 15, 2014, 3:16 a.m.
On Fri, 2014-08-15 at 03:25 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1408065880 -7200
> #      Fri Aug 15 03:24:40 2014 +0200
> # Branch stable
> # Node ID 508100176a0ee38a4dcd1972bba4d5363ca0d4d7
> # Parent  1075a3096d38c94366bbf7bcd4171f25e3e62172
> incoming: don't request heads that already are common

These are queued for stable, thanks.

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -357,6 +357,9 @@  def getremotechanges(ui, repo, other, on
             pass
         return repo, [], other.close
 
+    commonset = set(common)
+    rheads = [x for x in rheads if x not in commonset]
+
     bundle = None
     bundlerepo = None
     localrepo = other.local()
diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
--- a/tests/test-setdiscovery.t
+++ b/tests/test-setdiscovery.t
@@ -347,7 +347,7 @@  Test actual protocol when pulling one ne
   $ cut -d' ' -f6- access.log | grep -v cmd=known # cmd=known uses random sampling
   "GET /?cmd=capabilities HTTP/1.1" 200 -
   "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D513314ca8b3ae4dac8eec56966265b00fcf866db
-  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=513314ca8b3ae4dac8eec56966265b00fcf866db&heads=e64a39e7da8b0d54bc63e81169aff001c13b3477+513314ca8b3ae4dac8eec56966265b00fcf866db
+  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=513314ca8b3ae4dac8eec56966265b00fcf866db&heads=e64a39e7da8b0d54bc63e81169aff001c13b3477
   $ cat errors.log
 
   $ cd ..
diff --git a/tests/test-treediscovery.t b/tests/test-treediscovery.t
--- a/tests/test-treediscovery.t
+++ b/tests/test-treediscovery.t
@@ -508,7 +508,7 @@  Both have new stuff in existing named br
   "GET /?cmd=heads HTTP/1.1" 200 -
   "GET /?cmd=branches HTTP/1.1" 200 - x-hgarg-1:nodes=d8f638ac69e9ae8dea4f09f11d696546a912d961
   "GET /?cmd=between HTTP/1.1" 200 - x-hgarg-1:pairs=d8f638ac69e9ae8dea4f09f11d696546a912d961-d57206cc072a18317c1e381fb60aa31bd3401785
-  "GET /?cmd=changegroupsubset HTTP/1.1" 200 - x-hgarg-1:bases=d8f638ac69e9ae8dea4f09f11d696546a912d961&heads=d8f638ac69e9ae8dea4f09f11d696546a912d961+2c8d5d5ec612be65cdfdeac78b7662ab1696324a
+  "GET /?cmd=changegroupsubset HTTP/1.1" 200 - x-hgarg-1:bases=d8f638ac69e9ae8dea4f09f11d696546a912d961&heads=d8f638ac69e9ae8dea4f09f11d696546a912d961
   "GET /?cmd=capabilities HTTP/1.1" 200 -
   "GET /?cmd=heads HTTP/1.1" 200 -
   "GET /?cmd=branches HTTP/1.1" 200 - x-hgarg-1:nodes=d8f638ac69e9ae8dea4f09f11d696546a912d961