revlog: close the index file handle after the data one
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 26 May 2021 21:46:45 +0200
changeset 47328 27e9ed1217c5
parent 47327 1844a2e3401c
child 47329 717a94b423b9
revlog: close the index file handle after the data one This make sure the data file is flushed before the index. preventing the index to reference unflushed data. Differential Revision: https://phab.mercurial-scm.org/D10776
mercurial/revlog.py
--- a/mercurial/revlog.py	Wed May 26 21:35:51 2021 +0200
+++ b/mercurial/revlog.py	Wed May 26 21:46:45 2021 +0200
@@ -2267,10 +2267,12 @@
                     self._write_docket(transaction)
             finally:
                 self._writinghandles = None
+                if dfh is not None:
+                    dfh.close()
+                # closing the index file last to avoid exposing referent to
+                # potential unflushed data content.
                 if ifh is not None:
                     ifh.close()
-                if dfh is not None:
-                    dfh.close()
 
     def _write_docket(self, transaction):
         """write the current docket on disk