Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 51649:ba205f944cb4 stable
mmap: add a `is_mmap_safe` method to vfs
This will be useful to safeguard mmap usage to void SIGBUS when repositories
lives on a NFS drive.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 03 Jul 2024 12:22:48 +0200 |
parents | 59f846fbc11d |
children | 522b4d729e89 |
comparison
equal
deleted
inserted
replaced
51648:5b803e5c1325 | 51649:ba205f944cb4 |
---|---|
439 | 439 |
440 return data | 440 return data |
441 | 441 |
442 | 442 |
443 def mmapread(fp, size=None): | 443 def mmapread(fp, size=None): |
444 """Read a file content using mmap | |
445 | |
446 The responsability of checking the file system is mmap safe is the | |
447 responsability of the caller. | |
448 | |
449 In some case, a normal string might be returned. | |
450 """ | |
444 if size == 0: | 451 if size == 0: |
445 # size of 0 to mmap.mmap() means "all data" | 452 # size of 0 to mmap.mmap() means "all data" |
446 # rather than "zero bytes", so special case that. | 453 # rather than "zero bytes", so special case that. |
447 return b'' | 454 return b'' |
448 elif size is None: | 455 elif size is None: |