From acb0e9751d474c6bed6a136da27dc44a88801def Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sat, 3 Dec 2022 19:47:03 -0800 Subject: [PATCH] Add a `Tree` method to return conflicts matching a matcher This is useful for `jj resolve`. --- lib/src/tree.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/src/tree.rs b/lib/src/tree.rs index cb06b6bbb..57583fa01 100644 --- a/lib/src/tree.rs +++ b/lib/src/tree.rs @@ -210,19 +210,23 @@ impl Tree { } } - pub fn has_conflict(&self) -> bool { - !self.conflicts().is_empty() - } - - pub fn conflicts(&self) -> Vec<(RepoPath, ConflictId)> { + pub fn conflicts_matching(&self, matcher: &dyn Matcher) -> Vec<(RepoPath, ConflictId)> { let mut conflicts = vec![]; - for (name, value) in self.entries() { + for (name, value) in self.entries_matching(matcher) { if let TreeValue::Conflict(id) = value { conflicts.push((name.clone(), id.clone())); } } conflicts } + + pub fn conflicts(&self) -> Vec<(RepoPath, ConflictId)> { + self.conflicts_matching(&EverythingMatcher) + } + + pub fn has_conflict(&self) -> bool { + !self.conflicts().is_empty() + } } pub struct TreeEntriesIterator<'matcher> {