stream-clone: check is a compatible protocol can be found
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 20 May 2023 01:39:13 +0200
changeset 50523 a6543983b8f4
parent 50522 58e4842fbfc1
child 50524 58adcabc295f
stream-clone: check is a compatible protocol can be found The previous code was explicitly checking if "v2" is listed in the "stream" bundle2 capability. The new code is checking is there is anything common between the versions supported client side and server side overlaps. This prepare the introduction of more stream version than "v2".
mercurial/streamclone.py
--- a/mercurial/streamclone.py	Sat May 20 01:22:49 2023 +0200
+++ b/mercurial/streamclone.py	Sat May 20 01:39:13 2023 +0200
@@ -15,6 +15,7 @@
 from .interfaces import repository
 from . import (
     bookmarks,
+    bundle2 as bundle2mod,
     cacheutil,
     error,
     narrowspec,
@@ -89,8 +90,10 @@
 
     bundle2supported = False
     if pullop.canusebundle2:
-        if b'v2' in pullop.remotebundle2caps.get(b'stream', []):
-            bundle2supported = True
+        local_caps = bundle2mod.getrepocaps(repo, role=b'client')
+        local_supported = set(local_caps.get(b'stream', []))
+        remote_supported = set(pullop.remotebundle2caps.get(b'stream', []))
+        bundle2supported = bool(local_supported & remote_supported)
         # else
         # Server doesn't support bundle2 stream clone or doesn't support
         # the versions we support. Fall back and possibly allow legacy.