# HG changeset patch # User Pierre-Yves David # Date 2015-04-07 23:01:32 # 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 --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -32,7 +32,7 @@ def readbundle(ui, fh, fname, vfs=None): 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 @@ def getbundle(repo, source, heads=None, 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 --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -363,7 +363,9 @@ class wirepeer(peer.peerrepository): 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')