bmstore: close file in a finally block in _writerepo
Also rename the variable to file_ to avoid shadowing a builtin.
--- 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()