Patchwork bundle: avoid crash when when no good changegroup version found

login
register
mail settings
Submitter via Mercurial-devel
Date March 28, 2016, 10:16 p.m.
Message ID <36d7ddd387bf91b2623e.1459203408@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/14116/
State Accepted
Headers show

Comments

via Mercurial-devel - March 28, 2016, 10:16 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1458972332 25200
#      Fri Mar 25 23:05:32 2016 -0700
# Node ID 36d7ddd387bf91b2623ee2a020279ef5c7af7669
# Parent  5474dc73680f96e79ae3c255fb01b7943b2fc2d1
bundle: avoid crash when 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.
Pierre-Yves David - March 29, 2016, 2:20 a.m.
On 03/28/2016 03:16 PM, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1458972332 25200
> #      Fri Mar 25 23:05:32 2016 -0700
> # Node ID 36d7ddd387bf91b2623ee2a020279ef5c7af7669
> # Parent  5474dc73680f96e79ae3c255fb01b7943b2fc2d1
> bundle: avoid crash when 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.

Thanks for cleaning that up. Pushed,

Patch

diff -r 5474dc73680f -r 36d7ddd387bf mercurial/commands.py
--- a/mercurial/commands.py	Mon Mar 28 09:12:03 2016 +0200
+++ 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 "
diff -r 5474dc73680f -r 36d7ddd387bf tests/test-treemanifest.t
--- a/tests/test-treemanifest.t	Mon Mar 28 09:12:03 2016 +0200
+++ 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]