[Request] [+- ] D10908: status: Move some `is_ignored` computation earlier
SimonSapin
phabricator at mercurial-scm.org
Thu Jun 24 20:52:32 UTC 2021
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This refactor should make have no observable behavior difference, it will make
an upcoming changeset easier.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10908
AFFECTED FILES
rust/hg-core/src/dirstate_tree/status.rs
CHANGE DETAILS
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
@@ -307,11 +307,12 @@
Left(dirstate_node) => {
self.traverse_dirstate_only(dirstate_node)?
}
- Right(fs_entry) => self.traverse_fs_only(
- has_ignored_ancestor,
- directory_hg_path,
- fs_entry,
- ),
+ Right(fs_entry) => {
+ let hg_path = directory_hg_path.join(&fs_entry.base_name);
+ let is_ignored =
+ has_ignored_ancestor || (self.ignore_fn)(&hg_path);
+ self.traverse_fs_only(is_ignored, hg_path, fs_entry);
+ }
}
Ok(is_fs_only)
})
@@ -394,7 +395,9 @@
} else {
// `node.entry.is_none()` indicates a "directory"
// node, but the filesystem has a file
- self.mark_unknown_or_ignored(has_ignored_ancestor, hg_path)
+ let is_ignored =
+ has_ignored_ancestor || (self.ignore_fn)(&hg_path);
+ self.mark_unknown_or_ignored(is_ignored, hg_path)
}
}
@@ -586,16 +589,13 @@
/// Something in the filesystem has no corresponding dirstate node
fn traverse_fs_only(
&self,
- has_ignored_ancestor: bool,
- directory_hg_path: &HgPath,
+ is_ignored: bool,
+ hg_path: HgPathBuf,
fs_entry: &DirEntry,
) {
- let hg_path = directory_hg_path.join(&fs_entry.base_name);
let file_type = fs_entry.metadata.file_type();
let file_or_symlink = file_type.is_file() || file_type.is_symlink();
if file_type.is_dir() {
- let is_ignored =
- has_ignored_ancestor || (self.ignore_fn)(&hg_path);
let traverse_children = if is_ignored {
// Descendants of an ignored directory are all ignored
self.options.list_ignored
@@ -612,9 +612,11 @@
is_at_repo_root,
) {
children_fs_entries.par_iter().for_each(|child_fs_entry| {
+ let child_hg_path =
+ hg_path.join(&child_fs_entry.base_name);
self.traverse_fs_only(
- is_ignored,
- &hg_path,
+ is_ignored || (self.ignore_fn)(&child_hg_path),
+ child_hg_path,
child_fs_entry,
)
})
@@ -625,7 +627,7 @@
}
} else if file_or_symlink && self.matcher.matches(&hg_path) {
self.mark_unknown_or_ignored(
- has_ignored_ancestor,
+ is_ignored,
&BorrowedPath::InMemory(&hg_path),
)
}
@@ -633,10 +635,9 @@
fn mark_unknown_or_ignored(
&self,
- has_ignored_ancestor: bool,
+ is_ignored: bool,
hg_path: &BorrowedPath<'_, 'on_disk>,
) {
- let is_ignored = has_ignored_ancestor || (self.ignore_fn)(&hg_path);
if is_ignored {
if self.options.list_ignored {
self.outcome
To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210624/3a45aa5e/attachment-0001.html>
More information about the Mercurial-patches
mailing list