changeset 33625:6788e648efcf stable

test-revlog-raw: close file handles explicitly (issue5644)
author Yuya Nishihara <yuya@tcha.org>
date Wed, 02 Aug 2017 22:58:38 +0900
parents b4793cc8e1c0
children 524b13fc711f
files tests/test-revlog-raw.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-revlog-raw.py	Wed Aug 02 22:04:02 2017 +0900
+++ b/tests/test-revlog-raw.py	Wed Aug 02 22:58:38 2017 +0900
@@ -144,12 +144,18 @@
             text = None
             cachedelta = (deltaparent, rlog.revdiff(deltaparent, r))
         flags = rlog.flags(r)
-        ifh = dlog.opener(dlog.indexfile, 'a+')
-        dfh = None
-        if not dlog._inline:
-            dfh = dlog.opener(dlog.datafile, 'a+')
-        dlog._addrevision(rlog.node(r), text, tr, r, p1, p2, flags, cachedelta,
-                          ifh, dfh)
+        ifh = dfh = None
+        try:
+            ifh = dlog.opener(dlog.indexfile, 'a+')
+            if not dlog._inline:
+                dfh = dlog.opener(dlog.datafile, 'a+')
+            dlog._addrevision(rlog.node(r), text, tr, r, p1, p2, flags,
+                              cachedelta, ifh, dfh)
+        finally:
+            if dfh is not None:
+                dfh.close()
+            if ifh is not None:
+                ifh.close()
     return dlog
 
 # Utilities to generate revisions for testing