diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py --- 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. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- 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) diff --git a/mercurial/commands.py b/mercurial/commands.py --- 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', diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- 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) diff --git a/tests/flagprocessorext.py b/tests/flagprocessorext.py --- 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.