# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-15 21:14:47 # Node ID c448d7e00bf98064379ab89063e7c80f881da20c # Parent 476f53058ee84c631d422780e2e217a6c72598bd with: use context manager for wlock in shelve cleanupcmd diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -354,16 +354,12 @@ def _docreatecmd(ui, repo, pats, opts): 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"""