// Copyright 2022 The Jujutsu Authors//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at//// https://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License. use std::path::Path; use indoc::indoc; use crate::common::create_commit_with_files;use crate::common::CommandOutput;use crate::common::TestEnvironment;use crate::common::TestWorkDir; #[must_use]fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { work_dir.run_jj(["log", "-T", "bookmarks"])} #[test]fn test_resolution() { let mut test_env = TestEnvironment::default(); let editor_script = test_env.set_up_fake_editor(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); create_commit_with_files(&work_dir, "b", &["base"], &[("file", "b\n")]); create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); // Test the setup insta::assert_snapshot!(get_log_output(&work_dir), @r" @ conflict ├─╮ │ ○ b ○ │ a ├─╯ ○ base ◆ [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" file 2-sided conflict [EOF] "); insta::assert_snapshot!(work_dir.read_file("file"), @r" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 -base +a +++++++ Contents of side #2 b >>>>>>> Conflict 1 of 1 ends "); // Check that output file starts out empty and resolve the conflict std::fs::write( &editor_script, ["dump editor0", "write\nresolution\n"].join("\0"), ) .unwrap(); let output = work_dir.run_jj(["resolve"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 741263c9 conflict | conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files [EOF] "); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor0")).unwrap(), @""); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file index 0000000000..88425ec521 100644 --- a/file +++ b/file @@ -1,7 +1,1 @@ -<<<<<<< Conflict 1 of 1 -%%%%%%% Changes from base to side #1 --base -+a -+++++++ Contents of side #2 -b ->>>>>>> Conflict 1 of 1 ends +resolution [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" ------- stderr ------- Error: No conflicts found at this revision [EOF] [exit status: 2] "); // Try again with --tool=<name> work_dir.run_jj(["undo"]).success(); std::fs::write(&editor_script, "write\nresolution\n").unwrap(); let output = work_dir.run_jj([ "resolve", "--config=ui.merge-editor='false'", "--tool=fake-editor", ]); insta::assert_snapshot!(output, @r" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 1f8a36f7 conflict | conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file index 0000000000..88425ec521 100644 --- a/file +++ b/file @@ -1,7 +1,1 @@ -<<<<<<< Conflict 1 of 1 -%%%%%%% Changes from base to side #1 --base -+a -+++++++ Contents of side #2 -b ->>>>>>> Conflict 1 of 1 ends +resolution [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" ------- stderr ------- Error: No conflicts found at this revision [EOF] [exit status: 2] "); // Check that the output file starts with conflict markers if // `merge-tool-edits-conflict-markers=true` work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, ["dump editor1", "write\nresolution\n"].join("\0"), ) .unwrap(); work_dir .run_jj([ "resolve", "--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", ]) .success(); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(), @r" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 -base +a +++++++ Contents of side #2 b >>>>>>> Conflict 1 of 1 ends "); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file index 0000000000..88425ec521 100644 --- a/file +++ b/file @@ -1,7 +1,1 @@ -<<<<<<< Conflict 1 of 1 -%%%%%%% Changes from base to side #1 --base -+a -+++++++ Contents of side #2 -b ->>>>>>> Conflict 1 of 1 ends +resolution [EOF] "); // Check that if merge tool leaves conflict markers in output file and // `merge-tool-edits-conflict-markers=true`, these markers are properly parsed. work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ "dump editor2", indoc! {" write <<<<<<< %%%%%%% -some +fake +++++++ conflict >>>>>>> "}, ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj([ "resolve", "--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", ]); insta::assert_snapshot!(output, @r###" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 0d40d2b8 conflict | (conflict) conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files Warning: There are unresolved conflicts at these paths: file 2-sided conflict New conflicts appeared in 1 commits: vruxwmqv 0d40d2b8 conflict | (conflict) conflict Hint: To resolve the conflicts, start by creating a commit on top of the conflicted commit: jj new vruxwmqv Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. [EOF] "###); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor2")).unwrap(), @r" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 -base +a +++++++ Contents of side #2 b >>>>>>> Conflict 1 of 1 ends "); // Note the "Modified" below insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file --- a/file +++ b/file @@ -1,7 +1,7 @@ <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 --base -+a +-some ++fake +++++++ Contents of side #2 -b +conflict >>>>>>> Conflict 1 of 1 ends [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" file 2-sided conflict [EOF] "); // Check that if merge tool leaves conflict markers in output file but // `merge-tool-edits-conflict-markers=false` or is not specified, // `jj` considers the conflict resolved. work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ "dump editor3", indoc! {" write <<<<<<< %%%%%%% -some +fake +++++++ conflict >>>>>>> "}, ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj(["resolve"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 2cc7f5e3 conflict | conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files [EOF] "); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor3")).unwrap(), @""); // Note the "Resolved" below insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file index 0000000000..0610716cc1 100644 --- a/file +++ b/file @@ -1,7 +1,7 @@ -<<<<<<< Conflict 1 of 1 -%%%%%%% Changes from base to side #1 --base -+a -+++++++ Contents of side #2 -b ->>>>>>> Conflict 1 of 1 ends +<<<<<<< +%%%%%%% +-some ++fake ++++++++ +conflict +>>>>>>> [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" ------- stderr ------- Error: No conflicts found at this revision [EOF] [exit status: 2] "); // Check that merge tool can override conflict marker style setting, and that // the merge tool can output Git-style conflict markers work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ "dump editor4", indoc! {" write <<<<<<< some ||||||| fake ======= conflict >>>>>>> "}, ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj([ "resolve", "--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", "--config=merge-tools.fake-editor.conflict-marker-style=git", ]); insta::assert_snapshot!(output, @r###" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv d5f058ec conflict | (conflict) conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files Warning: There are unresolved conflicts at these paths: file 2-sided conflict New conflicts appeared in 1 commits: vruxwmqv d5f058ec conflict | (conflict) conflict Hint: To resolve the conflicts, start by creating a commit on top of the conflicted commit: jj new vruxwmqv Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. [EOF] "###); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor4")).unwrap(), @r" <<<<<<< Side #1 (Conflict 1 of 1) a ||||||| Base base ======= b >>>>>>> Side #2 (Conflict 1 of 1 ends) "); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file --- a/file +++ b/file @@ -1,7 +1,7 @@ <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 --base -+a +-fake ++some +++++++ Contents of side #2 -b +conflict >>>>>>> Conflict 1 of 1 ends [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" file 2-sided conflict [EOF] "); // Check that merge tool can leave conflict markers by returning exit code 1 // when using `merge-conflict-exit-codes = [1]`. The Git "diff3" conflict // markers should also be parsed correctly. work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ "dump editor5", indoc! {" write <<<<<<< some ||||||| fake ======= conflict >>>>>>> "}, "fail", ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj([ "resolve", "--config=merge-tools.fake-editor.merge-conflict-exit-codes=[1]", ]); insta::assert_snapshot!(output, @r###" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 6c205356 conflict | (conflict) conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files Warning: There are unresolved conflicts at these paths: file 2-sided conflict New conflicts appeared in 1 commits: vruxwmqv 6c205356 conflict | (conflict) conflict Hint: To resolve the conflicts, start by creating a commit on top of the conflicted commit: jj new vruxwmqv Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. [EOF] "###); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor5")).unwrap(), @""); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file --- a/file +++ b/file @@ -1,7 +1,7 @@ <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 --base -+a +-fake ++some +++++++ Contents of side #2 -b +conflict >>>>>>> Conflict 1 of 1 ends [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" file 2-sided conflict [EOF] "); // Check that an error is reported if a merge tool indicated it would leave // conflict markers, but the output file didn't contain valid conflict markers. work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ indoc! {" write <<<<<<< this isn't diff3 style! some ======= conflict >>>>>>> "}, "fail", ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj([Lines 1–500 of 2093. Load more
// Copyright 2022 The Jujutsu Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use std::path::Path; use indoc::indoc; use crate::common::create_commit_with_files; use crate::common::CommandOutput; use crate::common::TestEnvironment; use crate::common::TestWorkDir; #[must_use] fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput { work_dir.run_jj(["log", "-T", "bookmarks"]) } #[test] fn test_resolution() { let mut test_env = TestEnvironment::default(); let editor_script = test_env.set_up_fake_editor(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); create_commit_with_files(&work_dir, "base", &[], &[("file", "base\n")]); create_commit_with_files(&work_dir, "a", &["base"], &[("file", "a\n")]); create_commit_with_files(&work_dir, "b", &["base"], &[("file", "b\n")]); create_commit_with_files(&work_dir, "conflict", &["a", "b"], &[]); // Test the setup insta::assert_snapshot!(get_log_output(&work_dir), @r" @ conflict ├─╮ │ ○ b ○ │ a ├─╯ ○ base ◆ [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" file 2-sided conflict [EOF] "); insta::assert_snapshot!(work_dir.read_file("file"), @r" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 -base +a +++++++ Contents of side #2 b >>>>>>> Conflict 1 of 1 ends "); // Check that output file starts out empty and resolve the conflict std::fs::write( &editor_script, ["dump editor0", "write\nresolution\n"].join("\0"), ) .unwrap(); let output = work_dir.run_jj(["resolve"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 741263c9 conflict | conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files [EOF] "); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor0")).unwrap(), @""); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file index 0000000000..88425ec521 100644 --- a/file +++ b/file @@ -1,7 +1,1 @@ -<<<<<<< Conflict 1 of 1 -%%%%%%% Changes from base to side #1 --base -+a -+++++++ Contents of side #2 -b ->>>>>>> Conflict 1 of 1 ends +resolution [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" ------- stderr ------- Error: No conflicts found at this revision [EOF] [exit status: 2] "); // Try again with --tool=<name> work_dir.run_jj(["undo"]).success(); std::fs::write(&editor_script, "write\nresolution\n").unwrap(); let output = work_dir.run_jj([ "resolve", "--config=ui.merge-editor='false'", "--tool=fake-editor", ]); insta::assert_snapshot!(output, @r" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 1f8a36f7 conflict | conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file index 0000000000..88425ec521 100644 --- a/file +++ b/file @@ -1,7 +1,1 @@ -<<<<<<< Conflict 1 of 1 -%%%%%%% Changes from base to side #1 --base -+a -+++++++ Contents of side #2 -b ->>>>>>> Conflict 1 of 1 ends +resolution [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" ------- stderr ------- Error: No conflicts found at this revision [EOF] [exit status: 2] "); // Check that the output file starts with conflict markers if // `merge-tool-edits-conflict-markers=true` work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, ["dump editor1", "write\nresolution\n"].join("\0"), ) .unwrap(); work_dir .run_jj([ "resolve", "--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", ]) .success(); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(), @r" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 -base +a +++++++ Contents of side #2 b >>>>>>> Conflict 1 of 1 ends "); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file index 0000000000..88425ec521 100644 --- a/file +++ b/file @@ -1,7 +1,1 @@ -<<<<<<< Conflict 1 of 1 -%%%%%%% Changes from base to side #1 --base -+a -+++++++ Contents of side #2 -b ->>>>>>> Conflict 1 of 1 ends +resolution [EOF] "); // Check that if merge tool leaves conflict markers in output file and // `merge-tool-edits-conflict-markers=true`, these markers are properly parsed. work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ "dump editor2", indoc! {" write <<<<<<< %%%%%%% -some +fake +++++++ conflict >>>>>>> "}, ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj([ "resolve", "--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", ]); insta::assert_snapshot!(output, @r###" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 0d40d2b8 conflict | (conflict) conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files Warning: There are unresolved conflicts at these paths: file 2-sided conflict New conflicts appeared in 1 commits: vruxwmqv 0d40d2b8 conflict | (conflict) conflict Hint: To resolve the conflicts, start by creating a commit on top of the conflicted commit: jj new vruxwmqv Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. [EOF] "###); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor2")).unwrap(), @r" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 -base +a +++++++ Contents of side #2 b >>>>>>> Conflict 1 of 1 ends "); // Note the "Modified" below insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file --- a/file +++ b/file @@ -1,7 +1,7 @@ <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 --base -+a +-some ++fake +++++++ Contents of side #2 -b +conflict >>>>>>> Conflict 1 of 1 ends [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" file 2-sided conflict [EOF] "); // Check that if merge tool leaves conflict markers in output file but // `merge-tool-edits-conflict-markers=false` or is not specified, // `jj` considers the conflict resolved. work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ "dump editor3", indoc! {" write <<<<<<< %%%%%%% -some +fake +++++++ conflict >>>>>>> "}, ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj(["resolve"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 2cc7f5e3 conflict | conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files [EOF] "); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor3")).unwrap(), @""); // Note the "Resolved" below insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file index 0000000000..0610716cc1 100644 --- a/file +++ b/file @@ -1,7 +1,7 @@ -<<<<<<< Conflict 1 of 1 -%%%%%%% Changes from base to side #1 --base -+a -+++++++ Contents of side #2 -b ->>>>>>> Conflict 1 of 1 ends +<<<<<<< +%%%%%%% +-some ++fake ++++++++ +conflict +>>>>>>> [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" ------- stderr ------- Error: No conflicts found at this revision [EOF] [exit status: 2] "); // Check that merge tool can override conflict marker style setting, and that // the merge tool can output Git-style conflict markers work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ "dump editor4", indoc! {" write <<<<<<< some ||||||| fake ======= conflict >>>>>>> "}, ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj([ "resolve", "--config=merge-tools.fake-editor.merge-tool-edits-conflict-markers=true", "--config=merge-tools.fake-editor.conflict-marker-style=git", ]); insta::assert_snapshot!(output, @r###" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv d5f058ec conflict | (conflict) conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files Warning: There are unresolved conflicts at these paths: file 2-sided conflict New conflicts appeared in 1 commits: vruxwmqv d5f058ec conflict | (conflict) conflict Hint: To resolve the conflicts, start by creating a commit on top of the conflicted commit: jj new vruxwmqv Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. [EOF] "###); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor4")).unwrap(), @r" <<<<<<< Side #1 (Conflict 1 of 1) a ||||||| Base base ======= b >>>>>>> Side #2 (Conflict 1 of 1 ends) "); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file --- a/file +++ b/file @@ -1,7 +1,7 @@ <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 --base -+a +-fake ++some +++++++ Contents of side #2 -b +conflict >>>>>>> Conflict 1 of 1 ends [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" file 2-sided conflict [EOF] "); // Check that merge tool can leave conflict markers by returning exit code 1 // when using `merge-conflict-exit-codes = [1]`. The Git "diff3" conflict // markers should also be parsed correctly. work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ "dump editor5", indoc! {" write <<<<<<< some ||||||| fake ======= conflict >>>>>>> "}, "fail", ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj([ "resolve", "--config=merge-tools.fake-editor.merge-conflict-exit-codes=[1]", ]); insta::assert_snapshot!(output, @r###" ------- stderr ------- Resolving conflicts in: file Working copy (@) now at: vruxwmqv 6c205356 conflict | (conflict) conflict Parent commit (@-) : zsuskuln 45537d53 a | a Parent commit (@-) : royxmykx 89d1b299 b | b Added 0 files, modified 1 files, removed 0 files Warning: There are unresolved conflicts at these paths: file 2-sided conflict New conflicts appeared in 1 commits: vruxwmqv 6c205356 conflict | (conflict) conflict Hint: To resolve the conflicts, start by creating a commit on top of the conflicted commit: jj new vruxwmqv Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. [EOF] "###); insta::assert_snapshot!( std::fs::read_to_string(test_env.env_root().join("editor5")).unwrap(), @""); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @r" diff --git a/file b/file --- a/file +++ b/file @@ -1,7 +1,7 @@ <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 --base -+a +-fake ++some +++++++ Contents of side #2 -b +conflict >>>>>>> Conflict 1 of 1 ends [EOF] "); insta::assert_snapshot!(work_dir.run_jj(["resolve", "--list"]), @r" file 2-sided conflict [EOF] "); // Check that an error is reported if a merge tool indicated it would leave // conflict markers, but the output file didn't contain valid conflict markers. work_dir.run_jj(["undo"]).success(); insta::assert_snapshot!(work_dir.run_jj(["diff", "--git"]), @""); std::fs::write( &editor_script, [ indoc! {" write <<<<<<< this isn't diff3 style! some ======= conflict >>>>>>> "}, "fail", ] .join("\0"), ) .unwrap(); let output = work_dir.run_jj([