[Updated] D10823: dirstate-tree: Fix status algorithm with unreadable directory

SimonSapin phabricator at mercurial-scm.org
Tue Jun 1 19:35:52 UTC 2021


Closed by commit rHG5e12b6bfdd3e: dirstate-tree: Fix status algorithm with unreadable directory (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10823?vs=28349&id=28356

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10823/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D10823

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/status.rs
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -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
diff --git a/rust/hg-core/src/dirstate_tree/status.rs b/rust/hg-core/src/dirstate_tree/status.rs
--- a/rust/hg-core/src/dirstate_tree/status.rs
+++ b/rust/hg-core/src/dirstate_tree/status.rs
@@ -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:



To: SimonSapin, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210601/42721484/attachment-0002.html>


More information about the Mercurial-patches mailing list