diff -r 476f53058ee8 -r c448d7e00bf9 hgext/shelve.py --- a/hgext/shelve.py Fri Jan 15 13:14:47 2016 -0800 +++ b/hgext/shelve.py Fri Jan 15 13:14:47 2016 -0800 @@ -354,16 +354,12 @@ def cleanupcmd(ui, repo): """subcommand that deletes all shelves""" - wlock = None - try: - wlock = repo.wlock() + with repo.wlock(): for (name, _type) in repo.vfs.readdir('shelved'): suffix = name.rsplit('.', 1)[-1] if suffix in ('hg', 'patch'): shelvedfile(repo, name).movetobackup() cleanupoldbackups(repo) - finally: - lockmod.release(wlock) def deletecmd(ui, repo, pats): """subcommand that deletes a specific shelve"""