# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-15 21:14:47 # Node ID 496ca4deddc56e09a44c2a2a27aee8dcb132289d # Parent 1c2408c28aff71044dbdc8f82ced26b55373b8e1 with: use context manager for wlock in unshelve diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -602,11 +602,8 @@ def unshelve(ui, repo, *shelved, **opts) than ``maxbackups`` backups are kept, if same timestamp prevents from deciding exact order of them, for safety. """ - wlock = repo.wlock() - try: + with repo.wlock(): return _dounshelve(ui, repo, *shelved, **opts) - finally: - lockmod.release(wlock) def _dounshelve(ui, repo, *shelved, **opts): abortf = opts['abort']