# HG changeset patch # User Pierre-Yves David # Date 2020-01-15 14:50:43 # Node ID 2ea6a67ff5029f7c64d06331cdb7034404d44d43 # Parent 1d2b37def017bb806653b04c1e735c26e261df3a 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 diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py --- a/mercurial/revlogutils/nodemap.py +++ b/mercurial/revlogutils/nodemap.py @@ -92,7 +92,8 @@ def _persist_nodemap(tr, revlog): 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