Mercurial > hg > mercurial-source
changeset 37951: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 | 568e9b928c4c |
files | hgext/lfs/__init__.py mercurial/bundle2.py mercurial/commands.py mercurial/exchange.py tests/flagprocessorext.py |
diffstat | 5 files changed, 44 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/lfs/__init__.py +++ b/hgext/lfs/__init__.py @@ -340,9 +340,7 @@ # Make bundle choose changegroup3 instead of changegroup2. This affects # "hg bundle" command. Note: it does not cover all bundle formats like # "packed1". Using "packed1" with lfs will likely cause trouble. - names = [k for k, v in exchange._bundlespeccgversions.items() if v == '02'] - for k in names: - exchange._bundlespeccgversions[k] = '03' + exchange._bundlespeccontentopts["v2"]["cg.version"] = "03" # bundlerepo uses "vfsmod.readonlyvfs(othervfs)", we need to make sure lfs # options and blob stores are passed from othervfs to the new readonlyvfs.
--- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -1596,8 +1596,11 @@ outgoing.missingheads): part.addparam('targetphase', '%d' % phases.secret, mandatory=False) - addparttagsfnodescache(repo, bundler, outgoing) - addpartrevbranchcache(repo, bundler, outgoing) + if opts.get('tagsfnodescache', True): + addparttagsfnodescache(repo, bundler, outgoing) + + if opts.get('revbranchcache', True): + addpartrevbranchcache(repo, bundler, outgoing) if opts.get('obsolescence', False): obsmarkers = repo.obsstore.relevantmarkers(outgoing.missing)
--- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1204,7 +1204,7 @@ raise error.Abort(pycompat.bytestr(e), hint=_("see 'hg help bundlespec' for supported " "values for --type")) - cgversion = bundlespec.version + cgversion = bundlespec.contentopts["cg.version"] # Packed bundles are a pseudo bundle format for now. if cgversion == 's1': @@ -1267,14 +1267,15 @@ if complevel is not None: compopts['level'] = complevel - - contentopts = {'cg.version': cgversion, 'changegroup': True} + # Allow overriding the bundling of obsmarker in phases through + # configuration while we don't have a bundle version that include them if repo.ui.configbool('experimental', 'evolution.bundle-obsmarker'): - contentopts['obsolescence'] = True + bundlespec.contentopts['obsolescence'] = True if repo.ui.configbool('experimental', 'bundle-phases'): - contentopts['phases'] = True + bundlespec.contentopts['phases'] = True + bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing, - contentopts, compression=bcompression, + bundlespec.contentopts, compression=bcompression, compopts=compopts) @command('cat',
--- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -52,6 +52,30 @@ 'bundle2': '02', #legacy } +# Maps bundle version with content opts to choose which part to bundle +_bundlespeccontentopts = { + 'v1': { + 'changegroup': True, + 'cg.version': '01', + 'obsolescence': False, + 'phases': False, + 'tagsfnodescache': False, + 'revbranchcache': False + }, + 'v2': { + 'changegroup': True, + 'cg.version': '02', + 'obsolescence': False, + 'phases': False, + 'tagsfnodescache': True, + 'revbranchcache': True + }, + 'packed1' : { + 'cg.version': 's1' + } +} +_bundlespeccontentopts['bundle2'] = _bundlespeccontentopts['v2'] + # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. _bundlespecv1compengines = {'gzip', 'bzip2', 'none'} @@ -60,6 +84,7 @@ compression = attr.ib() version = attr.ib() params = attr.ib() + contentopts = attr.ib() def parsebundlespec(repo, spec, strict=True, externalnames=False): """Parse a bundle string specification into parts. @@ -178,12 +203,15 @@ _('missing support for repository features: %s') % ', '.join(sorted(missingreqs))) + # Compute contentopts based on the version + contentopts = _bundlespeccontentopts.get(version, {}).copy() + if not externalnames: engine = util.compengines.forbundlename(compression) compression = engine.bundletype()[1] version = _bundlespeccgversions[version] - return bundlespec(compression, version, params) + return bundlespec(compression, version, params, contentopts) def readbundle(ui, fh, fname, vfs=None): header = changegroup.readexactly(fh, 4)
--- a/tests/flagprocessorext.py +++ b/tests/flagprocessorext.py @@ -105,8 +105,8 @@ revlog.REVIDX_FLAGS_ORDER.extend(flags) # Teach exchange to use changegroup 3 - for k in exchange._bundlespeccgversions.keys(): - exchange._bundlespeccgversions[k] = b'03' + for k in exchange._bundlespeccontentopts.keys(): + exchange._bundlespeccontentopts[k]["cg.version"] = "03" # Add wrappers for addrevision, responsible to set flags depending on the # revision data contents.