mmap: only use mmap to read revlog index if it is safe
Cf `is_mmap_safe` docstring.
--- a/mercurial/revlog.py Wed Jul 03 12:22:48 2024 +0200
+++ b/mercurial/revlog.py Wed Jul 03 12:26:57 2024 +0200
@@ -1460,7 +1460,10 @@
with self.opener(filepath) as fp:
if mmap_threshold is not None:
file_size = self.opener.fstat(fp).st_size
- if file_size >= mmap_threshold:
+ if (
+ file_size >= mmap_threshold
+ and self.opener.is_mmap_safe(filepath)
+ ):
if size is not None:
# avoid potentiel mmap crash
size = min(file_size, size)
--- a/tests/test-revlog-mmapindex.t Wed Jul 03 12:22:48 2024 +0200
+++ b/tests/test-revlog-mmapindex.t Wed Jul 03 12:26:57 2024 +0200
@@ -37,7 +37,7 @@
mmap index which is now more than 4k long
$ hg log -l 5 -T '{rev}\n' --config experimental.mmapindexthreshold=4k
- mmapping $TESTTMP/a/.hg/store/00changelog.i
+ mmapping $TESTTMP/a/.hg/store/00changelog.i (no-pure !)
mmapping $TESTTMP/a/.hg/store/00changelog-????????.nd (glob) (rust !)
100
99