diff mercurial/exchange.py @ 37165: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 6f467adf9f05
line wrap: on
line diff
--- a/mercurial/exchange.py	Fri Mar 30 12:43:08 2018 +0200
+++ b/mercurial/exchange.py	Fri Mar 30 12:43:57 2018 +0200
@@ -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)