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

conflicts: test materialization with with negative snapshots

We didn't have any tests with negative snapshots (after a `-------`
line). I initially thought we couldn't produce such conflict markers
anymore. I'm not sure we want to render conflicts like the one in the
test like this. I don't think I intended for `add_index` in the code
to be able to be two steps ahead of the remove. Maybe we should
rewrite the algorithm to not do that and thus never produce negative
snapshots.
This commit is contained in:
Martin von Zweigbergk 2024-01-22 21:59:05 -08:00 committed by Martin von Zweigbergk
parent 566713bf6b
commit 502150b2f4

View file

@ -420,6 +420,61 @@ line 5
);
}
#[test]
fn test_materialize_conflict_two_forward_diffs() {
let test_repo = TestRepo::init();
let store = test_repo.repo.store();
// Create conflict A-B+B-C+D-E+C. This is designed to tempt the algorithm to
// produce a negative snapshot at the end like this:
// <<<<
// ====
// A
// %%%%
// B
// ++++
// D
// %%%%
// C
// ----
// E
// >>>>
// TODO: Maybe we should never have negative snapshots
let path = RepoPath::from_internal_string("file");
let a_id = testutils::write_file(store, path, "A\n");
let b_id = testutils::write_file(store, path, "B\n");
let c_id = testutils::write_file(store, path, "C\n");
let d_id = testutils::write_file(store, path, "D\n");
let e_id = testutils::write_file(store, path, "E\n");
let conflict = Merge::from_removes_adds(
vec![Some(b_id.clone()), Some(c_id.clone()), Some(e_id.clone())],
vec![
Some(a_id.clone()),
Some(b_id.clone()),
Some(d_id.clone()),
Some(c_id.clone()),
],
);
insta::assert_snapshot!(
&materialize_conflict_string(store, path, &conflict),
@r###"
<<<<<<<
+++++++
A
%%%%%%%
B
+++++++
D
%%%%%%%
C
-------
E
>>>>>>>
"###
);
}
#[test]
fn test_parse_conflict_resolved() {
assert_eq!(