diff mercurial/bundle2.py @ 50553:3c0da0fa0eed

stream-clone: check the version of streaming clone supported by the client Make the server refuse to produce streaming clone bundle, if the client doesn't specify the stream=v2 capability. This is in preparation to introduce stream=v3. As far as I can tell, this capability was added at the same time as support for bundle2-based streaming pulls was added, so I don't expect clients to break. (the modern client doesn't break, at any rate)
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Sun, 21 May 2023 00:00:57 +0200
parents f2bcb56a1d39
children 58adcabc295f
line wrap: on
line diff
--- a/mercurial/bundle2.py	Sun May 21 01:03:19 2023 +0200
+++ b/mercurial/bundle2.py	Sun May 21 00:00:57 2023 +0200
@@ -1886,6 +1886,14 @@
         msg = _(b'stream data requested but server does not allow this feature')
         hint = _(b'the client seems buggy')
         raise error.Abort(msg, hint=hint)
+    if not (b'stream' in bundler.capabilities):
+        msg = _(
+            b'stream data requested but supported streaming clone versions were not specified'
+        )
+        hint = _(b'the client seems buggy')
+        raise error.Abort(msg, hint=hint)
+    if not (b'v2' in bundler.capabilities[b'stream']):
+        raise error.Abort(_(b'the client does not support streamclone v2'))
 
     # Stream clones don't compress well. And compression undermines a
     # goal of stream clones, which is to be fast. Communicate the desire