Patchwork D8461: rust-status: check for '.hg' regardless of file type (issue6300)

login
register
mail settings
Submitter phabricator
Date April 23, 2020, 9:21 p.m.
Message ID <995029a6584a5b75e8a741415a81537c@localhost.localdomain>
Download mbox | patch
Permalink /patch/46228/
State Not Applicable
Headers show

Comments

phabricator - April 23, 2020, 9:21 p.m.
Closed by commit rHGa467416c493c: rust-status: check for &#039;.hg&#039; regardless of file type (issue6300) (authored by Alphare).
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/D8461?vs=21182&id=21206

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

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

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

CHANGE DETAILS




To: Alphare, #hg-reviewers, marmoute
Cc: mercurial-patches, mercurial-devel

Patch

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