Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/nodemap.py @ 44338:2ea6a67ff502
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
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 15 Jan 2020 15:50:43 +0100 |
parents | 1d2b37def017 |
children | c7eebdb15139 |
comparison
equal
deleted
inserted
replaced
44337:1d2b37def017 | 44338:2ea6a67ff502 |
---|---|
90 data = None | 90 data = None |
91 else: | 91 else: |
92 datafile = _rawdata_filepath(revlog, target_docket) | 92 datafile = _rawdata_filepath(revlog, target_docket) |
93 # EXP-TODO: if this is a cache, this should use a cache vfs, not a | 93 # EXP-TODO: if this is a cache, this should use a cache vfs, not a |
94 # store vfs | 94 # store vfs |
95 with revlog.opener(datafile, b'a') as fd: | 95 with revlog.opener(datafile, b'r+') as fd: |
96 fd.seek(target_docket.data_length) | |
96 fd.write(data) | 97 fd.write(data) |
97 target_docket.data_length += len(data) | 98 target_docket.data_length += len(data) |
98 target_docket.data_unused += data_changed_count | 99 target_docket.data_unused += data_changed_count |
99 | 100 |
100 if data is None: | 101 if data is None: |