with: use context manager for wlock in shelve cleanupcmd
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:47 -0800
changeset 27835 c448d7e00bf9
parent 27834 476f53058ee8
child 27836 1c2408c28aff
with: use context manager for wlock in shelve cleanupcmd
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"""