Mercurial > hg
changeset 49142:c4ccd0346f5c
rust-status: stop using `state()` in the dispatch logic
Let's use the new API.
Differential Revision: https://phab.mercurial-scm.org/D12540
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Tue, 12 Apr 2022 17:35:02 +0200 |
parents | 126d253eb274 |
children | e55ce61891e3 |
files | rust/hg-core/src/dirstate_tree/status.rs |
diffstat | 1 files changed, 18 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/status.rs Tue Apr 12 17:34:18 2022 +0200 +++ b/rust/hg-core/src/dirstate_tree/status.rs Tue Apr 12 17:35:02 2022 +0200 @@ -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>,