with: use context manager for wlock in _writerepo
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:45 -0800
changeset 27799 24b4dbb16c60
parent 27798 8953e963ce8c
child 27800 1c5f2c2c046b
with: use context manager for wlock in _writerepo
mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Fri Jan 15 13:14:50 2016 -0800
+++ b/mercurial/bookmarks.py	Fri Jan 15 13:14:45 2016 -0800
@@ -149,9 +149,7 @@
             rbm.active = None
             rbm._writeactive()
 
-        wlock = repo.wlock()
-        try:
-
+        with repo.wlock():
             file_ = repo.vfs('bookmarks', 'w', atomictemp=True)
             try:
                 self._write(file_)
@@ -161,9 +159,6 @@
             finally:
                 file_.close()
 
-        finally:
-            wlock.release()
-
     def _writeactive(self):
         if self._aclean:
             return