Mercurial > hg
changeset 46089:8ff2d8359d0f
persistent-nodemap: properly ignore non-existent `.nd` data file
This code was meant to handle the case of a nodemap docket file
pointing to a nodemap data file that doesn’t exist (anymore),
but most likely caused an `UnboundLocalError` exception instead
when `data` was used on the next line without being defined.
This case is theoretically possible with a race condition
between two hg processes, but is hard to reproduce or test:
* Process A reads a docket file and finds a UID in it
that points to a given data file name.
* Process B decides that this same data file needs compacting.
It writes a new one with a different UID,
overwrites the docket file,
then removes the old data file.
* Only then process A tries to a open a file that doesn’t exist anymore.
Differential Revision: https://phab.mercurial-scm.org/D9533
author | Simon Sapin <simon-commits@exyr.org> |
---|---|
date | Mon, 07 Dec 2020 18:06:53 +0100 |
parents | 8837498ae6e0 |
children | 9eb07ab3f2d4 |
files | mercurial/revlogutils/nodemap.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py Wed Dec 09 18:51:52 2020 -0800 +++ b/mercurial/revlogutils/nodemap.py Mon Dec 07 18:06:53 2020 +0100 @@ -58,7 +58,9 @@ else: data = fd.read(data_length) except OSError as e: - if e.errno != errno.ENOENT: + if e.errno == errno.ENOENT: + return None + else: raise if len(data) < data_length: return None