diff --git a/lib/src/tree.rs b/lib/src/tree.rs
index 31010f530..465a881d4 100644
--- a/lib/src/tree.rs
+++ b/lib/src/tree.rs
@@ -23,9 +23,10 @@ use itertools::Itertools;
use thiserror::Error;
use crate::backend::{
- BackendError, Conflict, ConflictId, ConflictTerm, FileId, ObjectId,
- TreeEntriesNonRecursiveIterator, TreeEntry, TreeId, TreeValue,
+ BackendError, ConflictId, FileId, ObjectId, TreeEntriesNonRecursiveIterator, TreeEntry, TreeId,
+ TreeValue,
};
+use crate::conflicts::Conflict;
use crate::files::MergeResult;
use crate::matchers::{EverythingMatcher, Matcher};
use crate::merge::trivial_merge;
@@ -622,31 +623,19 @@ fn merge_tree_value(
_ => {
// Start by creating a Conflict object. Conflicts can cleanly represent a single
// resolved state, the absence of a state, or a conflicted state.
- let mut conflict = Conflict::default();
- if let Some(base) = maybe_base {
- conflict.removes.push(ConflictTerm {
- value: base.clone(),
- });
- }
- if let Some(side1) = maybe_side1 {
- conflict.adds.push(ConflictTerm {
- value: side1.clone(),
- });
- }
- if let Some(side2) = maybe_side2 {
- conflict.adds.push(ConflictTerm {
- value: side2.clone(),
- });
- }
+ let conflict = Conflict::new(
+ vec![maybe_base.cloned()],
+ vec![maybe_side1.cloned(), maybe_side2.cloned()],
+ );
let filename = dir.join(basename);
let conflict = simplify_conflict(store, &filename, conflict)?;
- if conflict.adds.is_empty() {
+ if conflict.adds().is_empty() {
// If there are no values to add, then the path doesn't exist
return Ok(None);
}
- if conflict.removes.is_empty() && conflict.adds.len() == 1 {
+ if conflict.removes().is_empty() && conflict.adds().len() == 1 {
// A single add means that the current state is that state.
- return Ok(Some(conflict.adds[0].value.clone()));
+ return Ok(conflict.adds()[0].clone());
}
if let Some((merged_content, executable)) =
try_resolve_file_conflict(store, &filename, &conflict)?
@@ -654,7 +643,8 @@ fn merge_tree_value(
let id = store.write_file(&filename, &mut merged_content.as_slice())?;
Some(TreeValue::File { id, executable })
} else {
- let conflict_id = store.write_conflict(&filename, &conflict)?;
+ let conflict_id =
+ store.write_conflict(&filename, &conflict.to_backend_conflict())?;
Some(TreeValue::Conflict(conflict_id))
}
}
@@ -664,25 +654,19 @@ fn merge_tree_value(
fn try_resolve_file_conflict(
store: &Store,
filename: &RepoPath,
- conflict: &Conflict,
+ conflict: &Conflict