From patchwork Tue Apr 12 16:07:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D12540: rust-status: stop using `state()` in the dispatch logic From: phabricator X-Patchwork-Id: 50888 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 12 Apr 2022 16:07:18 +0000 Alphare created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Let's use the new API. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12540 AFFECTED FILES rust/hg-core/src/dirstate_tree/status.rs CHANGE DETAILS To: Alphare, #hg-reviewers Cc: mercurial-patches, mercurial-devel 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 @@ -13,7 +13,6 @@ use crate::utils::hg_path::HgPath; use crate::BadMatch; use crate::DirstateStatus; -use crate::EntryState; use crate::HgPathBuf; use crate::HgPathCow; use crate::PatternFileWarning; @@ -459,17 +458,23 @@ )? } else { if file_or_symlink && self.matcher.matches(hg_path) { - if let Some(state) = dirstate_node.state()? { - match state { - EntryState::Added => { - self.push_outcome(Outcome::Added, &dirstate_node)? - } - EntryState::Removed => self - .push_outcome(Outcome::Removed, &dirstate_node)?, - EntryState::Merged => self - .push_outcome(Outcome::Modified, &dirstate_node)?, - EntryState::Normal => self - .handle_normal_file(&dirstate_node, fs_metadata)?, + if let Some(entry) = dirstate_node.entry()? { + if !entry.any_tracked() { + // Forward-compat if we start tracking unknown/ignored + // files for caching reasons + self.mark_unknown_or_ignored( + has_ignored_ancestor, + hg_path, + ); + } + if entry.added() { + self.push_outcome(Outcome::Added, &dirstate_node)?; + } else if entry.removed() { + self.push_outcome(Outcome::Removed, &dirstate_node)?; + } else if entry.modified() { + self.push_outcome(Outcome::Modified, &dirstate_node)?; + } else { + self.handle_normal_file(&dirstate_node, fs_metadata)?; } } else { // `node.entry.is_none()` indicates a "directory" @@ -579,8 +584,7 @@ Ok(()) } - /// A file with `EntryState::Normal` in the dirstate was found in the - /// filesystem + /// A file that is clean in the dirstate was found in the filesystem fn handle_normal_file( &self, dirstate_node: &NodeRef<'tree, 'on_disk>,