mmap: only use mmap to read revlog persistent nodemap if it is safe
Cf `is_mmap_safe` docstring.
--- a/mercurial/revlogutils/nodemap.py Wed Jul 03 12:47:08 2024 +0200
+++ b/mercurial/revlogutils/nodemap.py Wed Jul 03 12:32:57 2024 +0200
@@ -74,7 +74,7 @@
test_race_hook_1()
try:
with revlog.opener(filename) as fd:
- if use_mmap:
+ if use_mmap and revlog.opener.is_mmap_safe(filename):
try:
data = util.buffer(util.mmapread(fd, data_length))
except ValueError:
@@ -205,7 +205,7 @@
fd.seek(target_docket.data_length)
fd.write(data)
if feed_data:
- if use_mmap:
+ if use_mmap and revlog.opener.is_mmap_safe(datafile):
fd.flush()
new_data = util.buffer(util.mmapread(fd, new_length))
else:
@@ -238,7 +238,7 @@
with revlog.opener(datafile, b'w+') as fd:
fd.write(data)
if feed_data:
- if use_mmap:
+ if use_mmap and revlog.opener.is_mmap_safe(datafile):
fd.flush()
new_data = util.buffer(util.mmapread(fd, len(data)))
else: