# HG changeset patch # User Pierre-Yves David # Date 2015-10-05 07:23:20 # Node ID 1e8e0b01faba14e905d18b8dfc737125007e9e34 # Parent a018cbabdb51f5a1cdb200d676c681e8eefd8522 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 diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -455,7 +455,19 @@ def getremotechanges(ui, repo, other, on 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'): diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t --- a/tests/test-setdiscovery.t +++ b/tests/test-setdiscovery.t @@ -350,7 +350,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 + "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