conflicts: add take(), returning the removes and adds Vecs

This commit is contained in:
Martin von Zweigbergk 2023-06-07 15:15:59 -07:00 committed by Martin von Zweigbergk
parent b1f2e80349
commit 35e4d5f205
2 changed files with 11 additions and 4 deletions

View file

@ -62,6 +62,11 @@ impl<T> Conflict<T> {
Conflict::new(removes, adds)
}
/// Returns the removes and adds as a pair.
pub fn take(self) -> (Vec<T>, Vec<T>) {
(self.removes, self.adds)
}
pub fn removes(&self) -> &[T] {
&self.removes
}

View file

@ -749,8 +749,9 @@ fn simplify_conflict(
match term {
Some(TreeValue::Conflict(id)) => {
let conflict = store.read_conflict(path, id)?;
new_removes.extend_from_slice(conflict.removes());
new_adds.extend_from_slice(conflict.adds());
let (removes, adds) = conflict.take();
new_removes.extend(removes);
new_adds.extend(adds);
}
_ => {
new_adds.push(term.clone());
@ -761,8 +762,9 @@ fn simplify_conflict(
match term {
Some(TreeValue::Conflict(id)) => {
let conflict = store.read_conflict(path, id)?;
new_removes.extend_from_slice(conflict.adds());
new_adds.extend_from_slice(conflict.removes());
let (removes, adds) = conflict.take();
new_removes.extend(adds);
new_adds.extend(removes);
}
_ => {
new_removes.push(term.clone());