ok/jj
1
0
Fork 0
forked from mirrors/jj

merged_tree: add entries() for iterating over all entries

We already have `entries_matching()`, so this is just a version of
that that doesn't take a matcher.
This commit is contained in:
Martin von Zweigbergk 2023-08-25 18:57:00 -07:00 committed by Martin von Zweigbergk
parent 36674e8f7e
commit 2dd2e77170
2 changed files with 8 additions and 5 deletions

View file

@ -23,7 +23,7 @@ use itertools::Itertools;
use crate::backend;
use crate::backend::{BackendResult, ConflictId, MergedTreeId, TreeValue};
use crate::matchers::Matcher;
use crate::matchers::{EverythingMatcher, Matcher};
use crate::merge::Merge;
use crate::repo_path::{RepoPath, RepoPathComponent, RepoPathJoin};
use crate::store::Store;
@ -297,6 +297,11 @@ impl MergedTree {
/// (i.e. the subdirectory was replaced by symlink in one side of the
/// conflict), then the entry for `foo` itself will be emitted, but no
/// entries from inside `foo/` from either of the trees will be.
pub fn entries(&self) -> TreeEntriesIterator<'static> {
TreeEntriesIterator::new(self.clone(), &EverythingMatcher)
}
/// Like `entries()` but restricted by a matcher.
pub fn entries_matching<'matcher>(
&self,
matcher: &'matcher dyn Matcher,

View file

@ -277,10 +277,8 @@ fn test_path_value_and_entries() {
Merge::resolved(tree3.path_value(&file_dir_conflict_sub_path)),
);
// Test entries_matching()
let actual_entries = merged_tree
.entries_matching(&EverythingMatcher)
.collect_vec();
// Test entries()
let actual_entries = merged_tree.entries().collect_vec();
// missing_path, resolved_dir_path, and file_dir_conflict_sub_path should not
// appear
let expected_entries = [