Mercurial > public > mercurial-scm > hg
comparison mercurial/exchange.py @ 31473:ffed3bf5cd4c stable
exchange: reject new compression engines for v1 bundles (issue5506)
Version 1 bundles only support a fixed set of compression engines.
Before this change, we would accept any compression engine for v1
bundles, even those that may not work on v1. This could lead to
an error.
We define a fixed set of compression engines known to work with v1
bundles and we add checking to ensure a newer engine (like zstd)
won't work with v1 bundles.
I also took the liberty of adding test coverage for unknown compression
names because I noticed we didn't have coverage of it before.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 16 Mar 2017 12:23:56 -0700 |
parents | d70971a3ae80 |
children | 10c0ee338535 |
comparison
equal
deleted
inserted
replaced
31277:86cd1f2cfff5 | 31473:ffed3bf5cd4c |
---|---|
42 'v2': '02', | 42 'v2': '02', |
43 'packed1': 's1', | 43 'packed1': 's1', |
44 'bundle2': '02', #legacy | 44 'bundle2': '02', #legacy |
45 } | 45 } |
46 | 46 |
47 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. | |
48 _bundlespecv1compengines = set(['gzip', 'bzip2', 'none']) | |
49 | |
47 def parsebundlespec(repo, spec, strict=True, externalnames=False): | 50 def parsebundlespec(repo, spec, strict=True, externalnames=False): |
48 """Parse a bundle string specification into parts. | 51 """Parse a bundle string specification into parts. |
49 | 52 |
50 Bundle specifications denote a well-defined bundle/exchange format. | 53 Bundle specifications denote a well-defined bundle/exchange format. |
51 The content of a given specification should not change over time in | 54 The content of a given specification should not change over time in |
136 compression = 'bzip2' | 139 compression = 'bzip2' |
137 version = spec | 140 version = spec |
138 else: | 141 else: |
139 raise error.UnsupportedBundleSpecification( | 142 raise error.UnsupportedBundleSpecification( |
140 _('%s is not a recognized bundle specification') % spec) | 143 _('%s is not a recognized bundle specification') % spec) |
144 | |
145 # Bundle version 1 only supports a known set of compression engines. | |
146 if version == 'v1' and compression not in _bundlespecv1compengines: | |
147 raise error.UnsupportedBundleSpecification( | |
148 _('compression engine %s is not supported on v1 bundles') % | |
149 compression) | |
141 | 150 |
142 # The specification for packed1 can optionally declare the data formats | 151 # The specification for packed1 can optionally declare the data formats |
143 # required to apply it. If we see this metadata, compare against what the | 152 # required to apply it. If we see this metadata, compare against what the |
144 # repo supports and error if the bundle isn't compatible. | 153 # repo supports and error if the bundle isn't compatible. |
145 if version == 'packed1' and 'requirements' in params: | 154 if version == 'packed1' and 'requirements' in params: |