mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
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.
This commit is contained in:
parent
f96ca2174a
commit
151c000fca
@ -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'))
|
||||
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user