bundlespec: phase out the `_bundlespeccgversions` mapping
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 17 May 2022 11:57:17 +0100
changeset 49321 c12c843f0db7
parent 49319 a75b530cfc29
child 49322 d587f09cad98
bundlespec: phase out the `_bundlespeccgversions` mapping The `_bundlespeccgversions` mapping is redundant with the `cg.version` parameter. We move all users to the `cg.version` version and phase out the `_bundlespeccgversions` mapping.
mercurial/bundlecaches.py
--- a/mercurial/bundlecaches.py	Mon Jun 13 11:20:57 2022 -0400
+++ b/mercurial/bundlecaches.py	Tue May 17 11:57:17 2022 +0100
@@ -56,7 +56,12 @@
         b'tagsfnodescache': True,
         b'revbranchcache': True,
     },
-    b'packed1': {b'cg.version': b's1'},
+    b'packed1': {
+        b'cg.version': b's1',
+    },
+    b'bundle2': {  # legacy
+        b'cg.version': b'02',
+    },
 }
 _bundlespeccontentopts[b'bundle2'] = _bundlespeccontentopts[b'v2']
 
@@ -150,7 +155,7 @@
 
         version, params = parseparams(version)
 
-        if version not in _bundlespeccgversions:
+        if version not in _bundlespeccontentopts:
             raise error.UnsupportedBundleSpecification(
                 _(b'%s is not a recognized bundle version') % version
             )
@@ -172,7 +177,7 @@
             # Modern compression engines require v2.
             if compression not in _bundlespecv1compengines:
                 version = b'v2'
-        elif spec in _bundlespeccgversions:
+        elif spec in _bundlespeccontentopts:
             if spec == b'packed1':
                 compression = b'none'
             else:
@@ -212,7 +217,7 @@
 
     engine = util.compengines.forbundlename(compression)
     compression, wirecompression = engine.bundletype()
-    wireversion = _bundlespeccgversions[version]
+    wireversion = _bundlespeccontentopts[version][b'cg.version']
 
     return bundlespec(
         compression, wirecompression, version, wireversion, params, contentopts