comparison rust/hg-core/src/dirstate_tree/status.rs @ 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 79b2c98ab7b4
comparison
equal deleted inserted replaced
49141:126d253eb274 49142:c4ccd0346f5c
11 use crate::utils::files::get_bytes_from_os_string; 11 use crate::utils::files::get_bytes_from_os_string;
12 use crate::utils::files::get_path_from_bytes; 12 use crate::utils::files::get_path_from_bytes;
13 use crate::utils::hg_path::HgPath; 13 use crate::utils::hg_path::HgPath;
14 use crate::BadMatch; 14 use crate::BadMatch;
15 use crate::DirstateStatus; 15 use crate::DirstateStatus;
16 use crate::EntryState;
17 use crate::HgPathBuf; 16 use crate::HgPathBuf;
18 use crate::HgPathCow; 17 use crate::HgPathCow;
19 use crate::PatternFileWarning; 18 use crate::PatternFileWarning;
20 use crate::StatusError; 19 use crate::StatusError;
21 use crate::StatusOptions; 20 use crate::StatusOptions;
457 fs_metadata, 456 fs_metadata,
458 dirstate_node, 457 dirstate_node,
459 )? 458 )?
460 } else { 459 } else {
461 if file_or_symlink && self.matcher.matches(hg_path) { 460 if file_or_symlink && self.matcher.matches(hg_path) {
462 if let Some(state) = dirstate_node.state()? { 461 if let Some(entry) = dirstate_node.entry()? {
463 match state { 462 if !entry.any_tracked() {
464 EntryState::Added => { 463 // Forward-compat if we start tracking unknown/ignored
465 self.push_outcome(Outcome::Added, &dirstate_node)? 464 // files for caching reasons
466 } 465 self.mark_unknown_or_ignored(
467 EntryState::Removed => self 466 has_ignored_ancestor,
468 .push_outcome(Outcome::Removed, &dirstate_node)?, 467 hg_path,
469 EntryState::Merged => self 468 );
470 .push_outcome(Outcome::Modified, &dirstate_node)?, 469 }
471 EntryState::Normal => self 470 if entry.added() {
472 .handle_normal_file(&dirstate_node, fs_metadata)?, 471 self.push_outcome(Outcome::Added, &dirstate_node)?;
472 } else if entry.removed() {
473 self.push_outcome(Outcome::Removed, &dirstate_node)?;
474 } else if entry.modified() {
475 self.push_outcome(Outcome::Modified, &dirstate_node)?;
476 } else {
477 self.handle_normal_file(&dirstate_node, fs_metadata)?;
473 } 478 }
474 } else { 479 } else {
475 // `node.entry.is_none()` indicates a "directory" 480 // `node.entry.is_none()` indicates a "directory"
476 // node, but the filesystem has a file 481 // node, but the filesystem has a file
477 self.mark_unknown_or_ignored( 482 self.mark_unknown_or_ignored(
577 .push((hg_path, directory_mtime)) 582 .push((hg_path, directory_mtime))
578 } 583 }
579 Ok(()) 584 Ok(())
580 } 585 }
581 586
582 /// A file with `EntryState::Normal` in the dirstate was found in the 587 /// A file that is clean in the dirstate was found in the filesystem
583 /// filesystem
584 fn handle_normal_file( 588 fn handle_normal_file(
585 &self, 589 &self,
586 dirstate_node: &NodeRef<'tree, 'on_disk>, 590 dirstate_node: &NodeRef<'tree, 'on_disk>,
587 fs_metadata: &std::fs::Metadata, 591 fs_metadata: &std::fs::Metadata,
588 ) -> Result<(), DirstateV2ParseError> { 592 ) -> Result<(), DirstateV2ParseError> {