changeset 26544:1e8e0b01faba

incoming: request a bundle2 when possible (BC) Incoming was using bundle1 in all cases, as bundle1 is restricted to changegroup1 and does not support general delta, this can lead to significant CPU overhead if the server is using general delta storage. We now properly request and store a bundle2 to disk. If the server include any output or error in the bundle, they will be stored on disk and replayed when the bundle is read. As 'hg incoming' is going to read the bundle right away, we call that 'good' enough and go back to the bigger plan of having general delta on by default. This was tracked as 4864
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 05 Oct 2015 00:23:20 -0700
parents a018cbabdb51
children e99c3846d78a
files mercurial/bundlerepo.py tests/test-setdiscovery.t
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundlerepo.py	Mon Oct 05 00:18:11 2015 -0700
+++ b/mercurial/bundlerepo.py	Mon Oct 05 00:23:20 2015 -0700
@@ -455,7 +455,19 @@
     if bundlename or not localrepo:
         # create a bundle (uncompressed if other repo is not local)
 
-        if True:
+        canbundle2 = (ui.configbool('experimental', 'bundle2-exp', True)
+                      and other.capable('getbundle')
+                      and other.capable('bundle2'))
+        if canbundle2:
+            kwargs = {}
+            kwargs['common'] = common
+            kwargs['heads'] = rheads
+            kwargs['bundlecaps'] = exchange.caps20to10(repo)
+            kwargs['cg'] = True
+            b2 = other.getbundle('incoming', **kwargs)
+            fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(),
+                                                     bundlename)
+        else:
             if other.capable('getbundle'):
                 cg = other.getbundle('incoming', common=common, heads=rheads)
             elif onlyheads is None and not other.capable('changegroupsubset'):
--- a/tests/test-setdiscovery.t	Mon Oct 05 00:18:11 2015 -0700
+++ b/tests/test-setdiscovery.t	Mon Oct 05 00:23:20 2015 -0700
@@ -350,7 +350,7 @@
   $ 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
+  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=513314ca8b3ae4dac8eec56966265b00fcf866db&heads=e64a39e7da8b0d54bc63e81169aff001c13b3477
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
   $ cat errors.log