rust-status: check for '.hg' regardless of file type (issue6300) stable
authorRaphaël Gomès <rgomes@octobus.net>
Thu, 23 Apr 2020 09:59:38 +0200
branchstable
changeset 44748 a467416c493c
parent 44747 d8b703b8bf70
child 44757 f365dfede78f
child 44759 e58422afbc74
rust-status: check for '.hg' regardless of file type (issue6300) '.hg' would show up in `hg status` if were a symlink. Differential Revision: https://phab.mercurial-scm.org/D8461
rust/hg-core/src/dirstate/status.rs
tests/test-status.t
--- a/rust/hg-core/src/dirstate/status.rs	Mon Apr 20 11:03:31 2020 +0200
+++ b/rust/hg-core/src/dirstate/status.rs	Thu Apr 23 09:59:38 2020 +0200
@@ -323,6 +323,11 @@
     let file_type = dir_entry.file_type()?;
     let entry_option = dmap.get(&filename);
 
+    if filename.as_bytes() == b".hg" {
+        // Could be a directory or a symlink
+        return Ok(());
+    }
+
     if file_type.is_dir() {
         handle_traversed_dir(
             scope,
@@ -446,9 +451,7 @@
     options: StatusOptions,
 ) -> IoResult<()> {
     let directory = directory.as_ref();
-    if directory.as_bytes() == b".hg" {
-        return Ok(());
-    }
+
     let visit_entries = match matcher.visit_children_set(directory) {
         VisitChildrenSet::Empty => return Ok(()),
         VisitChildrenSet::This | VisitChildrenSet::Recursive => None,
--- a/tests/test-status.t	Mon Apr 20 11:03:31 2020 +0200
+++ b/tests/test-status.t	Thu Apr 23 09:59:38 2020 +0200
@@ -672,3 +672,11 @@
   
 
   $ cd ..
+
+Make sure .hg doesn't show up even as a symlink
+
+  $ hg init repo0
+  $ mkdir symlink-repo0
+  $ cd symlink-repo0
+  $ ln -s ../repo0/.hg
+  $ hg status