# HG changeset patch # User Pierre-Yves David # Date 1428447692 25200 # Node ID 2d15c59a001b53c5c55651381fac389075406ca3 # Parent 5cac3accdaa139a1e9b9e20bd876534ed526cdc8 bundle2: detect bundle2 stream/request on /HG2./ instead of /HG2Y/ To support more bundle2 formats, we need a wider detection of bundle2-family streams. The various places what were explicitly detecting the full magic string are now matching on the first three characters of it. diff -r 5cac3accdaa1 -r 2d15c59a001b mercurial/exchange.py --- a/mercurial/exchange.py Mon Apr 06 17:23:11 2015 -0700 +++ b/mercurial/exchange.py Tue Apr 07 16:01:32 2015 -0700 @@ -32,7 +32,7 @@ if alg is None: alg = changegroup.readexactly(fh, 2) return changegroup.cg1unpacker(fh, alg) - elif version == '2Y': + elif version.startswith('2'): return bundle2.getunbundler(ui, fh, header=magic + version) else: raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) @@ -1168,7 +1168,10 @@ when the API of bundle is refined. """ # bundle10 case - if bundlecaps is None or 'HG2Y' not in bundlecaps: + usebundle2 = False + if bundlecaps is not None: + usebundle2 = util.any((cap.startswith('HG2') for cap in bundlecaps)) + if not usebundle2: if bundlecaps and not kwargs.get('cg', True): raise ValueError(_('request for bundle10 must include changegroup')) diff -r 5cac3accdaa1 -r 2d15c59a001b mercurial/wireproto.py --- a/mercurial/wireproto.py Mon Apr 06 17:23:11 2015 -0700 +++ b/mercurial/wireproto.py Tue Apr 07 16:01:32 2015 -0700 @@ -363,7 +363,9 @@ opts[key] = value f = self._callcompressable("getbundle", **opts) bundlecaps = kwargs.get('bundlecaps') - if bundlecaps is not None and 'HG2Y' in bundlecaps: + if bundlecaps is None: + bundlecaps = () # kwargs could have it to None + if util.any((cap.startswith('HG2') for cap in bundlecaps)): return bundle2.getunbundler(self.ui, f) else: return changegroupmod.cg1unpacker(f, 'UN')