2022-11-27 07:22:34 +00:00
|
|
|
|
// 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;
|
|
|
|
|
|
2024-03-23 02:34:28 +00:00
|
|
|
|
use indoc::indoc;
|
|
|
|
|
|
2022-11-27 07:22:34 +00:00
|
|
|
|
use crate::common::TestEnvironment;
|
|
|
|
|
|
|
|
|
|
fn create_commit(
|
|
|
|
|
test_env: &TestEnvironment,
|
|
|
|
|
repo_path: &Path,
|
|
|
|
|
name: &str,
|
|
|
|
|
parents: &[&str],
|
|
|
|
|
files: &[(&str, &str)],
|
|
|
|
|
) {
|
|
|
|
|
if parents.is_empty() {
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(repo_path, &["new", "root()", "-m", name]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
} else {
|
|
|
|
|
let mut args = vec!["new", "-m", name];
|
|
|
|
|
args.extend(parents);
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(repo_path, &args);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
for (name, content) in files {
|
|
|
|
|
std::fs::write(repo_path.join(name), content).unwrap();
|
|
|
|
|
}
|
2024-08-21 19:59:15 +00:00
|
|
|
|
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String {
|
2024-08-21 19:59:15 +00:00
|
|
|
|
test_env.jj_cmd_success(repo_path, &["log", "-T", "bookmarks"])
|
2022-11-27 07:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_resolution() {
|
|
|
|
|
let mut test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
create_commit(&test_env, &repo_path, "base", &[], &[("file", "base\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "a", &["base"], &[("file", "a\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "b", &["base"], &[("file", "b\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflict", &["a", "b"], &[]);
|
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2023-02-09 02:53:47 +00:00
|
|
|
|
@ conflict
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ b
|
|
|
|
|
○ │ a
|
2023-02-09 02:53:47 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ base
|
|
|
|
|
◆
|
2023-02-09 02:53:47 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
2023-01-07 19:09:55 +00:00
|
|
|
|
@r###"
|
|
|
|
|
file 2-sided conflict
|
|
|
|
|
"###);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(repo_path.join("file")).unwrap()
|
|
|
|
|
, @r###"
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
|
|
|
|
-base
|
|
|
|
|
+a
|
|
|
|
|
+++++++ Contents of side #2
|
|
|
|
|
b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
"###);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
|
|
|
|
|
let editor_script = test_env.set_up_fake_editor();
|
2022-10-31 02:41:19 +00:00
|
|
|
|
// Check that output file starts out empty and resolve the conflict
|
2022-12-22 07:58:23 +00:00
|
|
|
|
std::fs::write(
|
|
|
|
|
&editor_script,
|
|
|
|
|
["dump editor0", "write\nresolution\n"].join("\0"),
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["resolve"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2023-12-20 01:25:01 +00:00
|
|
|
|
Resolving conflicts in: file
|
2023-08-08 03:11:59 +00:00
|
|
|
|
Working copy now at: vruxwmqv e069f073 conflict | conflict
|
|
|
|
|
Parent commit : zsuskuln aa493daf a | a
|
|
|
|
|
Parent commit : royxmykx db6a4daf b | b
|
2022-12-24 01:57:10 +00:00
|
|
|
|
Added 0 files, modified 1 files, removed 0 files
|
|
|
|
|
"###);
|
2022-12-22 07:58:23 +00:00
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(test_env.env_root().join("editor0")).unwrap(), @r###"
|
|
|
|
|
"###);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
@r###"
|
2024-03-23 22:39:58 +00:00
|
|
|
|
diff --git a/file b/file
|
2024-07-14 10:26:07 +00:00
|
|
|
|
index 0000000000..88425ec521 100644
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--- a/file
|
|
|
|
|
+++ b/file
|
|
|
|
|
@@ -1,7 +1,1 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-<<<<<<< Conflict 1 of 1
|
|
|
|
|
-%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--base
|
|
|
|
|
-+a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-+++++++ Contents of side #2
|
2024-03-23 22:39:58 +00:00
|
|
|
|
-b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
->>>>>>> Conflict 1 of 1 ends
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+resolution
|
2022-10-31 02:41:19 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_cli_error(&repo_path, &["resolve", "--list"]),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
@r###"
|
2022-12-04 03:47:03 +00:00
|
|
|
|
Error: No conflicts found at this revision
|
2022-10-31 02:41:19 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
2024-03-01 14:49:22 +00:00
|
|
|
|
// Try again with --tool=<name>
|
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
|
|
|
|
std::fs::write(&editor_script, "write\nresolution\n").unwrap();
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(
|
|
|
|
|
&repo_path,
|
|
|
|
|
&[
|
|
|
|
|
"resolve",
|
|
|
|
|
"--config-toml=ui.merge-editor='false'",
|
|
|
|
|
"--tool=fake-editor",
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
|
|
|
|
Resolving conflicts in: file
|
|
|
|
|
Working copy now at: vruxwmqv 1a70c7c6 conflict | conflict
|
|
|
|
|
Parent commit : zsuskuln aa493daf a | a
|
|
|
|
|
Parent commit : royxmykx db6a4daf b | b
|
|
|
|
|
Added 0 files, modified 1 files, removed 0 files
|
|
|
|
|
"###);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2024-03-01 14:49:22 +00:00
|
|
|
|
@r###"
|
2024-03-23 22:39:58 +00:00
|
|
|
|
diff --git a/file b/file
|
2024-07-14 10:26:07 +00:00
|
|
|
|
index 0000000000..88425ec521 100644
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--- a/file
|
|
|
|
|
+++ b/file
|
|
|
|
|
@@ -1,7 +1,1 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-<<<<<<< Conflict 1 of 1
|
|
|
|
|
-%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--base
|
|
|
|
|
-+a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-+++++++ Contents of side #2
|
2024-03-23 22:39:58 +00:00
|
|
|
|
-b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
->>>>>>> Conflict 1 of 1 ends
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+resolution
|
2024-03-01 14:49:22 +00:00
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_cli_error(&repo_path, &["resolve", "--list"]),
|
|
|
|
|
@r###"
|
|
|
|
|
Error: No conflicts found at this revision
|
|
|
|
|
"###);
|
|
|
|
|
|
2022-10-31 02:41:19 +00:00
|
|
|
|
// Check that the output file starts with conflict markers if
|
|
|
|
|
// `merge-tool-edits-conflict-markers=true`
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
@"");
|
2022-11-27 07:22:34 +00:00
|
|
|
|
std::fs::write(
|
2022-10-31 02:41:19 +00:00
|
|
|
|
&editor_script,
|
2022-12-22 07:58:23 +00:00
|
|
|
|
["dump editor1", "write\nresolution\n"].join("\0"),
|
2022-11-27 07:22:34 +00:00
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(
|
2022-10-31 02:41:19 +00:00
|
|
|
|
&repo_path,
|
|
|
|
|
&[
|
|
|
|
|
"resolve",
|
|
|
|
|
"--config-toml",
|
|
|
|
|
"merge-tools.fake-editor.merge-tool-edits-conflict-markers=true",
|
|
|
|
|
],
|
|
|
|
|
);
|
2022-12-22 07:58:23 +00:00
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(), @r###"
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
2022-12-22 07:58:23 +00:00
|
|
|
|
-base
|
|
|
|
|
+a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
+++++++ Contents of side #2
|
2022-12-22 07:58:23 +00:00
|
|
|
|
b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
2022-12-22 07:58:23 +00:00
|
|
|
|
"###);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-11-27 07:22:34 +00:00
|
|
|
|
@r###"
|
2024-03-23 22:39:58 +00:00
|
|
|
|
diff --git a/file b/file
|
2024-07-14 10:26:07 +00:00
|
|
|
|
index 0000000000..88425ec521 100644
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--- a/file
|
|
|
|
|
+++ b/file
|
|
|
|
|
@@ -1,7 +1,1 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-<<<<<<< Conflict 1 of 1
|
|
|
|
|
-%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--base
|
|
|
|
|
-+a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-+++++++ Contents of side #2
|
2024-03-23 22:39:58 +00:00
|
|
|
|
-b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
->>>>>>> Conflict 1 of 1 ends
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+resolution
|
2022-11-27 07:22:34 +00:00
|
|
|
|
"###);
|
2022-10-31 02:41:19 +00:00
|
|
|
|
|
|
|
|
|
// Check that if merge tool leaves conflict markers in output file and
|
|
|
|
|
// `merge-tool-edits-conflict-markers=true`, these markers are properly parsed.
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
@"");
|
|
|
|
|
std::fs::write(
|
|
|
|
|
&editor_script,
|
2022-12-22 07:58:23 +00:00
|
|
|
|
[
|
|
|
|
|
"dump editor2",
|
2024-03-23 02:34:28 +00:00
|
|
|
|
indoc! {"
|
|
|
|
|
write
|
|
|
|
|
<<<<<<<
|
|
|
|
|
%%%%%%%
|
|
|
|
|
-some
|
|
|
|
|
+fake
|
|
|
|
|
+++++++
|
|
|
|
|
conflict
|
|
|
|
|
>>>>>>>
|
|
|
|
|
"},
|
2022-12-22 07:58:23 +00:00
|
|
|
|
]
|
|
|
|
|
.join("\0"),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(
|
|
|
|
|
&repo_path,
|
|
|
|
|
&[
|
|
|
|
|
"resolve",
|
|
|
|
|
"--config-toml",
|
|
|
|
|
"merge-tools.fake-editor.merge-tool-edits-conflict-markers=true",
|
|
|
|
|
],
|
|
|
|
|
);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
2024-09-21 16:08:19 +00:00
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2023-12-20 01:25:01 +00:00
|
|
|
|
Resolving conflicts in: file
|
2024-09-21 16:08:19 +00:00
|
|
|
|
Working copy now at: vruxwmqv 7699b9c3 conflict | (conflict) conflict
|
|
|
|
|
Parent commit : zsuskuln aa493daf a | a
|
|
|
|
|
Parent commit : royxmykx db6a4daf b | b
|
|
|
|
|
Added 0 files, modified 1 files, removed 0 files
|
|
|
|
|
There are unresolved conflicts at these paths:
|
|
|
|
|
file 2-sided conflict
|
2023-11-20 02:10:39 +00:00
|
|
|
|
New conflicts appeared in these commits:
|
2024-04-21 19:37:19 +00:00
|
|
|
|
vruxwmqv 7699b9c3 conflict | (conflict) conflict
|
2023-11-30 07:02:18 +00:00
|
|
|
|
To resolve the conflicts, start by updating to it:
|
2024-09-12 10:49:08 +00:00
|
|
|
|
jj new vruxwmqv
|
2023-11-30 07:02:18 +00:00
|
|
|
|
Then use `jj resolve`, or edit the conflict markers in the file directly.
|
2024-07-16 17:30:40 +00:00
|
|
|
|
Once the conflicts are resolved, you may want to inspect the result with `jj diff`.
|
2023-11-30 07:02:18 +00:00
|
|
|
|
Then run `jj squash` to move the resolution into the conflicted commit.
|
2024-09-21 16:08:19 +00:00
|
|
|
|
"###);
|
2022-12-22 07:58:23 +00:00
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(test_env.env_root().join("editor2")).unwrap(), @r###"
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
2022-12-22 07:58:23 +00:00
|
|
|
|
-base
|
|
|
|
|
+a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
+++++++ Contents of side #2
|
2022-12-22 07:58:23 +00:00
|
|
|
|
b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
2022-12-22 07:58:23 +00:00
|
|
|
|
"###);
|
2022-10-31 02:41:19 +00:00
|
|
|
|
// Note the "Modified" below
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
@r###"
|
2024-03-23 22:39:58 +00:00
|
|
|
|
diff --git a/file b/file
|
|
|
|
|
--- a/file
|
|
|
|
|
+++ b/file
|
|
|
|
|
@@ -1,7 +1,7 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--base
|
|
|
|
|
-+a
|
|
|
|
|
+-some
|
|
|
|
|
++fake
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
+++++++ Contents of side #2
|
2024-03-23 22:39:58 +00:00
|
|
|
|
-b
|
|
|
|
|
+conflict
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
2022-10-31 02:41:19 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
2023-01-07 19:09:55 +00:00
|
|
|
|
@r###"
|
|
|
|
|
file 2-sided conflict
|
|
|
|
|
"###);
|
2022-10-31 02:41:19 +00:00
|
|
|
|
|
|
|
|
|
// 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.
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
@"");
|
|
|
|
|
std::fs::write(
|
|
|
|
|
&editor_script,
|
2022-12-22 07:58:23 +00:00
|
|
|
|
[
|
|
|
|
|
"dump editor3",
|
2024-03-23 02:34:28 +00:00
|
|
|
|
indoc! {"
|
|
|
|
|
write
|
|
|
|
|
<<<<<<<
|
|
|
|
|
%%%%%%%
|
|
|
|
|
-some
|
|
|
|
|
+fake
|
|
|
|
|
+++++++
|
|
|
|
|
conflict
|
|
|
|
|
>>>>>>>
|
|
|
|
|
"},
|
2022-12-22 07:58:23 +00:00
|
|
|
|
]
|
|
|
|
|
.join("\0"),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["resolve"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2023-12-20 01:25:01 +00:00
|
|
|
|
Resolving conflicts in: file
|
2024-03-01 14:49:22 +00:00
|
|
|
|
Working copy now at: vruxwmqv 3166dfd2 conflict | conflict
|
2023-08-08 03:11:59 +00:00
|
|
|
|
Parent commit : zsuskuln aa493daf a | a
|
|
|
|
|
Parent commit : royxmykx db6a4daf b | b
|
2022-12-24 01:57:10 +00:00
|
|
|
|
Added 0 files, modified 1 files, removed 0 files
|
|
|
|
|
"###);
|
2022-12-22 07:58:23 +00:00
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(test_env.env_root().join("editor3")).unwrap(), @r###"
|
|
|
|
|
"###);
|
2022-10-31 02:41:19 +00:00
|
|
|
|
// Note the "Resolved" below
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
@r###"
|
2024-03-23 22:39:58 +00:00
|
|
|
|
diff --git a/file b/file
|
2024-07-14 10:26:07 +00:00
|
|
|
|
index 0000000000..0610716cc1 100644
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--- a/file
|
|
|
|
|
+++ b/file
|
|
|
|
|
@@ -1,7 +1,7 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-<<<<<<< Conflict 1 of 1
|
|
|
|
|
-%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--base
|
|
|
|
|
-+a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-+++++++ Contents of side #2
|
|
|
|
|
-b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
->>>>>>> Conflict 1 of 1 ends
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
+<<<<<<<
|
|
|
|
|
+%%%%%%%
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+-some
|
|
|
|
|
++fake
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
++++++++
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+conflict
|
2024-05-16 01:00:50 +00:00
|
|
|
|
+>>>>>>>
|
2022-10-31 02:41:19 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_cli_error(&repo_path, &["resolve", "--list"]),
|
2022-10-31 02:41:19 +00:00
|
|
|
|
@r###"
|
2022-12-04 03:47:03 +00:00
|
|
|
|
Error: No conflicts found at this revision
|
2022-10-31 02:41:19 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
|
|
|
|
|
// TODO: Check that running `jj new` and then `jj resolve -r conflict` works
|
|
|
|
|
// correctly.
|
2022-11-27 07:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn check_resolve_produces_input_file(
|
|
|
|
|
test_env: &mut TestEnvironment,
|
|
|
|
|
repo_path: &Path,
|
2024-05-30 22:58:43 +00:00
|
|
|
|
filename: &str,
|
2022-11-27 07:22:34 +00:00
|
|
|
|
role: &str,
|
|
|
|
|
expected_content: &str,
|
|
|
|
|
) {
|
|
|
|
|
let editor_script = test_env.set_up_fake_editor();
|
|
|
|
|
std::fs::write(editor_script, format!("expect\n{expected_content}")).unwrap();
|
|
|
|
|
|
|
|
|
|
let merge_arg_config = format!(r#"merge-tools.fake-editor.merge-args = ["${role}"]"#);
|
|
|
|
|
// This error means that fake-editor exited successfully but did not modify the
|
|
|
|
|
// output file.
|
2022-12-06 05:39:05 +00:00
|
|
|
|
// We cannot use `insta::assert_snapshot!` here after insta 1.22 due to
|
|
|
|
|
// https://github.com/mitsuhiko/insta/commit/745b45b. Hopefully, this will again become possible
|
|
|
|
|
// in the future. See also https://github.com/mitsuhiko/insta/issues/313.
|
|
|
|
|
assert_eq!(
|
2024-05-30 22:58:43 +00:00
|
|
|
|
test_env.jj_cmd_failure(
|
|
|
|
|
repo_path,
|
|
|
|
|
&["resolve", "--config-toml", &merge_arg_config, filename]
|
|
|
|
|
),
|
|
|
|
|
format!(
|
|
|
|
|
"Resolving conflicts in: {filename}\nError: Failed to resolve conflicts\nCaused by: \
|
|
|
|
|
The output file is either unchanged or empty after the editor quit (run with --debug \
|
|
|
|
|
to see the exact invocation).\n"
|
|
|
|
|
)
|
2022-12-06 05:39:05 +00:00
|
|
|
|
);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_normal_conflict_input_files() {
|
|
|
|
|
let mut test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
create_commit(&test_env, &repo_path, "base", &[], &[("file", "base\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "a", &["base"], &[("file", "a\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "b", &["base"], &[("file", "b\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflict", &["a", "b"], &[]);
|
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2023-02-09 02:53:47 +00:00
|
|
|
|
@ conflict
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ b
|
|
|
|
|
○ │ a
|
2023-02-09 02:53:47 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ base
|
|
|
|
|
◆
|
2023-02-09 02:53:47 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
2023-01-07 19:09:55 +00:00
|
|
|
|
@r###"
|
|
|
|
|
file 2-sided conflict
|
|
|
|
|
"###);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(repo_path.join("file")).unwrap()
|
|
|
|
|
, @r###"
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
|
|
|
|
-base
|
|
|
|
|
+a
|
|
|
|
|
+++++++ Contents of side #2
|
|
|
|
|
b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
"###);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
|
2024-05-30 22:58:43 +00:00
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "base", "base\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "left", "a\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "right", "b\n");
|
2022-11-27 07:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_baseless_conflict_input_files() {
|
|
|
|
|
let mut test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
create_commit(&test_env, &repo_path, "base", &[], &[]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "a", &["base"], &[("file", "a\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "b", &["base"], &[("file", "b\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflict", &["a", "b"], &[]);
|
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2023-02-09 02:53:47 +00:00
|
|
|
|
@ conflict
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ b
|
|
|
|
|
○ │ a
|
2023-02-09 02:53:47 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ base
|
|
|
|
|
◆
|
2023-02-09 02:53:47 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
2023-01-07 19:09:55 +00:00
|
|
|
|
@r###"
|
|
|
|
|
file 2-sided conflict
|
|
|
|
|
"###);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(repo_path.join("file")).unwrap()
|
|
|
|
|
, @r###"
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
2023-02-17 18:05:47 +00:00
|
|
|
|
+a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
+++++++ Contents of side #2
|
2022-11-27 07:22:34 +00:00
|
|
|
|
b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
2022-11-27 07:22:34 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
2024-05-30 22:58:43 +00:00
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "base", "");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "left", "a\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "right", "b\n");
|
2022-11-27 07:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_too_many_parents() {
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
create_commit(&test_env, &repo_path, "base", &[], &[("file", "base\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "a", &["base"], &[("file", "a\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "b", &["base"], &[("file", "b\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "c", &["base"], &[("file", "c\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflict", &["a", "b", "c"], &[]);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
2023-01-07 19:09:55 +00:00
|
|
|
|
@r###"
|
|
|
|
|
file 3-sided conflict
|
|
|
|
|
"###);
|
2023-01-07 18:21:38 +00:00
|
|
|
|
// Test warning color
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list", "--color=always"]),
|
|
|
|
|
@r###"
|
2023-01-13 08:39:22 +00:00
|
|
|
|
file [38;5;1m3-sided[38;5;3m conflict[39m
|
2023-01-07 18:21:38 +00:00
|
|
|
|
"###);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
|
2022-12-04 03:47:03 +00:00
|
|
|
|
let error = test_env.jj_cmd_failure(&repo_path, &["resolve"]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
insta::assert_snapshot!(error, @r###"
|
2024-03-24 06:47:47 +00:00
|
|
|
|
Hint: Using default editor ':builtin'; run `jj config set --user ui.merge-editor :builtin` to disable this message.
|
2023-12-20 01:25:01 +00:00
|
|
|
|
Resolving conflicts in: file
|
2024-01-31 11:45:03 +00:00
|
|
|
|
Error: Failed to resolve conflicts
|
|
|
|
|
Caused by: The conflict at "file" has 3 sides. At most 2 sides are supported.
|
2022-11-27 07:22:34 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 22:58:27 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn test_simplify_conflict_sides() {
|
2024-05-30 22:58:45 +00:00
|
|
|
|
let mut test_env = TestEnvironment::default();
|
2024-05-30 22:58:27 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
// Creates a 4-sided conflict, with fileA and fileB having different conflicts:
|
|
|
|
|
// fileA: A - B + C - B + B - B + B
|
|
|
|
|
// fileB: A - A + A - A + B - C + D
|
|
|
|
|
create_commit(
|
|
|
|
|
&test_env,
|
|
|
|
|
&repo_path,
|
|
|
|
|
"base",
|
|
|
|
|
&[],
|
|
|
|
|
&[("fileA", "base\n"), ("fileB", "base\n")],
|
|
|
|
|
);
|
|
|
|
|
create_commit(&test_env, &repo_path, "a1", &["base"], &[("fileA", "1\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "a2", &["base"], &[("fileA", "2\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "b1", &["base"], &[("fileB", "1\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "b2", &["base"], &[("fileB", "2\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflictA", &["a1", "a2"], &[]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflictB", &["b1", "b2"], &[]);
|
|
|
|
|
create_commit(
|
|
|
|
|
&test_env,
|
|
|
|
|
&repo_path,
|
|
|
|
|
"conflict",
|
|
|
|
|
&["conflictA", "conflictB"],
|
|
|
|
|
&[],
|
|
|
|
|
);
|
|
|
|
|
|
2024-05-30 22:58:36 +00:00
|
|
|
|
// Even though the tree-level conflict is a 4-sided conflict, each file is
|
|
|
|
|
// materialized as a 2-sided conflict.
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["debug", "tree"]),
|
|
|
|
|
@r###"
|
|
|
|
|
fileA: Ok(Conflicted([Some(File { id: FileId("d00491fd7e5bb6fa28c517a0bb32b8b506539d4d"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("0cfbf08886fca9a91cb753ec8734c84fcbe52c9f"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false })]))
|
|
|
|
|
fileB: Ok(Conflicted([Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("d00491fd7e5bb6fa28c517a0bb32b8b506539d4d"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("0cfbf08886fca9a91cb753ec8734c84fcbe52c9f"), executable: false })]))
|
|
|
|
|
"###);
|
2024-05-30 22:58:27 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
|
|
|
|
@r###"
|
2024-05-30 22:58:41 +00:00
|
|
|
|
fileA 2-sided conflict
|
|
|
|
|
fileB 2-sided conflict
|
2024-05-30 22:58:27 +00:00
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(repo_path.join("fileA")).unwrap(), @r###"
|
|
|
|
|
<<<<<<< Conflict 1 of 1
|
2024-05-30 22:58:36 +00:00
|
|
|
|
%%%%%%% Changes from base to side #1
|
2024-05-30 22:58:27 +00:00
|
|
|
|
-base
|
|
|
|
|
+1
|
|
|
|
|
+++++++ Contents of side #2
|
|
|
|
|
2
|
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(repo_path.join("fileB")).unwrap(), @r###"
|
|
|
|
|
<<<<<<< Conflict 1 of 1
|
2024-05-30 22:58:36 +00:00
|
|
|
|
%%%%%%% Changes from base to side #1
|
2024-05-30 22:58:27 +00:00
|
|
|
|
-base
|
|
|
|
|
+1
|
2024-05-30 22:58:36 +00:00
|
|
|
|
+++++++ Contents of side #2
|
2024-05-30 22:58:27 +00:00
|
|
|
|
2
|
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
|
|
|
|
"###);
|
|
|
|
|
|
2024-05-30 22:58:45 +00:00
|
|
|
|
// Conflict should be simplified before being handled by external merge tool.
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "fileA", "base", "base\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "fileA", "left", "1\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "fileA", "right", "2\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "fileB", "base", "base\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "fileB", "left", "1\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "fileB", "right", "2\n");
|
|
|
|
|
|
|
|
|
|
// Check that simplified conflicts are still parsed as conflicts after editing
|
|
|
|
|
// when `merge-tool-edits-conflict-markers=true`.
|
|
|
|
|
let editor_script = test_env.set_up_fake_editor();
|
|
|
|
|
std::fs::write(
|
|
|
|
|
editor_script,
|
|
|
|
|
indoc! {"
|
|
|
|
|
write
|
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
|
|
|
|
-base_edited
|
|
|
|
|
+1_edited
|
|
|
|
|
+++++++ Contents of side #2
|
|
|
|
|
2_edited
|
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
|
|
|
|
"},
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(
|
|
|
|
|
&repo_path,
|
|
|
|
|
&[
|
|
|
|
|
"resolve",
|
|
|
|
|
"--config-toml",
|
|
|
|
|
"merge-tools.fake-editor.merge-tool-edits-conflict-markers=true",
|
|
|
|
|
"fileB",
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
2024-09-21 16:08:19 +00:00
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2024-05-30 22:58:27 +00:00
|
|
|
|
Resolving conflicts in: fileB
|
2024-05-30 22:58:45 +00:00
|
|
|
|
Working copy now at: nkmrtpmo 4b14662a conflict | (conflict) conflict
|
|
|
|
|
Parent commit : kmkuslsw 18c1fb00 conflictA | (conflict) (empty) conflictA
|
|
|
|
|
Parent commit : lylxulpl d11c92eb conflictB | (conflict) (empty) conflictB
|
|
|
|
|
Added 0 files, modified 1 files, removed 0 files
|
|
|
|
|
There are unresolved conflicts at these paths:
|
|
|
|
|
fileA 2-sided conflict
|
|
|
|
|
fileB 2-sided conflict
|
2024-09-21 16:08:19 +00:00
|
|
|
|
New conflicts appeared in these commits:
|
|
|
|
|
nkmrtpmo 4b14662a conflict | (conflict) conflict
|
|
|
|
|
To resolve the conflicts, start by updating to it:
|
|
|
|
|
jj new nkmrtpmo
|
|
|
|
|
Then use `jj resolve`, or edit the conflict markers in the file directly.
|
|
|
|
|
Once the conflicts are resolved, you may want to inspect the result with `jj diff`.
|
|
|
|
|
Then run `jj squash` to move the resolution into the conflicted commit.
|
|
|
|
|
"###);
|
2024-05-30 22:58:45 +00:00
|
|
|
|
insta::assert_snapshot!(std::fs::read_to_string(repo_path.join("fileB")).unwrap(), @r###"
|
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
|
|
|
|
-base_edited
|
|
|
|
|
+1_edited
|
|
|
|
|
+++++++ Contents of side #2
|
|
|
|
|
2_edited
|
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
|
|
|
|
@r###"
|
|
|
|
|
fileA 2-sided conflict
|
|
|
|
|
fileB 2-sided conflict
|
2024-05-30 22:58:27 +00:00
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-27 07:22:34 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn test_edit_delete_conflict_input_files() {
|
|
|
|
|
let mut test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
create_commit(&test_env, &repo_path, "base", &[], &[("file", "base\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "a", &["base"], &[("file", "a\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "b", &["base"], &[]);
|
|
|
|
|
std::fs::remove_file(repo_path.join("file")).unwrap();
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflict", &["a", "b"], &[]);
|
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2023-02-09 02:53:47 +00:00
|
|
|
|
@ conflict
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ b
|
|
|
|
|
○ │ a
|
2023-02-09 02:53:47 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ base
|
|
|
|
|
◆
|
2023-02-09 02:53:47 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
|
|
|
|
@r###"
|
2023-01-07 19:09:55 +00:00
|
|
|
|
file 2-sided conflict including 1 deletion
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
insta::assert_snapshot!(
|
|
|
|
|
std::fs::read_to_string(repo_path.join("file")).unwrap()
|
|
|
|
|
, @r###"
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
+++++++ Contents of side #1
|
2023-02-17 18:05:47 +00:00
|
|
|
|
a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
%%%%%%% Changes from base to side #2
|
conflicts: preserve order of adds in materialized conflict
We write conflict to the working copy by materializing them as
conflict markers in a file. When the file has been modified (or just
the mtime has changed), we parse the markers to reconstruct the
conflict. For example, let's say we see this conflict marker:
```
<<<<<<<
+++++++
b
%%%%%%%
-a
+c
>>>>>>>
```
Then we will create a hunk with ["a"] as removed and ["b", "c"] as
added.
Now, since commit b84be06c0822, when we materialize conflicts, we
minimize the diff part of the marker (the `%%%%%%%` part). The problem
is that that minimization may result in a different order of the
positive conflict terms. That's particularly bad because we do the
minimization per hunk, so we can end up reconstructing an input that
never existed.
This commit fixes the bug by only considering the next add and the one
after that, and emitting either only the first with `%%%%%%%`, or both
of them, with the first one in `++++++++` and the second one in
`%%%%%%%`.
Note that the recent fix to add context to modify/delete conflicts
means that when we parse modified such conflicts, we'll always
consider them resolved, since the expected adds/removes we pass will
not match what's actually in the file. That doesn't seem so bad, and
it's not obvious what the fix should be, so I'll leave that for later.
2023-02-18 06:29:30 +00:00
|
|
|
|
-base
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
2022-11-27 07:22:34 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
2024-05-30 22:58:43 +00:00
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "base", "base\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "left", "a\n");
|
|
|
|
|
check_resolve_produces_input_file(&mut test_env, &repo_path, "file", "right", "");
|
2022-11-27 07:22:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_file_vs_dir() {
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
create_commit(&test_env, &repo_path, "base", &[], &[("file", "base\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "a", &["base"], &[("file", "a\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "b", &["base"], &[]);
|
|
|
|
|
std::fs::remove_file(repo_path.join("file")).unwrap();
|
|
|
|
|
std::fs::create_dir(repo_path.join("file")).unwrap();
|
|
|
|
|
// Without a placeholder file, `jj` ignores an empty directory
|
|
|
|
|
std::fs::write(repo_path.join("file").join("placeholder"), "").unwrap();
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflict", &["a", "b"], &[]);
|
2023-01-05 00:34:56 +00:00
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2023-02-09 02:53:47 +00:00
|
|
|
|
@ conflict
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ b
|
|
|
|
|
○ │ a
|
2023-02-09 02:53:47 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ base
|
|
|
|
|
◆
|
2023-02-09 02:53:47 +00:00
|
|
|
|
"###);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
|
|
|
|
@r###"
|
2023-01-07 19:09:55 +00:00
|
|
|
|
file 2-sided conflict including a directory
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
let error = test_env.jj_cmd_failure(&repo_path, &["resolve"]);
|
2022-11-27 07:22:34 +00:00
|
|
|
|
insta::assert_snapshot!(error, @r###"
|
2024-03-24 06:47:47 +00:00
|
|
|
|
Hint: Using default editor ':builtin'; run `jj config set --user ui.merge-editor :builtin` to disable this message.
|
2023-12-20 01:25:01 +00:00
|
|
|
|
Resolving conflicts in: file
|
2024-01-31 11:45:03 +00:00
|
|
|
|
Error: Failed to resolve conflicts
|
|
|
|
|
Caused by: Only conflicts that involve normal files (not symlinks, not executable, etc.) are supported. Conflict summary for "file":
|
2022-12-04 07:10:10 +00:00
|
|
|
|
Conflict:
|
2022-11-27 07:22:34 +00:00
|
|
|
|
Removing file with id df967b96a579e45a18b8251732d16804b2e56a55
|
|
|
|
|
Adding file with id 78981922613b2afb6025042ff6bd878ac1994e85
|
|
|
|
|
Adding tree with id 133bb38fc4e4bf6b551f1f04db7e48f04cac2877
|
|
|
|
|
|
|
|
|
|
"###);
|
|
|
|
|
}
|
2022-12-04 03:47:03 +00:00
|
|
|
|
|
2023-01-05 00:34:56 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn test_description_with_dir_and_deletion() {
|
|
|
|
|
let test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2023-01-05 00:34:56 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
create_commit(&test_env, &repo_path, "base", &[], &[("file", "base\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "edit", &["base"], &[("file", "b\n")]);
|
|
|
|
|
create_commit(&test_env, &repo_path, "dir", &["base"], &[]);
|
|
|
|
|
std::fs::remove_file(repo_path.join("file")).unwrap();
|
|
|
|
|
std::fs::create_dir(repo_path.join("file")).unwrap();
|
|
|
|
|
// Without a placeholder file, `jj` ignores an empty directory
|
|
|
|
|
std::fs::write(repo_path.join("file").join("placeholder"), "").unwrap();
|
|
|
|
|
create_commit(&test_env, &repo_path, "del", &["base"], &[]);
|
|
|
|
|
std::fs::remove_file(repo_path.join("file")).unwrap();
|
|
|
|
|
create_commit(
|
|
|
|
|
&test_env,
|
|
|
|
|
&repo_path,
|
|
|
|
|
"conflict",
|
|
|
|
|
&["edit", "dir", "del"],
|
|
|
|
|
&[],
|
|
|
|
|
);
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2023-02-09 02:53:47 +00:00
|
|
|
|
@ conflict
|
|
|
|
|
├─┬─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ │ ○ del
|
|
|
|
|
│ ○ │ dir
|
revset_graph: group commits topologically
The original idea was similar to Mercurial's "topo" sorting, but it was bad
at handling merge-heavy history. In order to render merges of topic branches
nicely, we need to prioritize branches at merge point, not at fork point.
OTOH, we do also want to place unmerged branches as close to the fork point
as possible. This commit implements the former requirement, and the latter
will be addressed by the next commit.
I think this is similar to Git's sorting logic described in the following blog
post. In our case, the in-degree walk can be dumb since topological order is
guaranteed by the index. We keep HashSet<CommitId> instead of an in-degree
integer value, which will be used in the next commit to resolve new heads as
late as possible.
https://github.blog/2022-08-30-gits-database-internals-ii-commit-history-queries/#topological-sorting
Compared to Sapling's beautify_graph(), this is lazy, and can roughly preserve
the index (or chronological) order. I tried beautify_graph() with prioritizing
the @ commit, but the result seemed too aggressively reordered. Perhaps, for
more complex history, beautify_graph() would produce a better result. For my
wip branches (~30 branches, a couple of commits per branch), this works pretty
well.
#242
2023-07-16 10:47:46 +00:00
|
|
|
|
│ ├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ │ edit
|
revset_graph: group commits topologically
The original idea was similar to Mercurial's "topo" sorting, but it was bad
at handling merge-heavy history. In order to render merges of topic branches
nicely, we need to prioritize branches at merge point, not at fork point.
OTOH, we do also want to place unmerged branches as close to the fork point
as possible. This commit implements the former requirement, and the latter
will be addressed by the next commit.
I think this is similar to Git's sorting logic described in the following blog
post. In our case, the in-degree walk can be dumb since topological order is
guaranteed by the index. We keep HashSet<CommitId> instead of an in-degree
integer value, which will be used in the next commit to resolve new heads as
late as possible.
https://github.blog/2022-08-30-gits-database-internals-ii-commit-history-queries/#topological-sorting
Compared to Sapling's beautify_graph(), this is lazy, and can roughly preserve
the index (or chronological) order. I tried beautify_graph() with prioritizing
the @ commit, but the result seemed too aggressively reordered. Perhaps, for
more complex history, beautify_graph() would produce a better result. For my
wip branches (~30 branches, a couple of commits per branch), this works pretty
well.
#242
2023-07-16 10:47:46 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ base
|
|
|
|
|
◆
|
2023-01-05 00:34:56 +00:00
|
|
|
|
"###);
|
|
|
|
|
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
|
|
|
|
@r###"
|
2023-01-07 19:09:55 +00:00
|
|
|
|
file 3-sided conflict including 1 deletion and a directory
|
2023-01-05 00:34:56 +00:00
|
|
|
|
"###);
|
2023-01-07 18:21:38 +00:00
|
|
|
|
// Test warning color. The deletion is fine, so it's not highlighted
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list", "--color=always"]),
|
|
|
|
|
@r###"
|
2023-01-13 08:39:22 +00:00
|
|
|
|
file [38;5;1m3-sided[38;5;3m conflict including 1 deletion and [38;5;1ma directory[39m
|
2023-01-07 18:21:38 +00:00
|
|
|
|
"###);
|
2023-01-05 00:34:56 +00:00
|
|
|
|
let error = test_env.jj_cmd_failure(&repo_path, &["resolve"]);
|
|
|
|
|
insta::assert_snapshot!(error, @r###"
|
2024-03-24 06:47:47 +00:00
|
|
|
|
Hint: Using default editor ':builtin'; run `jj config set --user ui.merge-editor :builtin` to disable this message.
|
2023-12-20 01:25:01 +00:00
|
|
|
|
Resolving conflicts in: file
|
2024-01-31 11:45:03 +00:00
|
|
|
|
Error: Failed to resolve conflicts
|
|
|
|
|
Caused by: Only conflicts that involve normal files (not symlinks, not executable, etc.) are supported. Conflict summary for "file":
|
2023-01-05 00:34:56 +00:00
|
|
|
|
Conflict:
|
|
|
|
|
Removing file with id df967b96a579e45a18b8251732d16804b2e56a55
|
|
|
|
|
Removing file with id df967b96a579e45a18b8251732d16804b2e56a55
|
|
|
|
|
Adding file with id 61780798228d17af2d34fce4cfbdf35556832472
|
|
|
|
|
Adding tree with id 133bb38fc4e4bf6b551f1f04db7e48f04cac2877
|
|
|
|
|
|
|
|
|
|
"###);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 03:47:03 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn test_multiple_conflicts() {
|
|
|
|
|
let mut test_env = TestEnvironment::default();
|
2024-05-17 19:49:25 +00:00
|
|
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
let repo_path = test_env.env_root().join("repo");
|
|
|
|
|
|
|
|
|
|
create_commit(
|
|
|
|
|
&test_env,
|
|
|
|
|
&repo_path,
|
|
|
|
|
"base",
|
|
|
|
|
&[],
|
2023-01-07 19:09:55 +00:00
|
|
|
|
&[
|
|
|
|
|
(
|
|
|
|
|
"this_file_has_a_very_long_name_to_test_padding",
|
|
|
|
|
"first base\n",
|
|
|
|
|
),
|
|
|
|
|
("another_file", "second base\n"),
|
|
|
|
|
],
|
2022-12-04 03:47:03 +00:00
|
|
|
|
);
|
|
|
|
|
create_commit(
|
|
|
|
|
&test_env,
|
|
|
|
|
&repo_path,
|
|
|
|
|
"a",
|
|
|
|
|
&["base"],
|
2023-01-07 19:09:55 +00:00
|
|
|
|
&[
|
|
|
|
|
(
|
|
|
|
|
"this_file_has_a_very_long_name_to_test_padding",
|
|
|
|
|
"first a\n",
|
|
|
|
|
),
|
|
|
|
|
("another_file", "second a\n"),
|
|
|
|
|
],
|
2022-12-04 03:47:03 +00:00
|
|
|
|
);
|
|
|
|
|
create_commit(
|
|
|
|
|
&test_env,
|
|
|
|
|
&repo_path,
|
|
|
|
|
"b",
|
|
|
|
|
&["base"],
|
2023-01-07 19:09:55 +00:00
|
|
|
|
&[
|
|
|
|
|
(
|
|
|
|
|
"this_file_has_a_very_long_name_to_test_padding",
|
|
|
|
|
"first b\n",
|
|
|
|
|
),
|
|
|
|
|
("another_file", "second b\n"),
|
|
|
|
|
],
|
2022-12-04 03:47:03 +00:00
|
|
|
|
);
|
|
|
|
|
create_commit(&test_env, &repo_path, "conflict", &["a", "b"], &[]);
|
|
|
|
|
// Test the setup
|
|
|
|
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
2023-02-09 02:53:47 +00:00
|
|
|
|
@ conflict
|
|
|
|
|
├─╮
|
2024-07-15 22:20:10 +00:00
|
|
|
|
│ ○ b
|
|
|
|
|
○ │ a
|
2023-02-09 02:53:47 +00:00
|
|
|
|
├─╯
|
2024-07-15 22:20:10 +00:00
|
|
|
|
○ base
|
|
|
|
|
◆
|
2023-02-09 02:53:47 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(
|
2023-01-07 19:09:55 +00:00
|
|
|
|
std::fs::read_to_string(repo_path.join("this_file_has_a_very_long_name_to_test_padding")).unwrap()
|
2022-12-04 03:47:03 +00:00
|
|
|
|
, @r###"
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
2022-12-04 03:47:03 +00:00
|
|
|
|
-first base
|
|
|
|
|
+first a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
+++++++ Contents of side #2
|
2022-12-04 03:47:03 +00:00
|
|
|
|
first b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(
|
2023-01-07 19:09:55 +00:00
|
|
|
|
std::fs::read_to_string(repo_path.join("another_file")).unwrap()
|
2022-12-04 03:47:03 +00:00
|
|
|
|
, @r###"
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
<<<<<<< Conflict 1 of 1
|
|
|
|
|
%%%%%%% Changes from base to side #1
|
2022-12-04 03:47:03 +00:00
|
|
|
|
-second base
|
|
|
|
|
+second a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
+++++++ Contents of side #2
|
2022-12-04 03:47:03 +00:00
|
|
|
|
second b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
>>>>>>> Conflict 1 of 1 ends
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
|
|
|
|
@r###"
|
2023-01-07 19:09:55 +00:00
|
|
|
|
another_file 2-sided conflict
|
|
|
|
|
this_file_has_a_very_long_name_to_test_padding 2-sided conflict
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
2023-01-07 18:21:38 +00:00
|
|
|
|
// Test colors
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list", "--color=always"]),
|
|
|
|
|
@r###"
|
formatter: use `crossterm` for colors
Let's use `crossterm` to make `ColorFormatter` a little more readable,
and maybe also more portable.
This uses the `SetForegroundColor()` function, which uses the escapes
for 256-color support (code 38) instead of the 8-color escapes (codes
30-37) combined with bold/bright (code 1) we were using before. IIUC,
most terminals support the 16 base colors when using the 256-color
escape even if they don't support all the 256 colors. It seems like an
improvement to use actual color codes for the bright colors too,
instead of assuming that terminals render bold as bright (even though
most terminals do).
Before this commit, we relied on ANSI escape 1 - which is specified to
make the font bold - to make the color brighter. That's why we call
the colors "bright blue" etc. When we switch from using code 30-37 to
using 38 to let our color config just control the color (not using
escape1), we therefore lose the bold font on many terminals (at least
in iTerm2 and in the terminal application on my Debian work
computer). As a workaround, I made us still use escape 1 when the
bright colors are used. I'll make boldness a separately configurable
attribute soon. Then we'll be able to remove this hack.
With the switch to `crossterm`, we also reset just the foreground
color (code 39) instead of resetting all attributes (code 0). That
also seems like an improvement, probably making it easier for us to
later support different background colors, underlining, etc.
2022-12-27 07:23:19 +00:00
|
|
|
|
another_file [38;5;3m2-sided conflict[39m
|
|
|
|
|
this_file_has_a_very_long_name_to_test_padding [38;5;3m2-sided conflict[39m
|
2023-01-07 18:21:38 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
|
|
|
|
|
let editor_script = test_env.set_up_fake_editor();
|
|
|
|
|
|
|
|
|
|
// Check that we can manually pick which of the conflicts to resolve first
|
2023-01-07 19:09:55 +00:00
|
|
|
|
std::fs::write(&editor_script, "expect\n\0write\nresolution another_file\n").unwrap();
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["resolve", "another_file"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
2024-09-21 16:08:19 +00:00
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2023-12-20 01:25:01 +00:00
|
|
|
|
Resolving conflicts in: another_file
|
2024-09-21 16:08:19 +00:00
|
|
|
|
Working copy now at: vruxwmqv 6a90e546 conflict | (conflict) conflict
|
|
|
|
|
Parent commit : zsuskuln de7553ef a | a
|
|
|
|
|
Parent commit : royxmykx f68bc2f0 b | b
|
|
|
|
|
Added 0 files, modified 1 files, removed 0 files
|
|
|
|
|
There are unresolved conflicts at these paths:
|
|
|
|
|
this_file_has_a_very_long_name_to_test_padding 2-sided conflict
|
2023-11-20 02:10:39 +00:00
|
|
|
|
New conflicts appeared in these commits:
|
2024-04-21 19:37:19 +00:00
|
|
|
|
vruxwmqv 6a90e546 conflict | (conflict) conflict
|
2023-11-30 07:02:18 +00:00
|
|
|
|
To resolve the conflicts, start by updating to it:
|
2024-09-12 10:49:08 +00:00
|
|
|
|
jj new vruxwmqv
|
2023-11-30 07:02:18 +00:00
|
|
|
|
Then use `jj resolve`, or edit the conflict markers in the file directly.
|
2024-07-16 17:30:40 +00:00
|
|
|
|
Once the conflicts are resolved, you may want to inspect the result with `jj diff`.
|
2023-11-30 07:02:18 +00:00
|
|
|
|
Then run `jj squash` to move the resolution into the conflicted commit.
|
2024-09-21 16:08:19 +00:00
|
|
|
|
"###);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-12-04 03:47:03 +00:00
|
|
|
|
@r###"
|
2024-03-23 22:39:58 +00:00
|
|
|
|
diff --git a/another_file b/another_file
|
2024-07-14 10:26:07 +00:00
|
|
|
|
index 0000000000..a9fcc7d486 100644
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--- a/another_file
|
|
|
|
|
+++ b/another_file
|
|
|
|
|
@@ -1,7 +1,1 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-<<<<<<< Conflict 1 of 1
|
|
|
|
|
-%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--second base
|
|
|
|
|
-+second a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-+++++++ Contents of side #2
|
2024-03-23 22:39:58 +00:00
|
|
|
|
-second b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
->>>>>>> Conflict 1 of 1 ends
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+resolution another_file
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
2023-01-07 19:09:55 +00:00
|
|
|
|
@r###"
|
2023-01-07 19:09:55 +00:00
|
|
|
|
this_file_has_a_very_long_name_to_test_padding 2-sided conflict
|
2023-01-07 19:09:55 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
|
2022-12-24 01:57:10 +00:00
|
|
|
|
// Repeat the above with the `--quiet` option.
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
2023-01-07 19:09:55 +00:00
|
|
|
|
std::fs::write(&editor_script, "expect\n\0write\nresolution another_file\n").unwrap();
|
2023-10-10 11:59:18 +00:00
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["resolve", "--quiet", "another_file"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
|
insta::assert_snapshot!(stdout, @"");
|
2024-03-30 17:18:56 +00:00
|
|
|
|
insta::assert_snapshot!(stderr, @"");
|
2022-12-24 01:57:10 +00:00
|
|
|
|
|
2022-12-04 03:47:03 +00:00
|
|
|
|
// For the rest of the test, we call `jj resolve` several times in a row to
|
|
|
|
|
// resolve each conflict in the order it chooses.
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-12-04 03:47:03 +00:00
|
|
|
|
@"");
|
|
|
|
|
std::fs::write(
|
|
|
|
|
&editor_script,
|
|
|
|
|
"expect\n\0write\nfirst resolution for auto-chosen file\n",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["resolve"]);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-12-04 03:47:03 +00:00
|
|
|
|
@r###"
|
2024-03-23 22:39:58 +00:00
|
|
|
|
diff --git a/another_file b/another_file
|
2024-07-14 10:26:07 +00:00
|
|
|
|
index 0000000000..7903e1c1c7 100644
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--- a/another_file
|
|
|
|
|
+++ b/another_file
|
|
|
|
|
@@ -1,7 +1,1 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-<<<<<<< Conflict 1 of 1
|
|
|
|
|
-%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--second base
|
|
|
|
|
-+second a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-+++++++ Contents of side #2
|
2024-03-23 22:39:58 +00:00
|
|
|
|
-second b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
->>>>>>> Conflict 1 of 1 ends
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+first resolution for auto-chosen file
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["resolve", "--list"]),
|
2023-01-07 19:09:55 +00:00
|
|
|
|
@r###"
|
2023-01-07 19:09:55 +00:00
|
|
|
|
this_file_has_a_very_long_name_to_test_padding 2-sided conflict
|
2023-01-07 19:09:55 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
std::fs::write(
|
|
|
|
|
&editor_script,
|
|
|
|
|
"expect\n\0write\nsecond resolution for auto-chosen file\n",
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
2023-10-10 11:59:18 +00:00
|
|
|
|
test_env.jj_cmd_ok(&repo_path, &["resolve"]);
|
2024-03-23 22:39:58 +00:00
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
2022-12-04 03:47:03 +00:00
|
|
|
|
@r###"
|
2024-03-23 22:39:58 +00:00
|
|
|
|
diff --git a/another_file b/another_file
|
2024-07-14 10:26:07 +00:00
|
|
|
|
index 0000000000..7903e1c1c7 100644
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--- a/another_file
|
|
|
|
|
+++ b/another_file
|
|
|
|
|
@@ -1,7 +1,1 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-<<<<<<< Conflict 1 of 1
|
|
|
|
|
-%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--second base
|
|
|
|
|
-+second a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-+++++++ Contents of side #2
|
2024-03-23 22:39:58 +00:00
|
|
|
|
-second b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
->>>>>>> Conflict 1 of 1 ends
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+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
|
2024-07-14 10:26:07 +00:00
|
|
|
|
index 0000000000..f8c72adf17 100644
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--- a/this_file_has_a_very_long_name_to_test_padding
|
|
|
|
|
+++ b/this_file_has_a_very_long_name_to_test_padding
|
|
|
|
|
@@ -1,7 +1,1 @@
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-<<<<<<< Conflict 1 of 1
|
|
|
|
|
-%%%%%%% Changes from base to side #1
|
2024-03-23 22:39:58 +00:00
|
|
|
|
--first base
|
|
|
|
|
-+first a
|
conflicts.rs: label conflict number and sides next to conflict markers
For example,
```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```
or
```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```
Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.
Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.
While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.
I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.
Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-03-23 22:16:28 +00:00
|
|
|
|
-+++++++ Contents of side #2
|
2024-03-23 22:39:58 +00:00
|
|
|
|
-first b
|
2024-05-16 01:00:50 +00:00
|
|
|
|
->>>>>>> Conflict 1 of 1 ends
|
2024-03-23 22:39:58 +00:00
|
|
|
|
+second resolution for auto-chosen file
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
2022-12-04 03:47:03 +00:00
|
|
|
|
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_cli_error(&repo_path, &["resolve", "--list"]),
|
2022-12-04 03:47:03 +00:00
|
|
|
|
@r###"
|
2022-12-04 03:47:03 +00:00
|
|
|
|
Error: No conflicts found at this revision
|
2022-12-04 03:47:03 +00:00
|
|
|
|
"###);
|
|
|
|
|
insta::assert_snapshot!(test_env.jj_cmd_cli_error(&repo_path, &["resolve"]),
|
|
|
|
|
@r###"
|
|
|
|
|
Error: No conflicts found at this revision
|
|
|
|
|
"###);
|
|
|
|
|
}
|