comparison mercurial/exchange.py @ 24649:2d15c59a001b

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 07 Apr 2015 16:01:32 -0700
parents 60fecc5b14a4
children b83a8f512a80
comparison
equal deleted inserted replaced
24648:5cac3accdaa1 24649:2d15c59a001b
30 raise util.Abort(_('%s: not a Mercurial bundle') % fname) 30 raise util.Abort(_('%s: not a Mercurial bundle') % fname)
31 if version == '10': 31 if version == '10':
32 if alg is None: 32 if alg is None:
33 alg = changegroup.readexactly(fh, 2) 33 alg = changegroup.readexactly(fh, 2)
34 return changegroup.cg1unpacker(fh, alg) 34 return changegroup.cg1unpacker(fh, alg)
35 elif version == '2Y': 35 elif version.startswith('2'):
36 return bundle2.getunbundler(ui, fh, header=magic + version) 36 return bundle2.getunbundler(ui, fh, header=magic + version)
37 else: 37 else:
38 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) 38 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
39 39
40 def buildobsmarkerspart(bundler, markers): 40 def buildobsmarkerspart(bundler, markers):
1166 1166
1167 The implementation is at a very early stage and will get massive rework 1167 The implementation is at a very early stage and will get massive rework
1168 when the API of bundle is refined. 1168 when the API of bundle is refined.
1169 """ 1169 """
1170 # bundle10 case 1170 # bundle10 case
1171 if bundlecaps is None or 'HG2Y' not in bundlecaps: 1171 usebundle2 = False
1172 if bundlecaps is not None:
1173 usebundle2 = util.any((cap.startswith('HG2') for cap in bundlecaps))
1174 if not usebundle2:
1172 if bundlecaps and not kwargs.get('cg', True): 1175 if bundlecaps and not kwargs.get('cg', True):
1173 raise ValueError(_('request for bundle10 must include changegroup')) 1176 raise ValueError(_('request for bundle10 must include changegroup'))
1174 1177
1175 if kwargs: 1178 if kwargs:
1176 raise ValueError(_('unsupported getbundle arguments: %s') 1179 raise ValueError(_('unsupported getbundle arguments: %s')