mercurial/revlog.py
changeset 47285 46b828b85eb7
parent 47284 21ed126bab53
child 47294 93a0abe098e7
--- a/mercurial/revlog.py	Tue May 18 02:35:27 2021 +0200
+++ b/mercurial/revlog.py	Wed May 19 13:46:19 2021 +0200
@@ -2190,6 +2190,13 @@
                     fp.write(e)
                 if self._docket is not None:
                     self._docket.index_end = fp.tell()
+
+                # There is a small transactional race here. If the rename of
+                # the index fails, we should remove the datafile. It is more
+                # important to ensure that the data file is not truncated
+                # when the index is replaced as otherwise data is lost.
+                tr.replace(self._datafile, self.start(trindex))
+
                 # the temp file replace the real index when we exit the context
                 # manager