nodemap: write new data from the expected current data length
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 15 Jan 2020 15:50:43 +0100
changeset 44338 2ea6a67ff502
parent 44337 1d2b37def017
child 44339 c7eebdb15139
nodemap: write new data from the expected current data length If the amount of data in the file exceed the expect amount, we will overwrite the extra data. This is a simple way to be safer. Differential Revision: https://phab.mercurial-scm.org/D7891
mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:50:33 2020 +0100
+++ b/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:50:43 2020 +0100
@@ -92,7 +92,8 @@
             datafile = _rawdata_filepath(revlog, target_docket)
             # EXP-TODO: if this is a cache, this should use a cache vfs, not a
             # store vfs
-            with revlog.opener(datafile, b'a') as fd:
+            with revlog.opener(datafile, b'r+') as fd:
+                fd.seek(target_docket.data_length)
                 fd.write(data)
             target_docket.data_length += len(data)
             target_docket.data_unused += data_changed_count