If we are to use mmap to read the nodemap data, and if the python code is
responsible for the IO, we need to refresh the mmap after each write and provide
it back to the index.
We start this dance without the mmap first.
hg-reviewers |
If we are to use mmap to read the nodemap data, and if the python code is
responsible for the IO, we need to refresh the mmap after each write and provide
it back to the index.
We start this dance without the mmap first.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/revlogutils/nodemap.py (6 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
e278a94259d8 | 80d015f9a9ed | Pierre-Yves David | Jan 15 2020, 9:51 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute |
data = None | data = None | ||||
else: | else: | ||||
datafile = _rawdata_filepath(revlog, target_docket) | datafile = _rawdata_filepath(revlog, target_docket) | ||||
# EXP-TODO: if this is a cache, this should use a cache vfs, not a | # EXP-TODO: if this is a cache, this should use a cache vfs, not a | ||||
# store vfs | # store vfs | ||||
with revlog.opener(datafile, 'r+') as fd: | with revlog.opener(datafile, 'r+') as fd: | ||||
fd.seek(target_docket.data_length) | fd.seek(target_docket.data_length) | ||||
fd.write(data) | fd.write(data) | ||||
fd.seek(0) | |||||
new_data = fd.read(target_docket.data_length + len(data)) | |||||
target_docket.data_length += len(data) | target_docket.data_length += len(data) | ||||
target_docket.data_unused += data_changed_count | target_docket.data_unused += data_changed_count | ||||
if data is None: | if data is None: | ||||
# otherwise fallback to a full new export | # otherwise fallback to a full new export | ||||
target_docket = NodeMapDocket() | target_docket = NodeMapDocket() | ||||
datafile = _rawdata_filepath(revlog, target_docket) | datafile = _rawdata_filepath(revlog, target_docket) | ||||
if util.safehasattr(revlog.index, "nodemap_data_all"): | if util.safehasattr(revlog.index, "nodemap_data_all"): | ||||
data = revlog.index.nodemap_data_all() | data = revlog.index.nodemap_data_all() | ||||
else: | else: | ||||
data = persistent_data(revlog.index) | data = persistent_data(revlog.index) | ||||
# EXP-TODO: if this is a cache, this should use a cache vfs, not a | # EXP-TODO: if this is a cache, this should use a cache vfs, not a | ||||
# store vfs | # store vfs | ||||
new_data = data | |||||
with revlog.opener(datafile, 'w') as fd: | with revlog.opener(datafile, 'w') as fd: | ||||
fd.write(data) | fd.write(data) | ||||
target_docket.data_length = len(data) | target_docket.data_length = len(data) | ||||
target_docket.tip_rev = revlog.tiprev() | target_docket.tip_rev = revlog.tiprev() | ||||
# EXP-TODO: if this is a cache, this should use a cache vfs, not a | # EXP-TODO: if this is a cache, this should use a cache vfs, not a | ||||
# store vfs | # store vfs | ||||
with revlog.opener(revlog.nodemap_file, 'w', atomictemp=True) as fp: | with revlog.opener(revlog.nodemap_file, 'w', atomictemp=True) as fp: | ||||
fp.write(target_docket.serialize()) | fp.write(target_docket.serialize()) | ||||
revlog._nodemap_docket = target_docket | revlog._nodemap_docket = target_docket | ||||
if util.safehasattr(revlog.index, "update_nodemap_data"): | |||||
revlog.index.update_nodemap_data(target_docket, new_data) | |||||
# EXP-TODO: if the transaction abort, we should remove the new data and | # EXP-TODO: if the transaction abort, we should remove the new data and | ||||
# reinstall the old one. | # reinstall the old one. | ||||
# search for old index file in all cases, some older process might have | # search for old index file in all cases, some older process might have | ||||
# left one behind. | # left one behind. | ||||
olds = _other_rawdata_filepath(revlog, target_docket) | olds = _other_rawdata_filepath(revlog, target_docket) | ||||
if olds: | if olds: | ||||
realvfs = getattr(revlog, '_realopener', revlog.opener) | realvfs = getattr(revlog, '_realopener', revlog.opener) |