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
--- 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