Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 51650:d6c895e4adc4 stable
mmap: only use mmap to read revlog index if it is safe
Cf `is_mmap_safe` docstring.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 03 Jul 2024 12:26:57 +0200 |
parents | 1721d983dd6d |
children | df6ce326936f |
comparison
equal
deleted
inserted
replaced
51649:ba205f944cb4 | 51650:d6c895e4adc4 |
---|---|
1458 If the file is missing return the empty string""" | 1458 If the file is missing return the empty string""" |
1459 try: | 1459 try: |
1460 with self.opener(filepath) as fp: | 1460 with self.opener(filepath) as fp: |
1461 if mmap_threshold is not None: | 1461 if mmap_threshold is not None: |
1462 file_size = self.opener.fstat(fp).st_size | 1462 file_size = self.opener.fstat(fp).st_size |
1463 if file_size >= mmap_threshold: | 1463 if ( |
1464 file_size >= mmap_threshold | |
1465 and self.opener.is_mmap_safe(filepath) | |
1466 ): | |
1464 if size is not None: | 1467 if size is not None: |
1465 # avoid potentiel mmap crash | 1468 # avoid potentiel mmap crash |
1466 size = min(file_size, size) | 1469 size = min(file_size, size) |
1467 # TODO: should .close() to release resources without | 1470 # TODO: should .close() to release resources without |
1468 # relying on Python GC | 1471 # relying on Python GC |