with: use context manager for wlock in qnew
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:47 -0800
changeset 27827 a5b168953013
parent 27826 f087b7095381
child 27828 823069f73ff9
with: use context manager for wlock in qnew
hgext/mq.py
--- a/hgext/mq.py	Fri Jan 15 13:14:47 2016 -0800
+++ b/hgext/mq.py	Fri Jan 15 13:14:47 2016 -0800
@@ -1168,8 +1168,7 @@
             raise error.Abort(_('cannot manage merge changesets'))
         self.checktoppatch(repo)
         insert = self.fullseriesend()
-        wlock = repo.wlock()
-        try:
+        with repo.wlock():
             try:
                 # if patch file write fails, abort early
                 p = self.opener(patchfn, "w")
@@ -1239,8 +1238,6 @@
                     self.ui.warn(_('error unlinking %s\n') % patchpath)
                 raise
             self.removeundo(repo)
-        finally:
-            release(wlock)
 
     def isapplied(self, patch):
         """returns (index, rev, patch)"""