Mercurial > hg
comparison mercurial/bundlecaches.py @ 49322:d587f09cad98
bundlespec: make the `stream` case less special
The handling of the stream case seems fragile (does not account for newer parts
and options that will arise) and has special code dedicated to it.
To simplify and strengthen things, we make it use the same mechanism as the other
options. So we make it less special by making it a special value in the common case.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 17 May 2022 14:25:53 +0100 |
parents | c12c843f0db7 |
children | bf66f7a1e3f8 |
comparison
equal
deleted
inserted
replaced
49321:c12c843f0db7 | 49322:d587f09cad98 |
---|---|
54 b'obsolescence': False, | 54 b'obsolescence': False, |
55 b'phases': False, | 55 b'phases': False, |
56 b'tagsfnodescache': True, | 56 b'tagsfnodescache': True, |
57 b'revbranchcache': True, | 57 b'revbranchcache': True, |
58 }, | 58 }, |
59 b'streamv2': { | |
60 b'changegroup': False, | |
61 b'cg.version': b'02', | |
62 b'obsolescence': False, | |
63 b'phases': False, | |
64 b"streamv2": True, | |
65 b'tagsfnodescache': False, | |
66 b'revbranchcache': False, | |
67 }, | |
59 b'packed1': { | 68 b'packed1': { |
60 b'cg.version': b's1', | 69 b'cg.version': b's1', |
61 }, | 70 }, |
62 b'bundle2': { # legacy | 71 b'bundle2': { # legacy |
63 b'cg.version': b'02', | 72 b'cg.version': b'02', |
64 }, | 73 }, |
65 } | 74 } |
66 _bundlespeccontentopts[b'bundle2'] = _bundlespeccontentopts[b'v2'] | 75 _bundlespeccontentopts[b'bundle2'] = _bundlespeccontentopts[b'v2'] |
67 | 76 |
68 _bundlespecvariants = { | 77 _bundlespecvariants = {b"streamv2": {}} |
69 b"streamv2": { | |
70 b"changegroup": False, | |
71 b"streamv2": True, | |
72 b"tagsfnodescache": False, | |
73 b"revbranchcache": False, | |
74 } | |
75 } | |
76 | 78 |
77 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. | 79 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. |
78 _bundlespecv1compengines = {b'gzip', b'bzip2', b'none'} | 80 _bundlespecv1compengines = {b'gzip', b'bzip2', b'none'} |
79 | 81 |
80 | 82 |
206 _(b'missing support for repository features: %s') | 208 _(b'missing support for repository features: %s') |
207 % b', '.join(sorted(missingreqs)) | 209 % b', '.join(sorted(missingreqs)) |
208 ) | 210 ) |
209 | 211 |
210 # Compute contentopts based on the version | 212 # Compute contentopts based on the version |
213 if b"stream" in params and params[b"stream"] == b"v2": | |
214 # That case is fishy as this mostly derails the version selection | |
215 # mechanism. `stream` bundles are quite specific and used differently | |
216 # as "normal" bundles. | |
217 # | |
218 # So we are pinning this to "v2", as this will likely be | |
219 # compatible forever. (see the next conditional). | |
220 # | |
221 # (we should probably define a cleaner way to do this and raise a | |
222 # warning when the old way is encounter) | |
223 version = b"streamv2" | |
211 contentopts = _bundlespeccontentopts.get(version, {}).copy() | 224 contentopts = _bundlespeccontentopts.get(version, {}).copy() |
212 | 225 if version == b"streamv2": |
213 # Process the variants | 226 # streamv2 have been reported as "v2" for a while. |
214 if b"stream" in params and params[b"stream"] == b"v2": | 227 version = b"v2" |
215 variant = _bundlespecvariants[b"streamv2"] | |
216 contentopts.update(variant) | |
217 | 228 |
218 engine = util.compengines.forbundlename(compression) | 229 engine = util.compengines.forbundlename(compression) |
219 compression, wirecompression = engine.bundletype() | 230 compression, wirecompression = engine.bundletype() |
220 wireversion = _bundlespeccontentopts[version][b'cg.version'] | 231 wireversion = _bundlespeccontentopts[version][b'cg.version'] |
221 | 232 |