changeset 44743:a467416c493c stable

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
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 23 Apr 2020 09:59:38 +0200
parents d8b703b8bf70
children e58422afbc74 f365dfede78f
files rust/hg-core/src/dirstate/status.rs tests/test-status.t
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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