Skip to content

Commit

Permalink
log node template: mark empty un-conflicted commits with
Browse files Browse the repository at this point in the history
This is useful to see which merges resolve conflicts and to more easily
sort WIP commits.

Some ideas I thought about and decided against:

- `∅` looked too messy

- I considered using green for "empty", and yellow for "non-empty
  working copy", but I think the dotted circle is visible enough and
making the working copy stand out is more important.

- There's the option of using `○` for empty commits and `●` for
  non-empty, but I personally feel like so many `●`s would look too heavy.
  • Loading branch information
ilyagr committed Aug 21, 2024
1 parent a83dadd commit f369749
Show file tree
Hide file tree
Showing 27 changed files with 1,098 additions and 1,097 deletions.
1 change: 1 addition & 0 deletions cli/src/config/templates.toml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ coalesce(
if(current_working_copy, "@"),
if(immutable, "◆"),
if(conflict, "×"),
if(empty, "◌"),
"○",
)
)
Expand Down
150 changes: 75 additions & 75 deletions cli/tests/test_advance_branches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ fn test_advance_branches_enabled(make_commit: CommitFn) {
// Run jj commit, which will advance the branch pointing to @-.
make_commit(&test_env, &workspace_path, "first");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{test_branch} desc: first
branches{test_branch} desc: first
◆ branches{} desc:
"###);
"#);
}

// Now disable advance branches and commit again. The branch shouldn't move.
set_advance_branches(&test_env, false);
make_commit(&test_env, &workspace_path, "second");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{} desc: second
branches{test_branch} desc: first
branches{} desc: second
branches{test_branch} desc: first
◆ branches{} desc:
"###);
"#);
}
}

Expand All @@ -125,24 +125,24 @@ fn test_advance_branches_at_minus(make_commit: CommitFn) {

make_commit(&test_env, &workspace_path, "first");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{test_branch} desc: first
branches{test_branch} desc: first
◆ branches{} desc:
"###);
"#);
}

// Create a second branch pointing to @. On the next commit, only the first
// branch, which points to @-, will advance.
test_env.jj_cmd_ok(&workspace_path, &["branch", "create", "test_branch2"]);
make_commit(&test_env, &workspace_path, "second");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{test_branch test_branch2} desc: second
branches{} desc: first
branches{test_branch test_branch2} desc: second
branches{} desc: first
◆ branches{} desc:
"###);
"#);
}
}

Expand Down Expand Up @@ -172,11 +172,11 @@ fn test_advance_branches_overrides(make_commit: CommitFn) {
// Commit will not advance the branch since advance-branches is disabled.
make_commit(&test_env, &workspace_path, "first");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{} desc: first
branches{} desc: first
◆ branches{test_branch} desc:
"###);
"#);
}

// Now enable advance branches for "test_branch", move the branch, and commit
Expand All @@ -191,20 +191,20 @@ fn test_advance_branches_overrides(make_commit: CommitFn) {
&["branch", "set", "test_branch", "-r", "@-"],
);
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{test_branch} desc: first
branches{test_branch} desc: first
◆ branches{} desc:
"###);
"#);
}
make_commit(&test_env, &workspace_path, "second");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{test_branch} desc: second
branches{} desc: first
branches{test_branch} desc: second
branches{} desc: first
◆ branches{} desc:
"###);
"#);
}

// Now disable advance branches for "test_branch" and "second_branch", which
Expand All @@ -217,13 +217,13 @@ fn test_advance_branches_overrides(make_commit: CommitFn) {
);
make_commit(&test_env, &workspace_path, "third");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{} desc: third
branches{test_branch} desc: second
branches{} desc: first
branches{} desc: third
branches{test_branch} desc: second
branches{} desc: first
◆ branches{} desc:
"###);
"#);
}

// If we create a new branch at @- and move test_branch there as well. When
Expand All @@ -237,24 +237,24 @@ fn test_advance_branches_overrides(make_commit: CommitFn) {
&["branch", "set", "test_branch", "-r", "@-"],
);
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{second_branch test_branch} desc: third
branches{} desc: second
branches{} desc: first
branches{second_branch test_branch} desc: third
branches{} desc: second
branches{} desc: first
◆ branches{} desc:
"###);
"#);
}
make_commit(&test_env, &workspace_path, "fourth");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{second_branch} desc: fourth
branches{test_branch} desc: third
branches{} desc: second
branches{} desc: first
branches{second_branch} desc: fourth
branches{test_branch} desc: third
branches{} desc: second
branches{} desc: first
◆ branches{} desc:
"###);
"#);
}
}

Expand Down Expand Up @@ -287,11 +287,11 @@ fn test_advance_branches_multiple_branches(make_commit: CommitFn) {
// Both branches are eligible and both will advance.
make_commit(&test_env, &workspace_path, "first");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{first_branch second_branch} desc: first
branches{first_branch second_branch} desc: first
◆ branches{} desc:
"###);
"#);
}
}

Expand Down Expand Up @@ -319,23 +319,23 @@ fn test_new_advance_branches_interior() {
&workspace_path,
&["branch", "create", "-r", "@---", "test_branch"],
);
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{} desc: third
branches{} desc: second
branches{test_branch} desc: first
branches{} desc: third
branches{} desc: second
branches{test_branch} desc: first
◆ branches{} desc:
"###);
"#);

test_env.jj_cmd_ok(&workspace_path, &["new", "-r", "@--"]);
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{} desc: third
branches{} desc: third
├─╯
branches{test_branch} desc: second
branches{} desc: first
branches{test_branch} desc: second
branches{} desc: first
◆ branches{} desc:
"###);
"#);
}

// If the `--before` flag is passed to `jj new`, branches are not advanced.
Expand All @@ -361,22 +361,22 @@ fn test_new_advance_branches_before() {
&workspace_path,
&["branch", "create", "-r", "@---", "test_branch"],
);
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{} desc: third
branches{} desc: second
branches{test_branch} desc: first
branches{} desc: third
branches{} desc: second
branches{test_branch} desc: first
◆ branches{} desc:
"###);
"#);

test_env.jj_cmd_ok(&workspace_path, &["new", "--before", "@-"]);
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
branches{} desc: third
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
branches{} desc: third
@ branches{} desc:
branches{} desc: second
branches{test_branch} desc: first
branches{} desc: second
branches{test_branch} desc: first
◆ branches{} desc:
"###);
"#);
}

// If the `--after` flag is passed to `jj new`, branches are not advanced.
Expand All @@ -400,11 +400,11 @@ fn test_new_advance_branches_after() {

test_env.jj_cmd_ok(&workspace_path, &["describe", "-m", "first"]);
test_env.jj_cmd_ok(&workspace_path, &["new", "--after", "@"]);
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
branches{} desc: first
branches{} desc: first
◆ branches{test_branch} desc:
"###);
"#);
}

#[test]
Expand All @@ -423,26 +423,26 @@ fn test_new_advance_branches_merge_children() {
);

// Check the initial state of the repo.
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc: 2
branches{} desc: 1
branches{} desc: 1
├─╯
branches{test_branch} desc: 0
branches{test_branch} desc: 0
◆ branches{} desc:
"###);
"#);

// The branch won't advance because `jj new` had multiple targets.
test_env.jj_cmd_ok(
&workspace_path,
&["new", "description(1)", "description(2)"],
);
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r###"
insta::assert_snapshot!(get_log_output_with_branches(&test_env, &workspace_path), @r#"
@ branches{} desc:
├─╮
branches{} desc: 2
│ branches{} desc: 1
branches{} desc: 2
│ branches{} desc: 1
├─╯
branches{test_branch} desc: 0
branches{test_branch} desc: 0
◆ branches{} desc:
"###);
"#);
}
12 changes: 6 additions & 6 deletions cli/tests/test_backout_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,21 @@ fn test_backout_multiple() {
create_commit(&test_env, &repo_path, "e", &["d"], &[("a", "a\nb\nc\n")]);

// Test the setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r#"
@ 208f8612074a e
ceeec03be46b d
ceeec03be46b d
○ 413337bbd11f c
○ 46cc97af6802 b
○ 2443ea76b0b1 a
◆ 000000000000
"###);
"#);

// Backout multiple commits
let (stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["backout", "-r", "b", "-r", "c", "-r", "e"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r#"
○ 6504c4ded177 Back out "b"
│ This backs out commit 46cc97af6802301d8db381386e8485ff3ff24ae6.
Expand All @@ -134,12 +134,12 @@ fn test_backout_multiple() {
│ This backs out commit 208f8612074af4c219d06568a8e1f04f2e80dc25.
@ 208f8612074a e
ceeec03be46b d
ceeec03be46b d
○ 413337bbd11f c
○ 46cc97af6802 b
○ 2443ea76b0b1 a
◆ 000000000000
"###);
"#);
// View the output of each backed out commit
let stdout = test_env.jj_cmd_success(&repo_path, &["show", "@+"]);
insta::assert_snapshot!(stdout, @r###"
Expand Down
Loading

0 comments on commit f369749

Please sign in to comment.