diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1189,7 +1189,7 @@ bundletype = opts.get('type', 'bzip2').lower() try: - bcompression, cgversion, params = exchange.parsebundlespec( + bcompression, cgversion, params, contentopts = exchange.parsebundlespec( repo, bundletype, strict=False) except error.UnsupportedBundleSpecification as e: raise error.Abort(str(e), @@ -1256,12 +1256,13 @@ 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 if repo.ui.configbool('experimental', 'bundle-phases'): contentopts['phases'] = True + bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing, contentopts, compression=bcompression, compopts=compopts) diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -46,6 +46,20 @@ 'bundle2': '02', #legacy } +# Maps bundle version with content opts to choose which part to bundle +_bundlespeccontentops = { + 'v1': { + 'changegroup': True, + 'obsolescence': False, + 'phases': False + }, + 'v2': { + 'changegroup': True, + 'obsolescence': False, + 'phases': False + } +} + # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. _bundlespecv1compengines = {'gzip', 'bzip2', 'none'} @@ -165,11 +179,18 @@ _('missing support for repository features: %s') % ', '.join(sorted(missingreqs))) + # Compute contentops based on the version + contentops = _bundlespeccontentops.get(version, {}).copy() + if not externalnames: engine = util.compengines.forbundlename(compression) compression = engine.bundletype()[1] version = _bundlespeccgversions[version] - return compression, version, params + + # Set the cg.version + contentops["cg.version"] = version + + return compression, version, params, contentops def readbundle(ui, fh, fname, vfs=None): header = changegroup.readexactly(fh, 4) @@ -2107,7 +2128,7 @@ # component of the BUNDLESPEC. if key == 'BUNDLESPEC': try: - comp, version, params = parsebundlespec(repo, value, + comp, version, params, _ = parsebundlespec(repo, value, externalnames=True) attrs['COMPRESSION'] = comp attrs['VERSION'] = version @@ -2135,7 +2156,7 @@ spec = entry.get('BUNDLESPEC') if spec: try: - comp, version, params = parsebundlespec(repo, spec, strict=True) + comp, version, params, _ = parsebundlespec(repo, spec, strict=True) # If a stream clone was requested, filter out non-streamclone # entries.