with: use context manager for wlock in _writeactive
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:45 -0800
changeset 27800 1c5f2c2c046b
parent 27799 24b4dbb16c60
child 27801 7be6371c732e
with: use context manager for wlock in _writeactive
mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Fri Jan 15 13:14:45 2016 -0800
+++ b/mercurial/bookmarks.py	Fri Jan 15 13:14:45 2016 -0800
@@ -162,8 +162,7 @@
     def _writeactive(self):
         if self._aclean:
             return
-        wlock = self._repo.wlock()
-        try:
+        with self._repo.wlock():
             if self._active is not None:
                 f = self._repo.vfs('bookmarks.current', 'w', atomictemp=True)
                 try:
@@ -176,8 +175,6 @@
                 except OSError as inst:
                     if inst.errno != errno.ENOENT:
                         raise
-        finally:
-            wlock.release()
         self._aclean = True
 
     def _write(self, fp):