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

merge: rename Merge::new() to Merge::from_removes_adds()

Since (removes, adds) pair is no longer the canonical representation of Merge,
the name Merge::new() seems too generic. Let's give more verbose name.
This commit is contained in:
Yuya Nishihara 2023-11-05 11:48:06 +09:00
parent 2c128f1b61
commit e0c35684af
8 changed files with 94 additions and 80 deletions

View file

@ -285,7 +285,7 @@ fn parse_conflict_hunk(input: &[u8]) -> Merge<ContentHunk> {
}
}
Merge::new(removes, adds)
Merge::from_removes_adds(removes, adds)
}
/// Parses conflict markers in `content` and returns an updated version of

View file

@ -190,7 +190,7 @@ pub fn merge(slices: &Merge<&[u8]>) -> MergeResult {
merge_hunks.push(Merge::resolved(resolved_hunk));
resolved_hunk = ContentHunk(vec![]);
}
merge_hunks.push(Merge::new(
merge_hunks.push(Merge::from_removes_adds(
parts[..num_diffs]
.iter()
.map(|part| ContentHunk(part.to_vec()))
@ -224,7 +224,7 @@ mod tests {
}
fn merge(removes: &[&[u8]], adds: &[&[u8]]) -> MergeResult {
super::merge(&Merge::new(removes.to_vec(), adds.to_vec()))
super::merge(&Merge::from_removes_adds(removes.to_vec(), adds.to_vec()))
}
#[test]
@ -269,7 +269,7 @@ mod tests {
// One side modified, two sides added
assert_eq!(
merge(&[b"a", b""], &[b"b", b"b", b"b"]),
MergeResult::Conflict(vec![Merge::new(
MergeResult::Conflict(vec![Merge::from_removes_adds(
vec![hunk(b"a"), hunk(b"")],
vec![hunk(b"b"), hunk(b"b"), hunk(b"b")]
)])
@ -282,7 +282,7 @@ mod tests {
// One side modified, two sides removed
assert_eq!(
merge(&[b"a\n", b"a\n"], &[b"b\n", b"", b""]),
MergeResult::Conflict(vec![Merge::new(
MergeResult::Conflict(vec![Merge::from_removes_adds(
vec![hunk(b"a\n"), hunk(b"a\n")],
vec![hunk(b"b\n"), hunk(b""), hunk(b"")]
)])
@ -295,7 +295,7 @@ mod tests {
// One side removed, one side modified
assert_eq!(
merge(&[b"a\n"], &[b"", b"b\n"]),
MergeResult::Conflict(vec![Merge::new(
MergeResult::Conflict(vec![Merge::from_removes_adds(
vec![hunk(b"a\n")],
vec![hunk(b""), hunk(b"b\n")]
)])
@ -303,7 +303,7 @@ mod tests {
// One side modified, one side removed
assert_eq!(
merge(&[b"a\n"], &[b"b\n", b""]),
MergeResult::Conflict(vec![Merge::new(
MergeResult::Conflict(vec![Merge::from_removes_adds(
vec![hunk(b"a\n")],
vec![hunk(b"b\n"), hunk(b"")]
)])
@ -311,7 +311,7 @@ mod tests {
// Two sides modified in different ways
assert_eq!(
merge(&[b"a"], &[b"b", b"c"]),
MergeResult::Conflict(vec![Merge::new(
MergeResult::Conflict(vec![Merge::from_removes_adds(
vec![hunk(b"a")],
vec![hunk(b"b"), hunk(b"c")]
)])
@ -329,7 +329,7 @@ mod tests {
// One side unchanged, two other sides make the different change
assert_eq!(
merge(&[b"a", b"a"], &[b"b", b"a", b"c"]),
MergeResult::Conflict(vec![Merge::new(
MergeResult::Conflict(vec![Merge::from_removes_adds(
vec![hunk(b"a"), hunk(b"a")],
vec![hunk(b"b"), hunk(b"a"), hunk(b"c")]
)])
@ -344,7 +344,7 @@ mod tests {
// Merge of an unresolved conflict and another branch.
assert_eq!(
merge(&[b"a", b"b"], &[b"c", b"d", b"e"]),
MergeResult::Conflict(vec![Merge::new(
MergeResult::Conflict(vec![Merge::from_removes_adds(
vec![hunk(b"a"), hunk(b"b")],
vec![hunk(b"c"), hunk(b"d"), hunk(b"e")]
)])
@ -352,7 +352,7 @@ mod tests {
// Two sides made the same change, third side made a different change
assert_eq!(
merge(&[b"a", b"b"], &[b"c", b"c", b"c"]),
MergeResult::Conflict(vec![Merge::new(
MergeResult::Conflict(vec![Merge::from_removes_adds(
vec![hunk(b"a"), hunk(b"b")],
vec![hunk(b"c"), hunk(b"c"), hunk(b"c")]
)])
@ -366,7 +366,7 @@ mod tests {
merge(&[b"a\n"], &[b"a\nb\n", b"a\nc\n"]),
MergeResult::Conflict(vec![
Merge::resolved(hunk(b"a\n")),
Merge::new(vec![hunk(b"")], vec![hunk(b"b\n"), hunk(b"c\n")])
Merge::from_removes_adds(vec![hunk(b"")], vec![hunk(b"b\n"), hunk(b"c\n")])
])
);
// Two sides changed different lines: no conflict
@ -379,7 +379,7 @@ mod tests {
merge(&[b"a\nb\nc\n"], &[b"a\nb1\nc\n", b"a\nb2\nc\n"]),
MergeResult::Conflict(vec![
Merge::resolved(hunk(b"a\n")),
Merge::new(vec![hunk(b"b\n")], vec![hunk(b"b1\n"), hunk(b"b2\n")]),
Merge::from_removes_adds(vec![hunk(b"b\n")], vec![hunk(b"b1\n"), hunk(b"b2\n")]),
Merge::resolved(hunk(b"c\n"))
])
);

View file

@ -1376,7 +1376,7 @@ mod tests {
TreeId::from_bytes(tree_builder.write().unwrap().as_bytes())
};
let root_tree = Merge::new(
let root_tree = Merge::from_removes_adds(
vec![create_tree(0), create_tree(1)],
vec![create_tree(2), create_tree(3), create_tree(4)],
);

View file

@ -144,9 +144,8 @@ impl<T> Merge<T> {
}
/// Creates a new merge object from the given removes and adds.
pub fn new(removes: Vec<T>, adds: Vec<T>) -> Self {
pub fn from_removes_adds(removes: Vec<T>, adds: Vec<T>) -> Self {
// TODO: removes and adds can be just IntoIterator.
// TODO: maybe add constructor that takes single values vec, and rename this
assert_eq!(adds.len(), removes.len() + 1);
let values = itertools::interleave(adds, removes).collect();
Merge { values }
@ -606,7 +605,7 @@ mod tests {
use super::*;
fn c<T: Clone>(removes: &[T], adds: &[T]) -> Merge<T> {
Merge::new(removes.to_vec(), adds.to_vec())
Merge::from_removes_adds(removes.to_vec(), adds.to_vec())
}
#[test]
@ -681,39 +680,48 @@ mod tests {
assert_eq!(Merge::from_legacy_form(legacy_form.0, legacy_form.1), merge);
}
// Non-conflict
test_equivalent((vec![], vec![0]), Merge::new(vec![], vec![Some(0)]));
test_equivalent(
(vec![], vec![0]),
Merge::from_removes_adds(vec![], vec![Some(0)]),
);
// Regular 3-way conflict
test_equivalent(
(vec![0], vec![1, 2]),
Merge::new(vec![Some(0)], vec![Some(1), Some(2)]),
Merge::from_removes_adds(vec![Some(0)], vec![Some(1), Some(2)]),
);
// Modify/delete conflict
test_equivalent(
(vec![0], vec![1]),
Merge::new(vec![Some(0)], vec![Some(1), None]),
Merge::from_removes_adds(vec![Some(0)], vec![Some(1), None]),
);
// Add/add conflict
test_equivalent(
(vec![], vec![0, 1]),
Merge::new(vec![None], vec![Some(0), Some(1)]),
Merge::from_removes_adds(vec![None], vec![Some(0), Some(1)]),
);
// 5-way conflict
test_equivalent(
(vec![0, 1], vec![2, 3, 4]),
Merge::new(vec![Some(0), Some(1)], vec![Some(2), Some(3), Some(4)]),
Merge::from_removes_adds(vec![Some(0), Some(1)], vec![Some(2), Some(3), Some(4)]),
);
// 5-way delete/delete conflict
test_equivalent(
(vec![0, 1], vec![]),
Merge::new(vec![Some(0), Some(1)], vec![None, None, None]),
Merge::from_removes_adds(vec![Some(0), Some(1)], vec![None, None, None]),
);
}
#[test]
fn test_as_resolved() {
assert_eq!(Merge::new(vec![], vec![0]).as_resolved(), Some(&0));
assert_eq!(
Merge::from_removes_adds(vec![], vec![0]).as_resolved(),
Some(&0)
);
// Even a trivially resolvable merge is not resolved
assert_eq!(Merge::new(vec![0], vec![0, 1]).as_resolved(), None);
assert_eq!(
Merge::from_removes_adds(vec![0], vec![0, 1]).as_resolved(),
None
);
}
#[test]
@ -788,7 +796,7 @@ mod tests {
#[test]
fn test_merge_invariants() {
fn check_invariants(removes: &[u32], adds: &[u32]) {
let merge = Merge::new(removes.to_vec(), adds.to_vec());
let merge = Merge::from_removes_adds(removes.to_vec(), adds.to_vec());
// `simplify()` is idempotent
assert_eq!(
merge.clone().simplify().simplify(),

View file

@ -507,7 +507,7 @@ fn ref_target_from_proto(maybe_proto: Option<crate::protos::op_store::RefTarget>
|term: crate::protos::op_store::ref_conflict::Term| term.value.map(CommitId::new);
let removes = conflict.removes.into_iter().map(term_from_proto).collect();
let adds = conflict.adds.into_iter().map(term_from_proto).collect();
RefTarget::from_merge(Merge::new(removes, adds))
RefTarget::from_merge(Merge::from_removes_adds(removes, adds))
}
}
}
@ -811,7 +811,7 @@ mod tests {
#[test]
fn test_ref_target_change_delete_order_roundtrip() {
let target = RefTarget::from_merge(Merge::new(
let target = RefTarget::from_merge(Merge::from_removes_adds(
vec![Some(CommitId::from_hex("111111"))],
vec![Some(CommitId::from_hex("222222")), None],
));
@ -819,7 +819,7 @@ mod tests {
assert_eq!(ref_target_from_proto(maybe_proto), target);
// If it were legacy format, order of None entry would be lost.
let target = RefTarget::from_merge(Merge::new(
let target = RefTarget::from_merge(Merge::from_removes_adds(
vec![Some(CommitId::from_hex("111111"))],
vec![None, Some(CommitId::from_hex("222222"))],
));

View file

@ -64,7 +64,7 @@ line 5
// The left side should come first. The diff should be use the smaller (right)
// side, and the left side should be a snapshot.
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone())],
vec![Some(left_id.clone()), Some(right_id.clone())],
);
@ -88,7 +88,7 @@ line 5
);
// Swap the positive terms in the conflict. The diff should still use the right
// side, but now the right side should come first.
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone())],
vec![Some(right_id.clone()), Some(left_id.clone())],
);
@ -157,7 +157,7 @@ line 3
// The order of (a, b, c) should be preserved. For all cases, the "a" side
// should be a snapshot.
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone()), Some(base_id.clone())],
vec![Some(a_id.clone()), Some(b_id.clone()), Some(c_id.clone())],
);
@ -181,7 +181,7 @@ line 3
line 3
"###
);
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone()), Some(base_id.clone())],
vec![Some(c_id.clone()), Some(b_id.clone()), Some(a_id.clone())],
);
@ -205,7 +205,7 @@ line 3
line 3
"###
);
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone()), Some(base_id.clone())],
vec![Some(c_id.clone()), Some(a_id.clone()), Some(b_id.clone())],
);
@ -268,7 +268,7 @@ line 5 right
",
);
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone())],
vec![Some(left_id.clone()), Some(right_id.clone())],
);
@ -363,7 +363,7 @@ line 5
);
// left modifies a line, right deletes the same line.
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone())],
vec![Some(modified_id.clone()), Some(deleted_id.clone())],
);
@ -382,7 +382,7 @@ line 5
);
// right modifies a line, left deletes the same line.
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone())],
vec![Some(deleted_id.clone()), Some(modified_id.clone())],
);
@ -401,7 +401,7 @@ line 5
);
// modify/delete conflict at the file level
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_id.clone())],
vec![Some(modified_id.clone()), None],
);
@ -599,7 +599,7 @@ fn test_update_conflict_from_content() {
let base_file_id = testutils::write_file(store, &path, "line 1\nline 2\nline 3\n");
let left_file_id = testutils::write_file(store, &path, "left 1\nline 2\nleft 3\n");
let right_file_id = testutils::write_file(store, &path, "right 1\nline 2\nright 3\n");
let conflict = Merge::new(
let conflict = Merge::from_removes_adds(
vec![Some(base_file_id.clone())],
vec![Some(left_file_id.clone()), Some(right_file_id.clone())],
);
@ -632,7 +632,7 @@ fn test_update_conflict_from_content() {
let new_right_file_id = testutils::write_file(store, &path, "resolved 1\nline 2\nright 3\n");
assert_eq!(
new_conflict,
Merge::new(
Merge::from_removes_adds(
vec![Some(new_base_file_id.clone())],
vec![
Some(new_left_file_id.clone()),
@ -650,7 +650,8 @@ fn test_update_conflict_from_content_modify_delete() {
let path = RepoPath::from_internal_string("dir/file");
let before_file_id = testutils::write_file(store, &path, "line 1\nline 2 before\nline 3\n");
let after_file_id = testutils::write_file(store, &path, "line 1\nline 2 after\nline 3\n");
let conflict = Merge::new(vec![Some(before_file_id)], vec![Some(after_file_id), None]);
let conflict =
Merge::from_removes_adds(vec![Some(before_file_id)], vec![Some(after_file_id), None]);
// If the content is unchanged compared to the materialized value, we get the
// old conflict id back.
@ -677,7 +678,7 @@ fn test_update_conflict_from_content_modify_delete() {
assert_eq!(
new_conflict,
Merge::new(
Merge::from_removes_adds(
vec![Some(new_base_file_id.clone())],
vec![Some(new_left_file_id.clone()), None]
)

View file

@ -122,7 +122,7 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) {
let base_file_id = testutils::write_file(store, path, "base file contents");
let left_file_id = testutils::write_file(store, path, "left file contents");
let right_file_id = testutils::write_file(store, path, "right file contents");
Merge::new(
Merge::from_removes_adds(
vec![Some(TreeValue::File {
id: base_file_id,
executable: false,

View file

@ -66,7 +66,7 @@ fn test_from_legacy_tree() {
let file2_v1_id = write_file(store.as_ref(), &file2_path, "file2_v1");
let file2_v2_id = write_file(store.as_ref(), &file2_path, "file2_v2");
let file2_v3_id = write_file(store.as_ref(), &file2_path, "file2_v3");
let file2_conflict = Merge::new(
let file2_conflict = Merge::from_removes_adds(
vec![Some(file_value(&file2_v1_id))],
vec![
Some(file_value(&file2_v2_id)),
@ -80,7 +80,7 @@ fn test_from_legacy_tree() {
let file3_path = RepoPath::from_internal_string("modify_delete");
let file3_v1_id = write_file(store.as_ref(), &file3_path, "file3_v1");
let file3_v2_id = write_file(store.as_ref(), &file3_path, "file3_v2");
let file3_conflict = Merge::new(
let file3_conflict = Merge::from_removes_adds(
vec![Some(file_value(&file3_v1_id))],
vec![Some(file_value(&file3_v2_id)), None],
);
@ -91,7 +91,7 @@ fn test_from_legacy_tree() {
let file4_path = RepoPath::from_internal_string("add_add");
let file4_v1_id = write_file(store.as_ref(), &file4_path, "file4_v1");
let file4_v2_id = write_file(store.as_ref(), &file4_path, "file4_v2");
let file4_conflict = Merge::new(
let file4_conflict = Merge::from_removes_adds(
vec![None],
vec![
Some(file_value(&file4_v1_id)),
@ -108,7 +108,7 @@ fn test_from_legacy_tree() {
let file5_v3_id = write_file(store.as_ref(), &file5_path, "file5_v3");
let file5_v4_id = write_file(store.as_ref(), &file5_path, "file5_v4");
let file5_v5_id = write_file(store.as_ref(), &file5_path, "file5_v5");
let file5_conflict = Merge::new(
let file5_conflict = Merge::from_removes_adds(
vec![
Some(file_value(&file5_v1_id)),
Some(file_value(&file5_v2_id)),
@ -149,7 +149,7 @@ fn test_from_legacy_tree() {
// file2: 3-way conflict
assert_eq!(
merged_tree.value(&file2_path.components()[0]),
MergedTreeVal::Conflict(Merge::new(
MergedTreeVal::Conflict(Merge::from_removes_adds(
vec![Some(file_value(&file2_v1_id)), None],
vec![
Some(file_value(&file2_v2_id)),
@ -161,7 +161,7 @@ fn test_from_legacy_tree() {
// file3: modify/delete conflict
assert_eq!(
merged_tree.value(&file3_path.components()[0]),
MergedTreeVal::Conflict(Merge::new(
MergedTreeVal::Conflict(Merge::from_removes_adds(
vec![Some(file_value(&file3_v1_id)), None],
vec![Some(file_value(&file3_v2_id)), None, None],
))
@ -169,7 +169,7 @@ fn test_from_legacy_tree() {
// file4: add/add conflict
assert_eq!(
merged_tree.value(&file4_path.components()[0]),
MergedTreeVal::Conflict(Merge::new(
MergedTreeVal::Conflict(Merge::from_removes_adds(
vec![None, None],
vec![
Some(file_value(&file4_v1_id)),
@ -181,7 +181,7 @@ fn test_from_legacy_tree() {
// file5: 5-way conflict
assert_eq!(
merged_tree.value(&file5_path.components()[0]),
MergedTreeVal::Conflict(Merge::new(
MergedTreeVal::Conflict(Merge::from_removes_adds(
vec![
Some(file_value(&file5_v1_id)),
Some(file_value(&file5_v2_id)),
@ -279,7 +279,7 @@ fn test_path_value_and_entries() {
(&file_dir_conflict_sub_path, "1"),
],
);
let merged_tree = MergedTree::Merge(Merge::new(
let merged_tree = MergedTree::Merge(Merge::from_removes_adds(
vec![tree1.clone()],
vec![tree2.clone(), tree3.clone()],
));
@ -287,7 +287,7 @@ fn test_path_value_and_entries() {
// Get the root tree
assert_eq!(
merged_tree.path_value(&RepoPath::root()),
Merge::new(
Merge::from_removes_adds(
vec![Some(TreeValue::Tree(tree1.id().clone()))],
vec![
Some(TreeValue::Tree(tree2.id().clone())),
@ -310,7 +310,7 @@ fn test_path_value_and_entries() {
// Get modify/delete conflict (some None values)
assert_eq!(
merged_tree.path_value(&modify_delete_path),
Merge::new(
Merge::from_removes_adds(
vec![tree1.path_value(&modify_delete_path)],
vec![tree2.path_value(&modify_delete_path), None]
),
@ -318,7 +318,7 @@ fn test_path_value_and_entries() {
// Get file/dir conflict path
assert_eq!(
merged_tree.path_value(&file_dir_conflict_path),
Merge::new(
Merge::from_removes_adds(
vec![tree1.path_value(&file_dir_conflict_path)],
vec![
tree2.path_value(&file_dir_conflict_path),
@ -419,7 +419,7 @@ fn test_resolve_success() {
],
);
let tree = MergedTree::new(Merge::new(vec![base1], vec![side1, side2]));
let tree = MergedTree::new(Merge::from_removes_adds(vec![base1], vec![side1, side2]));
let resolved = tree.resolve().unwrap();
let resolved_tree = resolved.as_resolved().unwrap().clone();
assert_eq!(
@ -443,7 +443,7 @@ fn test_resolve_root_becomes_empty() {
let side1 = create_single_tree(repo, &[(&path2, "base1")]);
let side2 = create_single_tree(repo, &[(&path1, "base1")]);
let tree = MergedTree::new(Merge::new(vec![base1], vec![side1, side2]));
let tree = MergedTree::new(Merge::from_removes_adds(vec![base1], vec![side1, side2]));
let resolved = tree.resolve().unwrap();
assert_eq!(resolved.as_resolved().unwrap().id(), store.empty_tree_id());
}
@ -467,11 +467,11 @@ fn test_resolve_with_conflict() {
let expected_side2 =
create_single_tree(repo, &[(&trivial_path, "side1"), (&conflict_path, "side2")]);
let tree = MergedTree::new(Merge::new(vec![base1], vec![side1, side2]));
let tree = MergedTree::new(Merge::from_removes_adds(vec![base1], vec![side1, side2]));
let resolved_tree = tree.resolve().unwrap();
assert_eq!(
resolved_tree,
Merge::new(vec![expected_base1], vec![expected_side1, expected_side2])
Merge::from_removes_adds(vec![expected_base1], vec![expected_side1, expected_side2])
)
}
@ -548,13 +548,13 @@ fn test_conflict_iterator() {
],
);
let tree = MergedTree::new(Merge::new(
let tree = MergedTree::new(Merge::from_removes_adds(
vec![base1.clone()],
vec![side1.clone(), side2.clone()],
));
let conflicts = tree.conflicts().collect_vec();
let conflict_at = |path: &RepoPath| {
Merge::new(
Merge::from_removes_adds(
vec![base1.path_value(path)],
vec![side1.path_value(path), side2.path_value(path)],
)
@ -619,13 +619,13 @@ fn test_conflict_iterator_higher_arity() {
&[(&two_sided_path, "side3"), (&three_sided_path, "side3")],
);
let tree = MergedTree::new(Merge::new(
let tree = MergedTree::new(Merge::from_removes_adds(
vec![base1.clone(), base2.clone()],
vec![side1.clone(), side2.clone(), side3.clone()],
));
let conflicts = tree.conflicts().collect_vec();
let conflict_at = |path: &RepoPath| {
Merge::new(
Merge::from_removes_adds(
vec![base1.path_value(path), base2.path_value(path)],
vec![
side1.path_value(path),
@ -654,7 +654,7 @@ fn test_conflict_iterator_higher_arity() {
vec![
(
two_sided_path.clone(),
Merge::new(
Merge::from_removes_adds(
vec![base2.path_value(&two_sided_path)],
vec![
side1.path_value(&two_sided_path),
@ -799,11 +799,11 @@ fn test_diff_conflicted() {
(&path4, "right-side2"),
],
);
let left_merged = MergedTree::new(Merge::new(
let left_merged = MergedTree::new(Merge::from_removes_adds(
vec![left_base.clone()],
vec![left_side1.clone(), left_side2.clone()],
));
let right_merged = MergedTree::new(Merge::new(
let right_merged = MergedTree::new(Merge::from_removes_adds(
vec![right_base.clone()],
vec![right_side1.clone(), right_side2.clone()],
));
@ -926,9 +926,14 @@ fn test_diff_dir_file() {
(&path6.join(&file), "right"),
],
);
let left_merged = MergedTree::new(Merge::new(vec![left_base], vec![left_side1, left_side2]));
let right_merged =
MergedTree::new(Merge::new(vec![right_base], vec![right_side1, right_side2]));
let left_merged = MergedTree::new(Merge::from_removes_adds(
vec![left_base],
vec![left_side1, left_side2],
));
let right_merged = MergedTree::new(Merge::from_removes_adds(
vec![right_base],
vec![right_side1, right_side2],
));
// Test the forwards diff
{
@ -1175,7 +1180,7 @@ fn test_merge_partial_resolution() {
let base1_merged = MergedTree::new(Merge::resolved(base1));
let side1_merged = MergedTree::new(Merge::resolved(side1));
let side2_merged = MergedTree::new(Merge::resolved(side2));
let expected_merged = MergedTree::new(Merge::new(
let expected_merged = MergedTree::new(Merge::from_removes_adds(
vec![expected_base1],
vec![expected_side1, expected_side2],
));
@ -1222,15 +1227,15 @@ fn test_merge_simplify_only() {
let tree4 = create_single_tree(repo, &[(&path, "4")]);
let tree5 = create_single_tree(repo, &[(&path, "5")]);
let expected = tree5.clone();
let base1_merged = MergedTree::new(Merge::new(
let base1_merged = MergedTree::new(Merge::from_removes_adds(
vec![tree1.clone()],
vec![tree2.clone(), tree3.clone()],
));
let side1_merged = MergedTree::new(Merge::new(
let side1_merged = MergedTree::new(Merge::from_removes_adds(
vec![tree1.clone()],
vec![tree4.clone(), tree2.clone()],
));
let side2_merged = MergedTree::new(Merge::new(
let side2_merged = MergedTree::new(Merge::from_removes_adds(
vec![tree4.clone()],
vec![tree5.clone(), tree3.clone()],
));
@ -1259,13 +1264,13 @@ fn test_merge_simplify_result() {
let expected_base1 = create_single_tree(repo, &[(&path1, "1"), (&path2, "3")]);
let expected_side1 = create_single_tree(repo, &[(&path1, "2"), (&path2, "3")]);
let expected_side2 = create_single_tree(repo, &[(&path1, "3"), (&path2, "3")]);
let side1_merged = MergedTree::new(Merge::new(
let side1_merged = MergedTree::new(Merge::from_removes_adds(
vec![tree1.clone()],
vec![tree2.clone(), tree3.clone()],
));
let base1_merged = MergedTree::new(Merge::resolved(tree4.clone()));
let side2_merged = MergedTree::new(Merge::resolved(tree5.clone()));
let expected_merged = MergedTree::new(Merge::new(
let expected_merged = MergedTree::new(Merge::from_removes_adds(
vec![expected_base1],
vec![expected_side1, expected_side2],
));
@ -1344,7 +1349,7 @@ fn test_merge_simplify_file_conflict() {
let parent_base = create_single_tree(repo, &[(&conflict_path, &parent_base_text)]);
let parent_left = create_single_tree(repo, &[(&conflict_path, &parent_left_text)]);
let parent_right = create_single_tree(repo, &[(&conflict_path, &parent_right_text)]);
let parent_merged = MergedTree::new(Merge::new(
let parent_merged = MergedTree::new(Merge::from_removes_adds(
vec![parent_base],
vec![parent_left, parent_right],
));
@ -1365,7 +1370,7 @@ fn test_merge_simplify_file_conflict() {
(&conflict_path, &child1_right_text),
],
);
let child1_merged = MergedTree::new(Merge::new(
let child1_merged = MergedTree::new(Merge::from_removes_adds(
vec![child1_base],
vec![child1_left, child1_right],
));
@ -1388,13 +1393,13 @@ fn test_merge_simplify_file_conflict() {
// be resolved. If we later change files::merge() so this no longer fails, it
// probably means that we can delete this whole test (the Merge::simplify() call
// in try_resolve_file_conflict() is just an optimization then).
let text_merge = Merge::new(
vec![Merge::new(
let text_merge = Merge::from_removes_adds(
vec![Merge::from_removes_adds(
vec![parent_base_text.as_bytes()],
vec![parent_left_text.as_bytes(), parent_right_text.as_bytes()],
)],
vec![
Merge::new(
Merge::from_removes_adds(
vec![parent_base_text.as_bytes()],
vec![parent_left_text.as_bytes(), child1_right_text.as_bytes()],
),