mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 00:50:57 +00:00
conflicts: Highlight change ids in rebase advice
This commit is contained in:
parent
bea013acd6
commit
bccd8214df
7 changed files with 55 additions and 48 deletions
|
@ -1296,6 +1296,11 @@ impl WorkspaceCommandHelper {
|
|||
.expect("parse error should be confined by WorkspaceCommandHelper::new()")
|
||||
}
|
||||
|
||||
pub fn short_change_id_template(&self) -> TemplateRenderer<'_, Commit> {
|
||||
self.parse_commit_template("format_short_change_id(self.change_id())")
|
||||
.expect("parse error should be confined by WorkspaceCommandHelper::new()")
|
||||
}
|
||||
|
||||
/// Returns one-line summary of the given `commit`.
|
||||
///
|
||||
/// Use `write_commit_summary()` to get colorized output. Use
|
||||
|
@ -1752,17 +1757,16 @@ See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
.roots()
|
||||
.evaluate_programmatic(repo)?;
|
||||
|
||||
let root_conflict_change_ids: Vec<_> = root_conflicts_revset
|
||||
let root_conflict_commits: Vec<_> = root_conflicts_revset
|
||||
.iter()
|
||||
.commits(repo.store())
|
||||
.map(|maybe_commit| maybe_commit.map(|c| c.change_id().clone()))
|
||||
.try_collect()?;
|
||||
|
||||
if !root_conflict_change_ids.is_empty() {
|
||||
if !root_conflict_commits.is_empty() {
|
||||
fmt.push_label("hint")?;
|
||||
if only_one_conflicted_commit {
|
||||
writeln!(fmt, "To resolve the conflicts, start by updating to it:",)?;
|
||||
} else if root_conflict_change_ids.len() == 1 {
|
||||
} else if root_conflict_commits.len() == 1 {
|
||||
writeln!(
|
||||
fmt,
|
||||
"To resolve the conflicts, start by updating to the first one:",
|
||||
|
@ -1773,8 +1777,11 @@ See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
"To resolve the conflicts, start by updating to one of the first ones:",
|
||||
)?;
|
||||
}
|
||||
for change_id in root_conflict_change_ids {
|
||||
writeln!(fmt, " jj new {}", short_change_hash(&change_id))?;
|
||||
let format_short_change_id = self.short_change_id_template();
|
||||
for commit in root_conflict_commits {
|
||||
write!(fmt, " jj new ")?;
|
||||
format_short_change_id.format(&commit, fmt)?;
|
||||
writeln!(fmt)?;
|
||||
}
|
||||
writeln!(
|
||||
fmt,
|
||||
|
|
|
@ -215,11 +215,11 @@ fn test_chmod_file_dir_deletion_conflicts() {
|
|||
&["file", "chmod", "x", "file", "-r=file_deletion"],
|
||||
);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
New conflicts appeared in these commits:
|
||||
kmkuslsw 1b2ef84c file_deletion | (conflict) file_deletion
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new kmkuslswpqwq
|
||||
jj new kmkuslsw
|
||||
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.
|
||||
|
@ -229,7 +229,7 @@ fn test_chmod_file_dir_deletion_conflicts() {
|
|||
Added 0 files, modified 1 files, removed 0 files
|
||||
There are unresolved conflicts at these paths:
|
||||
file 2-sided conflict including 1 deletion and an executable
|
||||
"###);
|
||||
"#);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["debug", "tree", "-r=file_deletion"]);
|
||||
insta::assert_snapshot!(stdout,
|
||||
@r###"
|
||||
|
|
|
@ -30,13 +30,13 @@ fn test_report_conflicts() {
|
|||
let (stdout, stderr) =
|
||||
test_env.jj_cmd_ok(&repo_path, &["rebase", "-s=description(B)", "-d=root()"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Rebased 3 commits
|
||||
New conflicts appeared in these commits:
|
||||
kkmpptxz 64bdec0c (conflict) C
|
||||
rlvkpnrz 10a5fd45 (conflict) B
|
||||
To resolve the conflicts, start by updating to the first one:
|
||||
jj new rlvkpnrzqnoo
|
||||
jj new rlvkpnrz
|
||||
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.
|
||||
|
@ -45,7 +45,7 @@ fn test_report_conflicts() {
|
|||
Added 0 files, modified 1 files, removed 0 files
|
||||
There are unresolved conflicts at these paths:
|
||||
file 2-sided conflict including 1 deletion
|
||||
"###);
|
||||
"#);
|
||||
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-d=description(A)"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
|
@ -70,8 +70,8 @@ fn test_report_conflicts() {
|
|||
kkmpptxz 17c72220 (conflict) C
|
||||
rlvkpnrz eb93a73d (conflict) B
|
||||
To resolve the conflicts, start by updating to one of the first ones:
|
||||
jj new kkmpptxzrspx
|
||||
jj new rlvkpnrzqnoo
|
||||
jj new kkmpptxz
|
||||
jj new rlvkpnrz
|
||||
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.
|
||||
|
@ -121,7 +121,7 @@ fn test_report_conflicts_with_divergent_commits() {
|
|||
let (stdout, stderr) =
|
||||
test_env.jj_cmd_ok(&repo_path, &["rebase", "-s=description(B)", "-d=root()"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Concurrent modification detected, resolving automatically.
|
||||
Rebased 3 commits
|
||||
New conflicts appeared in these commits:
|
||||
|
@ -129,7 +129,7 @@ fn test_report_conflicts_with_divergent_commits() {
|
|||
zsuskuln?? 97ce1783 (conflict) C2
|
||||
kkmpptxz eb93a73d (conflict) B
|
||||
To resolve the conflicts, start by updating to the first one:
|
||||
jj new kkmpptxzrspx
|
||||
jj new kkmpptxz
|
||||
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.
|
||||
|
@ -138,7 +138,7 @@ fn test_report_conflicts_with_divergent_commits() {
|
|||
Added 0 files, modified 1 files, removed 0 files
|
||||
There are unresolved conflicts at these paths:
|
||||
file 2-sided conflict including 1 deletion
|
||||
"###);
|
||||
"#);
|
||||
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-d=description(A)"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
|
@ -157,12 +157,12 @@ fn test_report_conflicts_with_divergent_commits() {
|
|||
let (stdout, stderr) =
|
||||
test_env.jj_cmd_ok(&repo_path, &["rebase", "-s=description(C2)", "-d=root()"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Rebased 1 commits
|
||||
New conflicts appeared in these commits:
|
||||
zsuskuln?? b15416ac (conflict) C2
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new zsuskulnrvyr
|
||||
jj new zsuskuln
|
||||
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.
|
||||
|
@ -171,21 +171,21 @@ fn test_report_conflicts_with_divergent_commits() {
|
|||
Added 0 files, modified 1 files, removed 0 files
|
||||
There are unresolved conflicts at these paths:
|
||||
file 2-sided conflict including 1 deletion
|
||||
"###);
|
||||
"#);
|
||||
|
||||
let (stdout, stderr) =
|
||||
test_env.jj_cmd_ok(&repo_path, &["rebase", "-s=description(C3)", "-d=root()"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Rebased 1 commits
|
||||
New conflicts appeared in these commits:
|
||||
zsuskuln?? 8cc7fde6 (conflict) C3
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new zsuskulnrvyr
|
||||
jj new zsuskuln
|
||||
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.
|
||||
"###);
|
||||
"#);
|
||||
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(
|
||||
&repo_path,
|
||||
|
|
|
@ -235,12 +235,12 @@ fn test_resolution() {
|
|||
],
|
||||
);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Resolving conflicts in: file
|
||||
New conflicts appeared in these commits:
|
||||
vruxwmqv 7699b9c3 conflict | (conflict) conflict
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new vruxwmqvtpmx
|
||||
jj new vruxwmqv
|
||||
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.
|
||||
|
@ -250,7 +250,7 @@ fn test_resolution() {
|
|||
Added 0 files, modified 1 files, removed 0 files
|
||||
There are unresolved conflicts at these paths:
|
||||
file 2-sided conflict
|
||||
"###);
|
||||
"#);
|
||||
insta::assert_snapshot!(
|
||||
std::fs::read_to_string(test_env.env_root().join("editor2")).unwrap(), @r###"
|
||||
<<<<<<< Conflict 1 of 1
|
||||
|
@ -590,12 +590,12 @@ fn test_simplify_conflict_sides() {
|
|||
],
|
||||
);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Resolving conflicts in: fileB
|
||||
New conflicts appeared in these commits:
|
||||
nkmrtpmo 4b14662a conflict | (conflict) conflict
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new nkmrtpmomlro
|
||||
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.
|
||||
|
@ -606,7 +606,7 @@ fn test_simplify_conflict_sides() {
|
|||
There are unresolved conflicts at these paths:
|
||||
fileA 2-sided conflict
|
||||
fileB 2-sided conflict
|
||||
"###);
|
||||
"#);
|
||||
insta::assert_snapshot!(std::fs::read_to_string(repo_path.join("fileB")).unwrap(), @r###"
|
||||
<<<<<<< Conflict 1 of 1
|
||||
%%%%%%% Changes from base to side #1
|
||||
|
@ -860,12 +860,12 @@ fn test_multiple_conflicts() {
|
|||
std::fs::write(&editor_script, "expect\n\0write\nresolution another_file\n").unwrap();
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["resolve", "another_file"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Resolving conflicts in: another_file
|
||||
New conflicts appeared in these commits:
|
||||
vruxwmqv 6a90e546 conflict | (conflict) conflict
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new vruxwmqvtpmx
|
||||
jj new vruxwmqv
|
||||
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.
|
||||
|
@ -875,7 +875,7 @@ fn test_multiple_conflicts() {
|
|||
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
|
||||
"###);
|
||||
"#);
|
||||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["diff", "--git"]),
|
||||
@r###"
|
||||
diff --git a/another_file b/another_file
|
||||
|
|
|
@ -58,13 +58,13 @@ fn test_restore() {
|
|||
"###);
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["restore", "-c=@-"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Created rlvkpnrz b9b6011e (empty) (no description set)
|
||||
Rebased 1 descendant commits
|
||||
New conflicts appeared in these commits:
|
||||
kkmpptxz d05c4d2a (conflict) (no description set)
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new kkmpptxzrspx
|
||||
jj new kkmpptxz
|
||||
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.
|
||||
|
@ -73,7 +73,7 @@ fn test_restore() {
|
|||
Added 0 files, modified 1 files, removed 0 files
|
||||
There are unresolved conflicts at these paths:
|
||||
file2 2-sided conflict including 1 deletion
|
||||
"###);
|
||||
"#);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s", "-r=@-"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
|
||||
|
|
|
@ -686,18 +686,18 @@ fn test_squash_from_multiple() {
|
|||
let (stdout, stderr) =
|
||||
test_env.jj_cmd_ok(&repo_path, &["squash", "--from=b", "--from=c", "--into=d"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Rebased 2 descendant commits
|
||||
New conflicts appeared in these commits:
|
||||
yqosqzyt 98759deb d | (conflict) (no description set)
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new yqosqzytrlsw
|
||||
jj new yqosqzyt
|
||||
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.
|
||||
Working copy now at: kpqxywon 3e25ee21 f | (no description set)
|
||||
Parent commit : yostqsxw abb5a4ea e | (no description set)
|
||||
"###);
|
||||
"#);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
@ 3e25ee211f3f f
|
||||
○ abb5a4ea1222 e
|
||||
|
@ -811,18 +811,18 @@ fn test_squash_from_multiple_partial() {
|
|||
let (stdout, stderr) =
|
||||
test_env.jj_cmd_ok(&repo_path, &["squash", "--from=b|c", "--into=d", "file1"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Rebased 2 descendant commits
|
||||
New conflicts appeared in these commits:
|
||||
yqosqzyt b91b1157 d | (conflict) (no description set)
|
||||
To resolve the conflicts, start by updating to it:
|
||||
jj new yqosqzytrlsw
|
||||
jj new yqosqzyt
|
||||
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.
|
||||
Working copy now at: kpqxywon 056dc38b f | (no description set)
|
||||
Parent commit : yostqsxw 45069475 e | (no description set)
|
||||
"###);
|
||||
"#);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
@ 056dc38bf286 f
|
||||
○ 450694753699 e
|
||||
|
|
|
@ -197,18 +197,18 @@ fn test_status_display_relevant_working_commit_conflict_hints() {
|
|||
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["status"]);
|
||||
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
insta::assert_snapshot!(stdout, @r#"
|
||||
The working copy is clean
|
||||
There are unresolved conflicts at these paths:
|
||||
conflicted.txt 2-sided conflict
|
||||
Working copy : yqosqzyt 65143fef (conflict) (empty) boom-cont-2
|
||||
Parent commit: royxmykx a4e88714 (conflict) (empty) boom-cont
|
||||
To resolve the conflicts, start by updating to the first one:
|
||||
jj new mzvwutvlkqwt
|
||||
jj new mzvwutvl
|
||||
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.
|
||||
"###);
|
||||
"#);
|
||||
|
||||
// Resolve conflict
|
||||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "fixed 1"]);
|
||||
|
@ -352,7 +352,7 @@ fn test_status_simplify_conflict_sides() {
|
|||
);
|
||||
|
||||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["status"]),
|
||||
@r###"
|
||||
@r#"
|
||||
The working copy is clean
|
||||
There are unresolved conflicts at these paths:
|
||||
fileA 2-sided conflict
|
||||
|
@ -361,10 +361,10 @@ fn test_status_simplify_conflict_sides() {
|
|||
Parent commit: kmkuslsw 18c1fb00 conflictA | (conflict) (empty) conflictA
|
||||
Parent commit: lylxulpl d11c92eb conflictB | (conflict) (empty) conflictB
|
||||
To resolve the conflicts, start by updating to one of the first ones:
|
||||
jj new lylxulplsnyw
|
||||
jj new kmkuslswpqwq
|
||||
jj new lylxulpl
|
||||
jj new kmkuslsw
|
||||
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.
|
||||
"###);
|
||||
"#);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue