Mercurial > hg
comparison mercurial/exchange.py @ 37168:a2b350d9f6ae
bundlespec: add support for some variants
This way the stream v2 bundle spec can disable the changegroup part while
enabling the stream v2 part.
Differential Revision: https://phab.mercurial-scm.org/D1955
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 31 Jan 2018 11:10:55 +0100 |
parents | 6f467adf9f05 |
children | b837655c1509 |
comparison
equal
deleted
inserted
replaced
37167:6f467adf9f05 | 37168:a2b350d9f6ae |
---|---|
74 'cg.version': 's1' | 74 'cg.version': 's1' |
75 } | 75 } |
76 } | 76 } |
77 _bundlespeccontentopts['bundle2'] = _bundlespeccontentopts['v2'] | 77 _bundlespeccontentopts['bundle2'] = _bundlespeccontentopts['v2'] |
78 | 78 |
79 _bundlespecvariants = {"streamv2": {"changegroup": False, "streamv2": True, | |
80 "tagsfnodescache": False, | |
81 "revbranchcache": False}} | |
82 | |
79 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. | 83 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. |
80 _bundlespecv1compengines = {'gzip', 'bzip2', 'none'} | 84 _bundlespecv1compengines = {'gzip', 'bzip2', 'none'} |
81 | 85 |
82 @attr.s | 86 @attr.s |
83 class bundlespec(object): | 87 class bundlespec(object): |
204 ', '.join(sorted(missingreqs))) | 208 ', '.join(sorted(missingreqs))) |
205 | 209 |
206 # Compute contentopts based on the version | 210 # Compute contentopts based on the version |
207 contentopts = _bundlespeccontentopts.get(version, {}).copy() | 211 contentopts = _bundlespeccontentopts.get(version, {}).copy() |
208 | 212 |
213 # Process the variants | |
214 if "stream" in params and params["stream"] == "v2": | |
215 variant = _bundlespecvariants["streamv2"] | |
216 contentopts.update(variant) | |
217 | |
209 if not externalnames: | 218 if not externalnames: |
210 engine = util.compengines.forbundlename(compression) | 219 engine = util.compengines.forbundlename(compression) |
211 compression = engine.bundletype()[1] | 220 compression = engine.bundletype()[1] |
212 version = _bundlespeccgversions[version] | 221 version = _bundlespeccgversions[version] |
213 | 222 |
279 else: | 288 else: |
280 raise error.Abort(_('changegroup version %s does not have ' | 289 raise error.Abort(_('changegroup version %s does not have ' |
281 'a known bundlespec') % version, | 290 'a known bundlespec') % version, |
282 hint=_('try upgrading your Mercurial ' | 291 hint=_('try upgrading your Mercurial ' |
283 'client')) | 292 'client')) |
293 elif part.type == 'stream2' and version is None: | |
294 # A stream2 part requires to be part of a v2 bundle | |
295 version = "v2" | |
296 requirements = urlreq.unquote(part.params['requirements']) | |
297 splitted = requirements.split() | |
298 params = bundle2._formatrequirementsparams(splitted) | |
299 return 'none-v2;stream=v2;%s' % params | |
284 | 300 |
285 if not version: | 301 if not version: |
286 raise error.Abort(_('could not identify changegroup version in ' | 302 raise error.Abort(_('could not identify changegroup version in ' |
287 'bundle')) | 303 'bundle')) |
288 | 304 |