changeset 52957:961900fbd67c stable

bundles: filter out unsupported requirements for non-packed1 format stream bundle specs specify requirements, but we were ignoring this when selecting which bundle to apply, causing spurious clone failures.
author Julien Cristau <jcristau@mozilla.com>
date Tue, 18 Feb 2025 10:33:30 +0100
parents 818c2f0a5c84
children 5b36cb26c650
files mercurial/bundlecaches.py tests/test-stream-bundle-v2.t
diffstat 2 files changed, 32 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundlecaches.py	Tue Feb 11 22:14:35 2025 -0500
+++ b/mercurial/bundlecaches.py	Tue Feb 18 10:33:30 2025 +0100
@@ -318,10 +318,10 @@
             % compression
         )
 
-    # The specification for packed1 can optionally declare the data formats
+    # The specification for stream bundles can optionally declare the data formats
     # required to apply it. If we see this metadata, compare against what the
     # repo supports and error if the bundle isn't compatible.
-    if version == b'packed1' and b'requirements' in params:
+    if b'requirements' in params:
         requirements = set(cast(bytes, params[b'requirements']).split(b','))
         missingreqs = requirements - requirementsmod.STREAM_FIXED_REQUIREMENTS
         if missingreqs:
--- a/tests/test-stream-bundle-v2.t	Tue Feb 11 22:14:35 2025 -0500
+++ b/tests/test-stream-bundle-v2.t	Tue Feb 18 10:33:30 2025 +0100
@@ -91,20 +91,44 @@
   none-v2;stream=v3-exp;requirements%3Dgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog (stream-v3 zstd no-rust !)
   none-v2;stream=v3-exp;requirements%3Dgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog (stream-v3 rust !)
 
-Test that we can apply the bundle as a stream clone bundle
-
-  $ cat > .hg/clonebundles.manifest << EOF
-  > http://localhost:$HGPORT1/bundle.hg BUNDLESPEC=`hg debugbundle --spec bundle.hg`
-  > EOF
-
   $ hg serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log
   $ cat hg.pid >> $DAEMON_PIDS
 
   $ "$PYTHON" $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid
   $ cat http.pid >> $DAEMON_PIDS
 
+Stream bundle spec with unknown requirements should be filtered out
+
+#if stream-v2
+  $ cat > .hg/clonebundles.manifest << EOF
+  > http://localhost:$HGPORT1/bundle.hg BUNDLESPEC=none-v2;stream=v2;requirements%3Drevlogv42
+  > EOF
+#endif
+#if stream-v3
+  $ cat > .hg/clonebundles.manifest << EOF
+  > http://localhost:$HGPORT1/bundle.hg BUNDLESPEC=none-v2;stream=v3-exp;requirements%3Drevlogv42
+  > EOF
+#endif
+
   $ cd ..
 
+  $ hg clone -U http://localhost:$HGPORT stream-clone-unsupported-requirements
+  no compatible clone bundles available on server; falling back to regular clone
+  (you may want to report this to the server operator)
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 5 changesets with 5 changes to 5 files
+  new changesets 426bada5c675:9bc730a19041 (5 drafts)
+
+Test that we can apply the bundle as a stream clone bundle
+
+  $ cat > main/.hg/clonebundles.manifest << EOF
+  > http://localhost:$HGPORT1/bundle.hg BUNDLESPEC=`hg debugbundle --spec main/bundle.hg`
+  > EOF
+
+
 #if stream-v2
   $ hg clone http://localhost:$HGPORT stream-clone-implicit --debug
   using http://localhost:$HGPORT/