Mercurial > hg-stable
changeset 33053:e425f5aabe70
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.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 22 Jun 2017 15:03:13 -0700 |
parents | 2baef42a2881 |
children | dbc2ee17053e |
files | mercurial/commands.py |
diffstat | 1 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Jun 21 21:08:48 2017 -0700 +++ b/mercurial/commands.py Thu Jun 22 15:03:13 2017 -0700 @@ -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)