Mercurial > hg
comparison rust/hg-core/src/dirstate/status.rs @ 46890:441024b279a6
rust: Remove the compile-time 'dirstate-tree' feature flag
This code has compiler errors since it is not built on CI and nobody has been
working on it for some time.
We (Octobus) are still pursuing status optimizations based on a tree data
structure for the dirstate, but upcoming patches will use a run-time opt-in
instead of compile-time, so that at least corresponding Rust code keeps
compiling when other changes are made.
Differential Revision: https://phab.mercurial-scm.org/D10329
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 08 Apr 2021 21:46:54 +0200 |
parents | 3c9ddb1986a9 |
children | 787ff5d21bcd c8f62920f07a |
comparison
equal
deleted
inserted
replaced
46889:8759e22f1649 | 46890:441024b279a6 |
---|---|
7 | 7 |
8 //! Rust implementation of dirstate.status (dirstate.py). | 8 //! Rust implementation of dirstate.status (dirstate.py). |
9 //! It is currently missing a lot of functionality compared to the Python one | 9 //! It is currently missing a lot of functionality compared to the Python one |
10 //! and will only be triggered in narrow cases. | 10 //! and will only be triggered in narrow cases. |
11 | 11 |
12 #[cfg(feature = "dirstate-tree")] | |
13 use crate::dirstate::dirstate_tree::iter::StatusShortcut; | |
14 #[cfg(not(feature = "dirstate-tree"))] | |
15 use crate::utils::path_auditor::PathAuditor; | 12 use crate::utils::path_auditor::PathAuditor; |
16 use crate::{ | 13 use crate::{ |
17 dirstate::SIZE_FROM_OTHER_PARENT, | 14 dirstate::SIZE_FROM_OTHER_PARENT, |
18 filepatterns::PatternFileWarning, | 15 filepatterns::PatternFileWarning, |
19 matchers::{get_ignore_function, Matcher, VisitChildrenSet}, | 16 matchers::{get_ignore_function, Matcher, VisitChildrenSet}, |
701 | 698 |
702 /// Add the files in the dirstate to the results. | 699 /// Add the files in the dirstate to the results. |
703 /// | 700 /// |
704 /// This takes a mutable reference to the results to account for the | 701 /// This takes a mutable reference to the results to account for the |
705 /// `extend` in timings | 702 /// `extend` in timings |
706 #[cfg(feature = "dirstate-tree")] | |
707 #[timed] | |
708 pub fn extend_from_dmap(&self, results: &mut Vec<DispatchedPath<'a>>) { | |
709 results.par_extend( | |
710 self.dmap | |
711 .fs_iter(self.root_dir.clone()) | |
712 .par_bridge() | |
713 .filter(|(path, _)| self.matcher.matches(path)) | |
714 .map(move |(filename, shortcut)| { | |
715 let entry = match shortcut { | |
716 StatusShortcut::Entry(e) => e, | |
717 StatusShortcut::Dispatch(d) => { | |
718 return (Cow::Owned(filename), d) | |
719 } | |
720 }; | |
721 let filename_as_path = match hg_path_to_path_buf(&filename) | |
722 { | |
723 Ok(f) => f, | |
724 Err(_) => { | |
725 return ( | |
726 Cow::Owned(filename), | |
727 INVALID_PATH_DISPATCH, | |
728 ) | |
729 } | |
730 }; | |
731 let meta = self | |
732 .root_dir | |
733 .join(filename_as_path) | |
734 .symlink_metadata(); | |
735 | |
736 match meta { | |
737 Ok(m) | |
738 if !(m.file_type().is_file() | |
739 || m.file_type().is_symlink()) => | |
740 { | |
741 ( | |
742 Cow::Owned(filename), | |
743 dispatch_missing(entry.state), | |
744 ) | |
745 } | |
746 Ok(m) => { | |
747 let dispatch = dispatch_found( | |
748 &filename, | |
749 entry, | |
750 HgMetadata::from_metadata(m), | |
751 &self.dmap.copy_map, | |
752 self.options, | |
753 ); | |
754 (Cow::Owned(filename), dispatch) | |
755 } | |
756 Err(e) | |
757 if e.kind() == ErrorKind::NotFound | |
758 || e.raw_os_error() == Some(20) => | |
759 { | |
760 // Rust does not yet have an `ErrorKind` for | |
761 // `NotADirectory` (errno 20) | |
762 // It happens if the dirstate contains `foo/bar` | |
763 // and foo is not a | |
764 // directory | |
765 ( | |
766 Cow::Owned(filename), | |
767 dispatch_missing(entry.state), | |
768 ) | |
769 } | |
770 Err(e) => { | |
771 (Cow::Owned(filename), dispatch_os_error(&e)) | |
772 } | |
773 } | |
774 }), | |
775 ); | |
776 } | |
777 | |
778 /// Add the files in the dirstate to the results. | |
779 /// | |
780 /// This takes a mutable reference to the results to account for the | |
781 /// `extend` in timings | |
782 #[cfg(not(feature = "dirstate-tree"))] | |
783 #[timed] | 703 #[timed] |
784 pub fn extend_from_dmap(&self, results: &mut Vec<DispatchedPath<'a>>) { | 704 pub fn extend_from_dmap(&self, results: &mut Vec<DispatchedPath<'a>>) { |
785 results.par_extend( | 705 results.par_extend( |
786 self.dmap | 706 self.dmap |
787 .par_iter() | 707 .par_iter() |
848 /// working directory traversal. This means that the rest must | 768 /// working directory traversal. This means that the rest must |
849 /// be either ignored, under a symlink or under a new nested repo. | 769 /// be either ignored, under a symlink or under a new nested repo. |
850 /// | 770 /// |
851 /// This takes a mutable reference to the results to account for the | 771 /// This takes a mutable reference to the results to account for the |
852 /// `extend` in timings | 772 /// `extend` in timings |
853 #[cfg(not(feature = "dirstate-tree"))] | |
854 #[timed] | 773 #[timed] |
855 pub fn handle_unknowns(&self, results: &mut Vec<DispatchedPath<'a>>) { | 774 pub fn handle_unknowns(&self, results: &mut Vec<DispatchedPath<'a>>) { |
856 let to_visit: Vec<(&HgPath, &DirstateEntry)> = | 775 let to_visit: Vec<(&HgPath, &DirstateEntry)> = |
857 if results.is_empty() && self.matcher.matches_everything() { | 776 if results.is_empty() && self.matcher.matches_everything() { |
858 self.dmap.iter().map(|(f, e)| (f.deref(), e)).collect() | 777 self.dmap.iter().map(|(f, e)| (f.deref(), e)).collect() |