# HG changeset patch # User Simon Sapin # Date 1622196974 -7200 # Node ID 5e12b6bfdd3ecc137dc7d8d4efe278433884846f # Parent 710435a5c4697e4aec92b3f97c147cf02eab6cc7 dirstate-tree: Fix status algorithm with unreadable directory When reading a directory fails such as because of insufficient permissions, it should be treated as empty by status instead of skipped entirely. Differential Revision: https://phab.mercurial-scm.org/D10823 diff -r 710435a5c469 -r 5e12b6bfdd3e rust/hg-core/src/dirstate_tree/status.rs --- a/rust/hg-core/src/dirstate_tree/status.rs Tue May 25 16:46:32 2021 -0700 +++ b/rust/hg-core/src/dirstate_tree/status.rs Fri May 28 12:16:14 2021 +0200 @@ -141,7 +141,10 @@ ) { entries } else { - return Ok(()); + // Treat an unreadable directory (typically because of insufficient + // permissions) like an empty directory. `self.read_dir` has + // already called `self.io_error` so a warning will be emitted. + Vec::new() }; // `merge_join_by` requires both its input iterators to be sorted: diff -r 710435a5c469 -r 5e12b6bfdd3e tests/test-status.t --- a/tests/test-status.t Tue May 25 16:46:32 2021 -0700 +++ b/tests/test-status.t Fri May 28 12:16:14 2021 +0200 @@ -837,6 +837,23 @@ yet by the Rust implementation of status, but includematcher is supported. --include is used below for that reason +#if unix-permissions + +Not having permission to read a directory that contains tracked files makes +status emit a warning then behave as if the directory was empty or removed +entirely: + + $ chmod 0 subdir + $ hg status --include subdir + subdir: Permission denied + R subdir/removed + ! subdir/clean + ! subdir/deleted + ! subdir/modified + $ chmod 755 subdir + +#endif + Remove a directory that contains tracked files $ rm -r subdir