Patchwork [DEFAULT(DUP)] unbundle: cleanly abort on unknown bundle2 feature

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 25, 2015, 8:47 p.m.
Message ID <5633576f2df10ce33435.1443214024@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/10644/
State Accepted
Commit f31ddc9bfa5f8f28cd899e907a0a9edb072b3e9a
Headers show

Comments

Pierre-Yves David - Sept. 25, 2015, 8:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1443142341 25200
#      Thu Sep 24 17:52:21 2015 -0700
# Node ID 5633576f2df10ce334355626d44c5de128cdf362
# Parent  485eb2a02a2bfb9914ee9534af8f2ff133bf1331
unbundle: cleanly abort on unknown bundle2 feature

The exception wasn't caught and resulted in a traceback.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6395,10 +6395,16 @@  def unbundle(ui, repo, fname1, *fnames, 
             if isinstance(gen, bundle2.unbundle20):
                 tr = repo.transaction('unbundle')
                 try:
                     op = bundle2.processbundle(repo, gen, lambda: tr)
                     tr.close()
+                except error.BundleUnknownFeatureError as exc:
+                    raise util.Abort(_('%s: unknown bundle feature, %s')
+                                     % (fname, exc),
+                                     hint=_("see https://mercurial.selenic.com/"
+                                            "wiki/BundleFeature for more "
+                                            "information"))
                 finally:
                     if tr:
                         tr.release()
                 changes = [r.get('result', 0)
                            for r in op.records['changegroup']]
diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t
--- a/tests/test-bundle2-format.t
+++ b/tests/test-bundle2-format.t
@@ -957,7 +957,11 @@  unknown compression while unbundling
 
   $ hg bundle2 --param Compression=FooBarUnknown --rev '8+7+5+4' ../rev.hg2.bz
   $ cat ../rev.hg2.bz | hg statbundle2
   abort: unknown parameters: Stream Parameter - Compression='FooBarUnknown'
   [255]
+  $ hg unbundle ../rev.hg2.bz
+  abort: ../rev.hg2.bz: unknown bundle feature, Stream Parameter - Compression='FooBarUnknown'
+  (see https://mercurial.selenic.com/wiki/BundleFeature for more information)
+  [255]
 
   $ cd ..