changeset 27800:1c5f2c2c046b

with: use context manager for wlock in _writeactive
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:45 -0800
parents 24b4dbb16c60
children 7be6371c732e
files mercurial/bookmarks.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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):