[PATCH 07 of 10] unbundle: move BundleUnknownFeatureError exception handling out
Martin von Zweigbergk
martinvonz at google.com
Sat Jun 24 15:38:35 UTC 2017
# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1498168993 25200
# Thu Jun 22 15:03:13 2017 -0700
# Node ID 0e791a5d805adf64d9056f7ee7be1f084c7ca10b
# Parent a57900f80358f016d3b84dfe85a53c1530136673
unbundle: move BundleUnknownFeatureError exception handling out
This just moves the BundleUnknownFeatureError exception handling one
level up so we collect the bundle2.applybundle{,1}() calls
together. applybundle1() will never throw the exception, so it should
have no functional consequence.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5202,23 +5202,23 @@
'"hg unbundle"'),
hint=_('use "hg debugapplystreamclonebundle"'))
url = 'bundle:' + fname
- if isinstance(gen, bundle2.unbundle20):
- with repo.transaction('unbundle') as tr:
- try:
+ try:
+ if isinstance(gen, bundle2.unbundle20):
+ with repo.transaction('unbundle') as tr:
op = bundle2.applybundle(repo, gen, tr,
source='unbundle',
url=url)
- except error.BundleUnknownFeatureError as exc:
- raise error.Abort(
- _('%s: unknown bundle feature, %s') % (fname, exc),
- hint=_("see https://mercurial-scm.org/"
- "wiki/BundleFeature for more "
- "information"))
- else:
- txnname = 'unbundle\n%s' % util.hidepassword(url)
- with repo.transaction(txnname) as tr:
- op = bundle2.applybundle1(repo, gen, tr, source='unbundle',
- url=url)
+ else:
+ txnname = 'unbundle\n%s' % util.hidepassword(url)
+ with repo.transaction(txnname) as tr:
+ op = bundle2.applybundle1(repo, gen, tr,
+ source='unbundle', url=url)
+ except error.BundleUnknownFeatureError as exc:
+ raise error.Abort(
+ _('%s: unknown bundle feature, %s') % (fname, exc),
+ hint=_("see https://mercurial-scm.org/"
+ "wiki/BundleFeature for more "
+ "information"))
modheads = bundle2.combinechangegroupresults(op)
return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
More information about the Mercurial-devel
mailing list