##// END OF EJS Templates
bundlespec: move computing the bundle contentops in parsebundlespec...
Boris Feld -
r37182:6c7a6b04 default
parent child Browse files
Show More
@@ -340,9 +340,7 b' def extsetup(ui):'
340 340 # Make bundle choose changegroup3 instead of changegroup2. This affects
341 341 # "hg bundle" command. Note: it does not cover all bundle formats like
342 342 # "packed1". Using "packed1" with lfs will likely cause trouble.
343 names = [k for k, v in exchange._bundlespeccgversions.items() if v == '02']
344 for k in names:
345 exchange._bundlespeccgversions[k] = '03'
343 exchange._bundlespeccontentopts["v2"]["cg.version"] = "03"
346 344
347 345 # bundlerepo uses "vfsmod.readonlyvfs(othervfs)", we need to make sure lfs
348 346 # options and blob stores are passed from othervfs to the new readonlyvfs.
@@ -1596,8 +1596,11 b' def _addpartsfromopts(ui, repo, bundler,'
1596 1596 outgoing.missingheads):
1597 1597 part.addparam('targetphase', '%d' % phases.secret, mandatory=False)
1598 1598
1599 addparttagsfnodescache(repo, bundler, outgoing)
1600 addpartrevbranchcache(repo, bundler, outgoing)
1599 if opts.get('tagsfnodescache', True):
1600 addparttagsfnodescache(repo, bundler, outgoing)
1601
1602 if opts.get('revbranchcache', True):
1603 addpartrevbranchcache(repo, bundler, outgoing)
1601 1604
1602 1605 if opts.get('obsolescence', False):
1603 1606 obsmarkers = repo.obsstore.relevantmarkers(outgoing.missing)
@@ -1204,7 +1204,7 b' def bundle(ui, repo, fname, dest=None, *'
1204 1204 raise error.Abort(pycompat.bytestr(e),
1205 1205 hint=_("see 'hg help bundlespec' for supported "
1206 1206 "values for --type"))
1207 cgversion = bundlespec.version
1207 cgversion = bundlespec.contentopts["cg.version"]
1208 1208
1209 1209 # Packed bundles are a pseudo bundle format for now.
1210 1210 if cgversion == 's1':
@@ -1267,14 +1267,15 b' def bundle(ui, repo, fname, dest=None, *'
1267 1267 if complevel is not None:
1268 1268 compopts['level'] = complevel
1269 1269
1270
1271 contentopts = {'cg.version': cgversion, 'changegroup': True}
1270 # Allow overriding the bundling of obsmarker in phases through
1271 # configuration while we don't have a bundle version that include them
1272 1272 if repo.ui.configbool('experimental', 'evolution.bundle-obsmarker'):
1273 contentopts['obsolescence'] = True
1273 bundlespec.contentopts['obsolescence'] = True
1274 1274 if repo.ui.configbool('experimental', 'bundle-phases'):
1275 contentopts['phases'] = True
1275 bundlespec.contentopts['phases'] = True
1276
1276 1277 bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing,
1277 contentopts, compression=bcompression,
1278 bundlespec.contentopts, compression=bcompression,
1278 1279 compopts=compopts)
1279 1280
1280 1281 @command('cat',
@@ -52,6 +52,30 b' urlreq = util.urlreq'
52 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 79 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE.
56 80 _bundlespecv1compengines = {'gzip', 'bzip2', 'none'}
57 81
@@ -60,6 +84,7 b' class bundlespec(object):'
60 84 compression = attr.ib()
61 85 version = attr.ib()
62 86 params = attr.ib()
87 contentopts = attr.ib()
63 88
64 89 def parsebundlespec(repo, spec, strict=True, externalnames=False):
65 90 """Parse a bundle string specification into parts.
@@ -178,12 +203,15 b' def parsebundlespec(repo, spec, strict=T'
178 203 _('missing support for repository features: %s') %
179 204 ', '.join(sorted(missingreqs)))
180 205
206 # Compute contentopts based on the version
207 contentopts = _bundlespeccontentopts.get(version, {}).copy()
208
181 209 if not externalnames:
182 210 engine = util.compengines.forbundlename(compression)
183 211 compression = engine.bundletype()[1]
184 212 version = _bundlespeccgversions[version]
185 213
186 return bundlespec(compression, version, params)
214 return bundlespec(compression, version, params, contentopts)
187 215
188 216 def readbundle(ui, fh, fname, vfs=None):
189 217 header = changegroup.readexactly(fh, 4)
@@ -105,8 +105,8 b' def extsetup(ui):'
105 105 revlog.REVIDX_FLAGS_ORDER.extend(flags)
106 106
107 107 # Teach exchange to use changegroup 3
108 for k in exchange._bundlespeccgversions.keys():
109 exchange._bundlespeccgversions[k] = b'03'
108 for k in exchange._bundlespeccontentopts.keys():
109 exchange._bundlespeccontentopts[k]["cg.version"] = "03"
110 110
111 111 # Add wrappers for addrevision, responsible to set flags depending on the
112 112 # revision data contents.
General Comments 0
You need to be logged in to leave comments. Login now