Patchwork [6,of,8,V2] getbundle: send highest changegroup format supported by both side

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 17, 2014, 7:56 p.m.
Message ID <6a9148c4306d43f56d2b.1413575790@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6391/
State Superseded
Commit 6bb9533fa8fad5238dd66124f7dcd2568c424d4c
Headers show

Comments

Pierre-Yves David - Oct. 17, 2014, 7:56 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413550750 -7200
#      Fri Oct 17 14:59:10 2014 +0200
# Node ID 6a9148c4306d43f56d2b607b7ff62f08637ca44e
# Parent  f71a2dedeb81b6194e2560313384e7d5c0bb1b2b
getbundle: send highest changegroup format supported by both side

When using bundle2, we find the common subset of supported changegroup-packers
and we pick the max of them. This allow to use generaldelta aware changegroup
through bundle2.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1177,11 +1177,15 @@  def _getbundlechangegrouppart(bundler, r
                               b2caps=None, heads=None, common=None, **kwargs):
     """add a changegroup part to the requested bundle"""
     cg = None
     if kwargs.get('cg', True):
         # build changegroup bundle here.
-        version = '1'
+        cgversions = b2caps.get('b2x:changegroup', ('1',))
+        cgversions = [v for v in cgversions if v in changegroup.packermap]
+        if not cgversions:
+            raise ValueError(_('no common changegroup version'))
+        version = max(cgversions)
         cg = changegroup.getchangegroupraw(repo, source, heads=heads,
                                            common=common, bundlecaps=bundlecaps,
                                            version=version)
 
     if cg: