changeset 27835:c448d7e00bf9

with: use context manager for wlock in shelve cleanupcmd
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:47 -0800
parents 476f53058ee8
children 1c2408c28aff
files hgext/shelve.py
diffstat 1 files changed, 1 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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"""