( )⚙ D11230 rhg: Propagate permission errors when finding a repository

This is an archive of the discontinued Mercurial Phabricator instance.

rhg: Propagate permission errors when finding a repository

Authored by SimonSapin on Jul 29 2021, 6:22 AM.



The Rust standard library has a Path::is_dir method that returns false
for any I/O error (such as a permission error),
not just "No such file or directory".

Instead add an is_dir function that returns false for non-directories
and for "No such file or directory" errors, but propagates other I/O errors.

Diff Detail

rHG Mercurial
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

SimonSapin created this revision.Jul 29 2021, 6:22 AM

This should not be merged as-is: some tests fail because this function returns an error if an ancestor of the given path is not a directory. We’d want to handle that case like "not found" errors instead, but https://doc.rust-lang.org/nightly/std/io/enum.ErrorKind.html#variant.NotADirectory is not stable yet (and does not exist at all in 1.41)

baymax updated this revision to Diff 29738.Jul 29 2021, 2:34 PM

✅ refresh by Heptapod after a successful CI run (🐙 💚)
⚠ This patch is intended for stable ⚠

I’ve changed this to only propagate permission errors specifically, for now. This seems to be the one that’s somewhat likely to happen, from possible errors listed in man 2 stat.

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.