changeset 51654:c0e30a019ce1 stable

mmap: only use mmap to read rev-branch-cache data if it is safe Cf `is_mmap_safe` docstring.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 03 Jul 2024 12:31:21 +0200
parents d6c895e4adc4
children 8e24f4f86ba8
files mercurial/branchmap.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Wed Jul 03 12:26:57 2024 +0200
+++ b/mercurial/branchmap.py	Wed Jul 03 12:31:21 2024 +0200
@@ -1213,11 +1213,12 @@
 
         if self._names:
             try:
-                if repo.ui.configbool(b'storage', b'revbranchcache.mmap'):
-                    with repo.cachevfs(_rbcrevs) as fp:
+                usemmap = repo.ui.configbool(b'storage', b'revbranchcache.mmap')
+                with repo.cachevfs(_rbcrevs) as fp:
+                    if usemmap and repo.cachevfs.is_mmap_safe(_rbcrevs):
                         data = util.buffer(util.mmapread(fp))
-                else:
-                    data = repo.cachevfs.read(_rbcrevs)
+                    else:
+                        data = fp.read()
                 self._rbcrevs = rbcrevs(data)
             except (IOError, OSError) as inst:
                 repo.ui.debug(