5315 with repo.lock(): |
5315 with repo.lock(): |
5316 for fname in fnames: |
5316 for fname in 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) |
5337 elif isinstance(gen, streamclone.streamcloneapplier): |
5334 elif isinstance(gen, streamclone.streamcloneapplier): |
5338 raise error.Abort( |
5335 raise error.Abort( |