comparison mercurial/exchange.py @ 37165:6c7a6b04b274

bundlespec: move computing the bundle contentops in parsebundlespec We will introduce a new bundlespec for stream bundle which will influence the contentops. Differential Revision: https://phab.mercurial-scm.org/D1952
author Boris Feld <boris.feld@octobus.net>
date Fri, 30 Mar 2018 12:43:57 +0200
parents b229fd9adeae
children 6f467adf9f05
comparison
equal deleted inserted replaced
37164:b229fd9adeae 37165:6c7a6b04b274
50 'v2': '02', 50 'v2': '02',
51 'packed1': 's1', 51 'packed1': 's1',
52 'bundle2': '02', #legacy 52 'bundle2': '02', #legacy
53 } 53 }
54 54
55 # Maps bundle version with content opts to choose which part to bundle
56 _bundlespeccontentopts = {
57 'v1': {
58 'changegroup': True,
59 'cg.version': '01',
60 'obsolescence': False,
61 'phases': False,
62 'tagsfnodescache': False,
63 'revbranchcache': False
64 },
65 'v2': {
66 'changegroup': True,
67 'cg.version': '02',
68 'obsolescence': False,
69 'phases': False,
70 'tagsfnodescache': True,
71 'revbranchcache': True
72 },
73 'packed1' : {
74 'cg.version': 's1'
75 }
76 }
77 _bundlespeccontentopts['bundle2'] = _bundlespeccontentopts['v2']
78
55 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. 79 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE.
56 _bundlespecv1compengines = {'gzip', 'bzip2', 'none'} 80 _bundlespecv1compengines = {'gzip', 'bzip2', 'none'}
57 81
58 @attr.s 82 @attr.s
59 class bundlespec(object): 83 class bundlespec(object):
60 compression = attr.ib() 84 compression = attr.ib()
61 version = attr.ib() 85 version = attr.ib()
62 params = attr.ib() 86 params = attr.ib()
87 contentopts = attr.ib()
63 88
64 def parsebundlespec(repo, spec, strict=True, externalnames=False): 89 def parsebundlespec(repo, spec, strict=True, externalnames=False):
65 """Parse a bundle string specification into parts. 90 """Parse a bundle string specification into parts.
66 91
67 Bundle specifications denote a well-defined bundle/exchange format. 92 Bundle specifications denote a well-defined bundle/exchange format.
176 if missingreqs: 201 if missingreqs:
177 raise error.UnsupportedBundleSpecification( 202 raise error.UnsupportedBundleSpecification(
178 _('missing support for repository features: %s') % 203 _('missing support for repository features: %s') %
179 ', '.join(sorted(missingreqs))) 204 ', '.join(sorted(missingreqs)))
180 205
206 # Compute contentopts based on the version
207 contentopts = _bundlespeccontentopts.get(version, {}).copy()
208
181 if not externalnames: 209 if not externalnames:
182 engine = util.compengines.forbundlename(compression) 210 engine = util.compengines.forbundlename(compression)
183 compression = engine.bundletype()[1] 211 compression = engine.bundletype()[1]
184 version = _bundlespeccgversions[version] 212 version = _bundlespeccgversions[version]
185 213
186 return bundlespec(compression, version, params) 214 return bundlespec(compression, version, params, contentopts)
187 215
188 def readbundle(ui, fh, fname, vfs=None): 216 def readbundle(ui, fh, fname, vfs=None):
189 header = changegroup.readexactly(fh, 4) 217 header = changegroup.readexactly(fh, 4)
190 218
191 alg = None 219 alg = None