rhg: fix race when a fixup file is deleted on disk stable
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 27 Feb 2023 15:18:50 +0100
branchstable
changeset 50225 53ca3e3bc013
parent 50224 e30b9e43be7e
child 50226 8fcd5302243a
rhg: fix race when a fixup file is deleted on disk See next changeset for the other race in the same kind of logic and why there are two different places.
rust/rhg/src/commands/status.rs
tests/test-dirstate-status-write-race.t
--- a/rust/rhg/src/commands/status.rs	Sat Feb 25 06:11:14 2023 +0100
+++ b/rust/rhg/src/commands/status.rs	Mon Feb 27 15:18:50 2023 +0100
@@ -436,9 +436,21 @@
                     // `unsure_is_clean` which was needed before reading
                     // contents. Here we access metadata again after reading
                     // content, in case it changed in the meantime.
-                    let fs_metadata = repo
+                    let metadata_res = repo
                         .working_directory_vfs()
-                        .symlink_metadata(&fs_path)?;
+                        .symlink_metadata(&fs_path);
+                    let fs_metadata = match metadata_res {
+                        Ok(meta) => meta,
+                        Err(err) => match err {
+                            HgError::IoError { .. } => {
+                                // The file has probably been deleted. In any
+                                // case, it was in the dirstate before, so
+                                // let's ignore the error.
+                                continue;
+                            }
+                            _ => return Err(err.into()),
+                        },
+                    };
                     if let Some(mtime) =
                         TruncatedTimestamp::for_reliable_mtime_of(
                             &fs_metadata,
--- a/tests/test-dirstate-status-write-race.t	Sat Feb 25 06:11:14 2023 +0100
+++ b/tests/test-dirstate-status-write-race.t	Mon Feb 27 15:18:50 2023 +0100
@@ -382,7 +382,6 @@
   ? p
   ? q
   $ cat $TESTTMP/status-race-lock.log
-  abort: when reading $TESTTMP/race-with-update/dir2/k: $ENOENT$ (known-bad-output rhg !)
 
 final cleanup
 
@@ -479,7 +478,6 @@
   ? p
   ? q
   $ cat $TESTTMP/status-race-lock.log
-  abort: when reading $TESTTMP/race-with-remove/dir2/l: $ENOENT$ (known-bad-output rhg !)
 
 final cleanup