Patchwork D1952: bundlespec: move computing the bundle contentops in parsebundlespec

login
register
mail settings
Submitter phabricator
Date Jan. 31, 2018, 4:25 p.m.
Message ID <differential-rev-PHID-DREV-h2qxoeuxzm7ygph7hxpq-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27094/
State New
Headers show

Comments

phabricator - Jan. 31, 2018, 4:25 p.m.
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We will introduce a new bundlespec for stream bundle which will influence the
  contentops.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1952

AFFECTED FILES
  mercurial/commands.py
  mercurial/exchange.py

CHANGE DETAILS




To: lothiraldan, #hg-reviewers
Cc: mercurial-devel

Patch

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.
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)