shelve: use try/except/finally
authorMatt Mackall <mpm@selenic.com>
Fri, 15 May 2015 09:55:31 -0500
changeset 25080 68f456f2f425
parent 25079 bee00e0c2e45
child 25081 7642f119c2a2
shelve: use try/except/finally
hgext/shelve.py
--- a/hgext/shelve.py	Fri May 15 09:55:15 2015 -0500
+++ b/hgext/shelve.py	Fri May 15 09:55:31 2015 -0500
@@ -284,17 +284,15 @@
     """subcommand that deletes a specific shelve"""
     if not pats:
         raise util.Abort(_('no shelved changes specified!'))
-    wlock = None
+    wlock = repo.wlock()
     try:
-        wlock = repo.wlock()
-        try:
-            for name in pats:
-                for suffix in 'hg patch'.split():
-                    shelvedfile(repo, name, suffix).unlink()
-        except OSError, err:
-            if err.errno != errno.ENOENT:
-                raise
-            raise util.Abort(_("shelved change '%s' not found") % name)
+        for name in pats:
+            for suffix in 'hg patch'.split():
+                shelvedfile(repo, name, suffix).unlink()
+    except OSError, err:
+        if err.errno != errno.ENOENT:
+            raise
+        raise util.Abort(_("shelved change '%s' not found") % name)
     finally:
         lockmod.release(wlock)