comparison mercurial/exchange.py @ 26756:9e272a96f764

exchange: support for streaming clone bundles Now that we have a mechanism to produce and consume streaming clone bundles, we need to teach the human-facing bundle specification parser and the internal bundle file header reading code to be aware of this new format. This patch does so. For the human-facing bundle specification, we choose the name "packed" to describe "streaming clone bundles" because the bundle is essentially a "pack" of raw revlog files that are "packed" together. There should probably be a bikeshed over the name, especially since it is human facing.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 15 Oct 2015 13:00:45 -0700
parents 69ac9aebbc55
children c0f475ac997e
comparison
equal deleted inserted replaced
26755:bb0b955d050d 26756:9e272a96f764
23 } 23 }
24 24
25 # Maps bundle version human names to changegroup versions. 25 # Maps bundle version human names to changegroup versions.
26 _bundlespeccgversions = {'v1': '01', 26 _bundlespeccgversions = {'v1': '01',
27 'v2': '02', 27 'v2': '02',
28 'packed1': 's1',
28 'bundle2': '02', #legacy 29 'bundle2': '02', #legacy
29 } 30 }
30 31
31 def parsebundlespec(repo, spec, strict=True, externalnames=False): 32 def parsebundlespec(repo, spec, strict=True, externalnames=False):
32 """Parse a bundle string specification into parts. 33 """Parse a bundle string specification into parts.
85 compression = spec 86 compression = spec
86 version = 'v1' 87 version = 'v1'
87 if 'generaldelta' in repo.requirements: 88 if 'generaldelta' in repo.requirements:
88 version = 'v2' 89 version = 'v2'
89 elif spec in _bundlespeccgversions: 90 elif spec in _bundlespeccgversions:
90 compression = 'bzip2' 91 if spec == 'packed1':
92 compression = 'none'
93 else:
94 compression = 'bzip2'
91 version = spec 95 version = spec
92 else: 96 else:
93 raise error.UnsupportedBundleSpecification( 97 raise error.UnsupportedBundleSpecification(
94 _('%s is not a recognized bundle specification') % spec) 98 _('%s is not a recognized bundle specification') % spec)
95 99
119 if alg is None: 123 if alg is None:
120 alg = changegroup.readexactly(fh, 2) 124 alg = changegroup.readexactly(fh, 2)
121 return changegroup.cg1unpacker(fh, alg) 125 return changegroup.cg1unpacker(fh, alg)
122 elif version.startswith('2'): 126 elif version.startswith('2'):
123 return bundle2.getunbundler(ui, fh, magicstring=magic + version) 127 return bundle2.getunbundler(ui, fh, magicstring=magic + version)
128 elif version == 'S1':
129 return streamclone.streamcloneapplier(fh)
124 else: 130 else:
125 raise error.Abort(_('%s: unknown bundle version %s') % (fname, version)) 131 raise error.Abort(_('%s: unknown bundle version %s') % (fname, version))
126 132
127 def buildobsmarkerspart(bundler, markers): 133 def buildobsmarkerspart(bundler, markers):
128 """add an obsmarker part to the bundler with <markers> 134 """add an obsmarker part to the bundler with <markers>