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".
--- 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.