Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/nodemap.py @ 46971:a3720569a43f
nodemap: deal with data mmap error
If the file is too small, the mmapread call would raise a ValueError. We catch
that and ignore nodemap content (as we do without mmap). This make the repository
slightly slower (until the next write) but usable. Unlike the current crash.
Differential Revision: https://phab.mercurial-scm.org/D10458
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 16 Apr 2021 15:39:00 +0200 |
parents | e2f7b2695ba1 |
children | f38bf44e077f |
comparison
equal
deleted
inserted
replaced
46970:99aed233aa8d | 46971:a3720569a43f |
---|---|
51 filename = _rawdata_filepath(revlog, docket) | 51 filename = _rawdata_filepath(revlog, docket) |
52 use_mmap = revlog.opener.options.get(b"persistent-nodemap.mmap") | 52 use_mmap = revlog.opener.options.get(b"persistent-nodemap.mmap") |
53 try: | 53 try: |
54 with revlog.opener(filename) as fd: | 54 with revlog.opener(filename) as fd: |
55 if use_mmap: | 55 if use_mmap: |
56 data = util.buffer(util.mmapread(fd, data_length)) | 56 try: |
57 data = util.buffer(util.mmapread(fd, data_length)) | |
58 except ValueError: | |
59 # raised when the read file is too small | |
60 data = b'' | |
57 else: | 61 else: |
58 data = fd.read(data_length) | 62 data = fd.read(data_length) |
59 except (IOError, OSError) as e: | 63 except (IOError, OSError) as e: |
60 if e.errno == errno.ENOENT: | 64 if e.errno == errno.ENOENT: |
61 return None | 65 return None |