# HG changeset patch # User Pierre-Yves David # Date 2024-07-03 10:31:21 # Node ID c0e30a019ce14dedf4cee41146ee85a7e82e8c9b # Parent d6c895e4adc4fdd756337446954e370eddc79ff9 mmap: only use mmap to read rev-branch-cache data if it is safe Cf `is_mmap_safe` docstring. diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -1213,11 +1213,12 @@ class revbranchcache: 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(