Skip to content

Commit

Permalink
conflicts: label closing delimeter with conflict number
Browse files Browse the repository at this point in the history
This follows up on #3459 and adds a
label to the closing delimenter of each conflict, e.g.  "Conflict 1 of 3
ends".

I didn't initially put any label at the ending delimeter since the
starting delimeter is already marked with "Conflict 1 of 3". However,
I'm now realizing that when I resolve conflicts, I usually go from top
to bottom. The first thing I do is delete the starting conflict
delimeter. It is when I get to the *end* of the conflict that I wonder
whether there are any more conflicts left in the file.
  • Loading branch information
ilyagr committed May 21, 2024
1 parent 7812beb commit 486cd41
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 46 deletions.
2 changes: 1 addition & 1 deletion cli/tests/test_cat_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn test_cat() {
+a
+++++++ Contents of side #2
c
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
}

Expand Down
10 changes: 5 additions & 5 deletions cli/tests/test_chmod_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn test_chmod_regular_conflict() {
+x
+++++++ Contents of side #2
n
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);

// Test chmodding a conflict
Expand All @@ -96,7 +96,7 @@ fn test_chmod_regular_conflict() {
+x
+++++++ Contents of side #2
n
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
test_env.jj_cmd_ok(&repo_path, &["chmod", "n", "file"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["debug", "tree"]);
Expand All @@ -113,7 +113,7 @@ fn test_chmod_regular_conflict() {
+x
+++++++ Contents of side #2
n
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);

// Unmatched paths should generate warnings
Expand Down Expand Up @@ -206,7 +206,7 @@ fn test_chmod_file_dir_deletion_conflicts() {
a
%%%%%%% Changes from base to side #2
-base
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
let (stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["chmod", "x", "file", "-r=file_deletion"]);
Expand Down Expand Up @@ -239,6 +239,6 @@ fn test_chmod_file_dir_deletion_conflicts() {
a
%%%%%%% Changes from base to side #2
-base
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
}
2 changes: 1 addition & 1 deletion cli/tests/test_diffedit_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ fn test_diffedit_merge() {
+c
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
}

Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_interdiff_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn test_interdiff_conflicting() {
-+abc
-+++++++ Contents of side #2
-bar
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+def
"###);
}
4 changes: 2 additions & 2 deletions cli/tests/test_obslog_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn test_obslog_with_or_without_diff() {
│ 4 : +++++++ Contents of side #2
│ 5 : foo
│ 6 : bar
│ 7 : >>>>>>>
│ 7 : >>>>>>> Conflict 1 of 1 ends
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 cf73917d conflict
│ my description
◉ rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 6fbba7bc
Expand Down Expand Up @@ -117,7 +117,7 @@ fn test_obslog_with_or_without_diff() {
-+++++++ Contents of side #2
-foo
-bar
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+resolved
rlvkpnrz hidden [email protected] 2001-02-03 08:05:09 cf73917d conflict
my description
Expand Down
35 changes: 18 additions & 17 deletions cli/tests/test_resolve_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn test_resolution() {
+a
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);

let editor_script = test_env.set_up_fake_editor();
Expand Down Expand Up @@ -110,7 +110,7 @@ fn test_resolution() {
-+a
-+++++++ Contents of side #2
-b
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+resolution
"###);
insta::assert_snapshot!(test_env.jj_cmd_cli_error(&repo_path, &["resolve", "--list"]),
Expand Down Expand Up @@ -150,7 +150,7 @@ fn test_resolution() {
-+a
-+++++++ Contents of side #2
-b
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+resolution
"###);
insta::assert_snapshot!(test_env.jj_cmd_cli_error(&repo_path, &["resolve", "--list"]),
Expand Down Expand Up @@ -184,7 +184,7 @@ fn test_resolution() {
+a
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
@r###"
Expand All @@ -199,7 +199,7 @@ fn test_resolution() {
-+a
-+++++++ Contents of side #2
-b
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+resolution
"###);

Expand Down Expand Up @@ -259,7 +259,7 @@ fn test_resolution() {
+a
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
// Note the "Modified" below
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
Expand All @@ -277,7 +277,7 @@ fn test_resolution() {
+++++++ Contents of side #2
-b
+conflict
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
@r###"
Expand Down Expand Up @@ -334,13 +334,14 @@ fn test_resolution() {
-+a
-+++++++ Contents of side #2
-b
->>>>>>> Conflict 1 of 1 ends
+<<<<<<<
+%%%%%%%
+-some
++fake
++++++++
+conflict
>>>>>>>
+>>>>>>>
"###);
insta::assert_snapshot!(test_env.jj_cmd_cli_error(&repo_path, &["resolve", "--list"]),
@r###"
Expand Down Expand Up @@ -407,7 +408,7 @@ fn test_normal_conflict_input_files() {
+a
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);

check_resolve_produces_input_file(&mut test_env, &repo_path, "base", "base\n");
Expand Down Expand Up @@ -447,7 +448,7 @@ fn test_baseless_conflict_input_files() {
+a
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);

check_resolve_produces_input_file(&mut test_env, &repo_path, "base", "");
Expand Down Expand Up @@ -518,7 +519,7 @@ fn test_edit_delete_conflict_input_files() {
a
%%%%%%% Changes from base to side #2
-base
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);

check_resolve_produces_input_file(&mut test_env, &repo_path, "base", "base\n");
Expand Down Expand Up @@ -691,7 +692,7 @@ fn test_multiple_conflicts() {
+first a
+++++++ Contents of side #2
first b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
insta::assert_snapshot!(
std::fs::read_to_string(repo_path.join("another_file")).unwrap()
Expand All @@ -702,7 +703,7 @@ fn test_multiple_conflicts() {
+second a
+++++++ Contents of side #2
second b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
@r###"
Expand Down Expand Up @@ -751,7 +752,7 @@ fn test_multiple_conflicts() {
-+second a
-+++++++ Contents of side #2
-second b
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+resolution another_file
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
Expand Down Expand Up @@ -790,7 +791,7 @@ fn test_multiple_conflicts() {
-+second a
-+++++++ Contents of side #2
-second b
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+first resolution for auto-chosen file
"###);
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
Expand All @@ -817,7 +818,7 @@ fn test_multiple_conflicts() {
-+second a
-+++++++ Contents of side #2
-second b
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+first resolution for auto-chosen file
diff --git a/this_file_has_a_very_long_name_to_test_padding b/this_file_has_a_very_long_name_to_test_padding
index 0000000000...f8c72adf17 100644
Expand All @@ -830,7 +831,7 @@ fn test_multiple_conflicts() {
-+first a
-+++++++ Contents of side #2
-first b
->>>>>>>
->>>>>>> Conflict 1 of 1 ends
+second resolution for auto-chosen file
"###);

Expand Down
10 changes: 5 additions & 5 deletions cli/tests/test_restore_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn test_restore_conflicted_merge() {
+a
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);

// Overwrite the file...
Expand All @@ -191,7 +191,7 @@ fn test_restore_conflicted_merge() {
4 : +a
5 : +++++++ Contents of side #2
6 : b
7 : >>>>>>>
7 : >>>>>>> Conflict 1 of 1 ends
1: resolution
"###);

Expand All @@ -216,7 +216,7 @@ fn test_restore_conflicted_merge() {
+a
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
let stdout = test_env.jj_cmd_success(&repo_path, &["diff"]);
insta::assert_snapshot!(stdout, @"");
Expand All @@ -232,7 +232,7 @@ fn test_restore_conflicted_merge() {
4 : +a
5 : +++++++ Contents of side #2
6 : b
7 : >>>>>>>
7 : >>>>>>> Conflict 1 of 1 ends
1: resolution
"###);

Expand All @@ -257,7 +257,7 @@ fn test_restore_conflicted_merge() {
+a
+++++++ Contents of side #2
b
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
}

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/test_squash_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ fn test_squash_from_multiple() {
+b
+++++++ Contents of side #3
c
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);

// Squash a few commits up an down
Expand Down Expand Up @@ -795,7 +795,7 @@ fn test_squash_from_multiple_partial() {
+b
+++++++ Contents of side #3
c
>>>>>>>
>>>>>>> Conflict 1 of 1 ends
"###);
// The unselected change from the sources have not been applied to the
// destination
Expand Down
4 changes: 3 additions & 1 deletion lib/src/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ pub fn materialize_merge_result(
output.write_all(&slice.0)?;
}
output.write_all(CONFLICT_END_LINE)?;
output.write_all(b"\n")?;
output.write_all(
format!(" Conflict {conflict_index} of {num_conflicts} ends\n").as_bytes(),
)?;
}
}
}
Expand Down
Loading

0 comments on commit 486cd41

Please sign in to comment.