##// END OF EJS Templates
unbundle: use context manager for transaction
Martin von Zweigbergk -
r32844:76bb53f8 default
parent child Browse files
Show More
@@ -5317,20 +5317,17 b' def unbundle(ui, repo, fname1, *fnames, '
5317 f = hg.openpath(ui, fname)
5317 f = hg.openpath(ui, fname)
5318 gen = exchange.readbundle(ui, f, fname)
5318 gen = exchange.readbundle(ui, f, fname)
5319 if isinstance(gen, bundle2.unbundle20):
5319 if isinstance(gen, bundle2.unbundle20):
5320 tr = repo.transaction('unbundle')
5320 with repo.transaction('unbundle') as tr:
5321 try:
5321 try:
5322 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
5322 op = bundle2.applybundle(repo, gen, tr,
5323 url='bundle:' + fname)
5323 source='unbundle',
5324 tr.close()
5324 url='bundle:' + fname)
5325 except error.BundleUnknownFeatureError as exc:
5325 except error.BundleUnknownFeatureError as exc:
5326 raise error.Abort(_('%s: unknown bundle feature, %s')
5326 raise error.Abort(
5327 % (fname, exc),
5327 _('%s: unknown bundle feature, %s') % (fname, exc),
5328 hint=_("see https://mercurial-scm.org/"
5328 hint=_("see https://mercurial-scm.org/"
5329 "wiki/BundleFeature for more "
5329 "wiki/BundleFeature for more "
5330 "information"))
5330 "information"))
5331 finally:
5332 if tr:
5333 tr.release()
5334 changes = [r.get('return', 0)
5331 changes = [r.get('return', 0)
5335 for r in op.records['changegroup']]
5332 for r in op.records['changegroup']]
5336 modheads = changegroup.combineresults(changes)
5333 modheads = changegroup.combineresults(changes)
General Comments 0
You need to be logged in to leave comments. Login now