revlog: avoid exposing delayed index entry too widely in non-inline revlog stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 07 Dec 2023 00:34:08 +0100
branchstable
changeset 51142 66417f55ea33
parent 51141 962974a5d068
child 51143 849745d7da89
revlog: avoid exposing delayed index entry too widely in non-inline revlog Before this change, the index entry would be seen as "appended" to the data file. It did not hurt too much as there are never accessed for reading, but this was odd. So lets stop doing so.
mercurial/revlog.py
--- a/mercurial/revlog.py	Wed Dec 06 15:38:15 2023 +0100
+++ b/mercurial/revlog.py	Thu Dec 07 00:34:08 2023 +0100
@@ -1173,7 +1173,9 @@
                 self.opener.unlink(self.index_file)
             return self.index_file
         else:
-            self._segmentfile._delay_buffer = self._delay_buffer = []
+            self._delay_buffer = []
+            if self.inline:
+                self._segmentfile._delay_buffer = self._delay_buffer
             return None
 
     def write_pending(self):
@@ -1193,7 +1195,11 @@
                 ifh.seek(0, os.SEEK_END)
                 ifh.write(b"".join(self._delay_buffer))
             any_pending = True
-        self._segmentfile._delay_buffer = self._delay_buffer = None
+        self._delay_buffer = None
+        if self.inline:
+            self._segmentfile._delay_buffer = self._delay_buffer
+        else:
+            assert self._segmentfile._delay_buffer is None
         self._orig_index_file = self.index_file
         self.index_file = pending_index_file
         self._segmentfile.filename = self.index_file