changeset 50518:f2bcb56a1d39

stream-clone: make sure the `stream` capability is set when bundling This is important to start narrowing protocol option in the next changesets.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 21 May 2023 01:03:19 +0200
parents cd2a2963b982
children 3c0da0fa0eed
files mercurial/bundle2.py mercurial/bundlecaches.py
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Sun May 21 00:00:29 2023 +0200
+++ b/mercurial/bundle2.py	Sun May 21 01:03:19 2023 +0200
@@ -1730,6 +1730,8 @@
     caps = {}
     if opts.get(b'obsolescence', False):
         caps[b'obsmarkers'] = (b'V1',)
+    if opts.get(b'streamv2'):
+        caps[b'stream'] = [b'v2']
     bundle = bundle20(ui, caps)
     bundle.setcompression(compression, compopts)
     _addpartsfromopts(ui, repo, bundle, source, outgoing, opts)
--- a/mercurial/bundlecaches.py	Sun May 21 00:00:29 2023 +0200
+++ b/mercurial/bundlecaches.py	Sun May 21 01:03:19 2023 +0200
@@ -269,17 +269,15 @@
             )
 
     # Compute contentopts based on the version
-    if b"stream" in params and params[b"stream"] == b"v2":
-        # That case is fishy as this mostly derails the version selection
+    if b"stream" in params:
+        # This case is fishy as this mostly derails the version selection
         # mechanism. `stream` bundles are quite specific and used differently
         # as "normal" bundles.
         #
-        # So we are pinning this to "v2", as this will likely be
-        # compatible forever. (see the next conditional).
-        #
         # (we should probably define a cleaner way to do this and raise a
-        # warning when the old way is encounter)
-        version = b"streamv2"
+        # warning when the old way is encountered)
+        if params[b"stream"] == b"v2":
+            version = b"streamv2"
     contentopts = _bundlespeccontentopts.get(version, {}).copy()
     if version == b"streamv2":
         # streamv2 have been reported as "v2" for a while.