bundle: avoid crash when no good changegroup version found
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 25 Mar 2016 23:05:32 -0700
changeset 28669 c4b727795d6a
parent 28668 07f1fbf1f758
child 28670 ff0d3b6b287f
bundle: avoid crash when no good changegroup version found When using treemanifests, only changegroup3 bundles can be created. However, there is currently no way of requesting a changegroup3 bundle, so we run into an assertion in changegroup.getbundler() when trying to get a changroup2 bundler. Let's avoid the traceback and print a short error message instead.
mercurial/commands.py
tests/test-treemanifest.t
--- a/mercurial/commands.py	Fri Mar 25 16:13:28 2016 -0700
+++ b/mercurial/commands.py	Fri Mar 25 23:05:32 2016 -0700
@@ -1399,6 +1399,10 @@
         base = scmutil.revrange(repo, opts.get('base'))
     # TODO: get desired bundlecaps from command line.
     bundlecaps = None
+    if cgversion not in changegroup.supportedoutgoingversions(repo):
+        raise error.Abort(_("repository does not support bundle version %s") %
+                          cgversion)
+
     if base:
         if dest:
             raise error.Abort(_("--base is incompatible with specifying "
--- a/tests/test-treemanifest.t	Fri Mar 25 16:13:28 2016 -0700
+++ b/tests/test-treemanifest.t	Fri Mar 25 23:05:32 2016 -0700
@@ -736,3 +736,9 @@
   bundle requirements: generaldelta, revlogv1, treemanifest
   $ hg debugbundle --spec repo-packed.hg
   none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Ctreemanifest
+
+Bundle with changegroup2 is not supported
+
+  $ hg -R deeprepo bundle --all -t v2 deeprepo.bundle
+  abort: repository does not support bundle version 02
+  [255]