# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-15 21:14:50 # Node ID 83995fdde2256e67b0a07a836b847a8b24363406 # Parent dc237afacbd48995a327b8cd16f2c6be037e2085 with: use context manager in unshelveabort diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -461,30 +461,27 @@ def pathtofiles(repo, files): def unshelveabort(ui, repo, state, opts): """subcommand that abort an in-progress unshelve""" - lock = None - try: - checkparents(repo, state) - - util.rename(repo.join('unshelverebasestate'), - repo.join('rebasestate')) + with repo.lock(): try: - rebase.rebase(ui, repo, **{ - 'abort' : True - }) - except Exception: - util.rename(repo.join('rebasestate'), - repo.join('unshelverebasestate')) - raise + checkparents(repo, state) - lock = repo.lock() - - mergefiles(ui, repo, state.wctx, state.pendingctx) + util.rename(repo.join('unshelverebasestate'), + repo.join('rebasestate')) + try: + rebase.rebase(ui, repo, **{ + 'abort' : True + }) + except Exception: + util.rename(repo.join('rebasestate'), + repo.join('unshelverebasestate')) + raise - repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') - finally: - shelvedstate.clear(repo) - ui.warn(_("unshelve of '%s' aborted\n") % state.name) - lockmod.release(lock) + mergefiles(ui, repo, state.wctx, state.pendingctx) + repair.strip(ui, repo, state.stripnodes, backup=False, + topic='shelve') + finally: + shelvedstate.clear(repo) + ui.warn(_("unshelve of '%s' aborted\n") % state.name) def mergefiles(ui, repo, wctx, shelvectx): """updates to wctx and merges the changes from shelvectx into the