# HG changeset patch # User Bryan O'Sullivan # Date 1452892490 28800 # Node ID 83995fdde2256e67b0a07a836b847a8b24363406 # Parent dc237afacbd48995a327b8cd16f2c6be037e2085 with: use context manager in unshelveabort diff -r dc237afacbd4 -r 83995fdde225 hgext/shelve.py --- a/hgext/shelve.py Fri Jan 15 13:14:47 2016 -0800 +++ b/hgext/shelve.py Fri Jan 15 13:14:50 2016 -0800 @@ -461,30 +461,27 @@ 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