changeset 27188:6a1301e22bd7

bmstore: close file in a finally block in _writerepo Also rename the variable to file_ to avoid shadowing a builtin.
author Augie Fackler <augie@google.com>
date Wed, 11 Nov 2015 21:03:48 -0500
parents d9dcc5c09d77
children 7b6cb7c15109
files mercurial/bookmarks.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Wed Nov 11 21:01:23 2015 -0500
+++ b/mercurial/bookmarks.py	Wed Nov 11 21:03:48 2015 -0500
@@ -132,9 +132,14 @@
         wlock = repo.wlock()
         try:
 
-            file = repo.vfs('bookmarks', 'w', atomictemp=True)
-            self._write(file)
-            file.close()
+            file_ = repo.vfs('bookmarks', 'w', atomictemp=True)
+            try:
+                self._write(file_)
+            except: # re-raises
+                file_.discard()
+                raise
+            finally:
+                file_.close()
 
         finally:
             wlock.release()