diff --git a/mercurial/exchange.py b/mercurial/exchange.py index ad5dc89285..9667a6b0bc 100644 --- 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, common=None, bundlecaps=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 index 360f51f885..7e077e17ce 100644 --- 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')