comparison mercurial/commands.py @ 33042:dbc2ee17053e

bundle: transpose transaction scope with bundle type switch This moves the transaction with-statements outside of the per-bundle-version switches, so the next patch will be a little simpler.
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 22 Jun 2017 21:27:57 -0700
parents e425f5aabe70
children 18c2489ac96d
comparison
equal deleted inserted replaced
33041:e425f5aabe70 33042:dbc2ee17053e
5201 _('packed bundles cannot be applied with ' 5201 _('packed bundles cannot be applied with '
5202 '"hg unbundle"'), 5202 '"hg unbundle"'),
5203 hint=_('use "hg debugapplystreamclonebundle"')) 5203 hint=_('use "hg debugapplystreamclonebundle"'))
5204 url = 'bundle:' + fname 5204 url = 'bundle:' + fname
5205 try: 5205 try:
5206 if isinstance(gen, bundle2.unbundle20): 5206 txnname = 'unbundle'
5207 with repo.transaction('unbundle') as tr: 5207 if not isinstance(gen, bundle2.unbundle20):
5208 txnname = 'unbundle\n%s' % util.hidepassword(url)
5209 with repo.transaction(txnname) as tr:
5210 if isinstance(gen, bundle2.unbundle20):
5208 op = bundle2.applybundle(repo, gen, tr, 5211 op = bundle2.applybundle(repo, gen, tr,
5209 source='unbundle', 5212 source='unbundle',
5210 url=url) 5213 url=url)
5211 else: 5214 else:
5212 txnname = 'unbundle\n%s' % util.hidepassword(url)
5213 with repo.transaction(txnname) as tr:
5214 op = bundle2.applybundle1(repo, gen, tr, 5215 op = bundle2.applybundle1(repo, gen, tr,
5215 source='unbundle', url=url) 5216 source='unbundle', url=url)
5216 except error.BundleUnknownFeatureError as exc: 5217 except error.BundleUnknownFeatureError as exc:
5217 raise error.Abort( 5218 raise error.Abort(
5218 _('%s: unknown bundle feature, %s') % (fname, exc), 5219 _('%s: unknown bundle feature, %s') % (fname, exc),