Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 51651: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 | f02ec1ecb3bf |
children | f4733654f144 |
comparison
equal
deleted
inserted
replaced
51650:d6c895e4adc4 | 51651:c0e30a019ce1 |
---|---|
1211 # don't try to use cache - fall back to the slow path | 1211 # don't try to use cache - fall back to the slow path |
1212 self.branchinfo = self._branchinfo | 1212 self.branchinfo = self._branchinfo |
1213 | 1213 |
1214 if self._names: | 1214 if self._names: |
1215 try: | 1215 try: |
1216 if repo.ui.configbool(b'storage', b'revbranchcache.mmap'): | 1216 usemmap = repo.ui.configbool(b'storage', b'revbranchcache.mmap') |
1217 with repo.cachevfs(_rbcrevs) as fp: | 1217 with repo.cachevfs(_rbcrevs) as fp: |
1218 if usemmap and repo.cachevfs.is_mmap_safe(_rbcrevs): | |
1218 data = util.buffer(util.mmapread(fp)) | 1219 data = util.buffer(util.mmapread(fp)) |
1219 else: | 1220 else: |
1220 data = repo.cachevfs.read(_rbcrevs) | 1221 data = fp.read() |
1221 self._rbcrevs = rbcrevs(data) | 1222 self._rbcrevs = rbcrevs(data) |
1222 except (IOError, OSError) as inst: | 1223 except (IOError, OSError) as inst: |
1223 repo.ui.debug( | 1224 repo.ui.debug( |
1224 b"couldn't read revision branch cache: %s\n" | 1225 b"couldn't read revision branch cache: %s\n" |
1225 % stringutil.forcebytestr(inst) | 1226 % stringutil.forcebytestr(inst) |