bundle: do no check the changegroup version if no changegroup is included
We don't need to check the compatibility of something we will not use.
In practice this was getting in the was of `streamv2` bundles on a narrow
repository as the 'cg.version=02' value was rejected by this checks.
--- a/mercurial/commands.py Wed Mar 27 18:51:33 2024 +0000
+++ b/mercurial/commands.py Tue Apr 02 17:02:39 2024 +0200
@@ -1626,6 +1626,8 @@
pycompat.bytestr(e),
hint=_(b"see 'hg help bundlespec' for supported values for --type"),
)
+
+ has_changegroup = bundlespec.params.get(b"changegroup", False)
cgversion = bundlespec.params[b"cg.version"]
# Packed bundles are a pseudo bundle format for now.
@@ -1662,7 +1664,8 @@
base = [nullrev]
else:
base = None
- if cgversion not in changegroup.supportedoutgoingversions(repo):
+ supported_cg_versions = changegroup.supportedoutgoingversions(repo)
+ if has_changegroup and cgversion not in supported_cg_versions:
raise error.Abort(
_(b"repository does not support bundle version %s") % cgversion
)