bundle: avoid crash when no good changegroup version found
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 25 Mar 2016 23:05:32 -0700
changeset 30999 c4b727795d6a5770ec523c1965b464baed81097f
parent 30998 07f1fbf1f75876e17bcf28757caf8e44a73547cd
child 31000 ff0d3b6b287f89594bd8d0308fe2810d2a18ea01
push id212
push usergszorc@mozilla.com
push dateSun, 03 Apr 2016 17:09:04 +0000
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.
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1394,16 +1394,20 @@ def bundle(ui, repo, fname, dest=None, *
                                 "a destination"))
         if opts.get('base'):
             ui.warn(_("ignoring --base because --all was specified\n"))
         base = ['null']
         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 destination"))
         common = [repo.lookup(rev) for rev in base]
         heads = revs and map(repo.lookup, revs) or revs
         cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
                                          common=common, bundlecaps=bundlecaps,
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -731,8 +731,14 @@ Stream clone with fncachestore
   8 files, 3 changesets, 10 total revisions
 Packed bundle
   $ hg -R deeprepo debugcreatestreamclonebundle repo-packed.hg
   writing 3349 bytes for 18 files
   bundle requirements: generaldelta, revlogv1, treemanifest
   $ hg debugbundle --spec repo-packed.hg
+Bundle with changegroup2 is not supported
+  $ hg -R deeprepo bundle --all -t v2 deeprepo.bundle
+  abort: repository does not support bundle version 02
+  [255]