diff --git a/hgext3rd/fbamend/fold.py b/hgext3rd/fbamend/fold.py --- a/hgext3rd/fbamend/fold.py +++ b/hgext3rd/fbamend/fold.py @@ -15,7 +15,6 @@ commands, error, hg, - lock as lockmod, phases, registrar, scmutil, @@ -108,15 +107,10 @@ ui.write_err(_('single revision specified, nothing to fold\n')) return 1 - wlock = lock = None - try: - wlock = repo.wlock() - lock = repo.lock() - + with repo.wlock(), repo.lock(): root, head = _foldcheck(repo, revs) - tr = repo.transaction('fold') - try: + with repo.transaction('fold') as tr: commitopts = opts.copy() allctx = [repo[r] for r in revs] targetphase = max(c.phase() for c in allctx) @@ -147,12 +141,6 @@ folded = repo.revs('allsuccessors(%ld)', revs).last() common.restackonce(ui, repo, folded) - tr.close() - finally: - tr.release() - finally: - lockmod.release(lock, wlock) - def _foldcheck(repo, revs): roots = repo.revs('roots(%ld)', revs) if len(roots) > 1: