Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: use shiny, colored graph nodes by default #3381

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `templates.log_node`
* `templates.op_log_node`

* A default configuration for `templates.log_node` is now provided which, out of
the box, uses visually distinct nodes with distinct colors, for ease of
reading.

Please see [the documentation](https://martinvonz.github.io/jj/v0.16.0/config/#node-style)
for `templates.log_node` for the default symbols, and an example of how to
re-configure this behavior and provide your own symbols.

* `jj log` now includes synthetic nodes in the graph where some revisions were
elided.

Expand Down
7 changes: 7 additions & 0 deletions cli/src/config/colors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@
"op_log current_operation id" = "bright blue"
"op_log current_operation user" = "yellow" # No bright yellow, see comment above
"op_log current_operation time" = "bright cyan"

"node" = { bold = true }
"node elided" = { fg = "bright black" }
"node working_copy" = { fg = "green" }
"node immutable" = { fg = "bright cyan" }
"node wip" = { fg = "yellow" }
"node normal" = { bold = false }
13 changes: 13 additions & 0 deletions cli/src/config/templates.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ log = 'builtin_log_compact'
op_log = 'builtin_op_log_compact'
show = 'builtin_log_detailed'

op_log_node = 'if(current_operation, "@", "◉")'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to make the "normal" symbol consistent with log_node? Do we want to make labels/colors consistent?


log_node = '''
label("node",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: perhaps, "node" should be moved to the caller (as we do for "op_log"), but that can be addressed later.

coalesce(
if(!self, label("elided", "⇋")),
if(current_working_copy, label("working_copy", "@")),
if(immutable, label("immutable", "◆")),
label("normal", "○")
)
)
'''

[template-aliases]
builtin_log_oneline = '''
if(root,
Expand Down
104 changes: 52 additions & 52 deletions cli/tests/test_abandon_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ fn test_basics() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] e
├─╮
[vru] d
[roy] c
│ │ [zsu] b
[vru] d
[roy] c
│ │ [zsu] b
├───╯
│ [rlv] a
│ [rlv] a
├─╯
[zzz]
[zzz]
"###);

let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["abandon", "d"]);
Expand All @@ -65,12 +65,12 @@ fn test_basics() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] e
├─╮
[roy] c d
│ │ [zsu] b
[roy] c d
│ │ [zsu] b
├───╯
│ [rlv] a
│ [rlv] a
├─╯
[zzz]
[zzz]
"###);

test_env.jj_cmd_ok(&repo_path, &["undo"]);
Expand All @@ -84,13 +84,13 @@ fn test_basics() {
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [nkm]
[zsu] b
[zsu] b
├─╯
[rlv] a e??
[vru] d e??
[roy] c
[rlv] a e??
[vru] d e??
[roy] c
├─╯
[zzz]
[zzz]
"###);

test_env.jj_cmd_ok(&repo_path, &["undo"]);
Expand All @@ -107,10 +107,10 @@ fn test_basics() {
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [xtn]
[zsu] b
[zsu] b
├─╯
[rlv] a e??
[zzz] c d e??
[rlv] a e??
[zzz] c d e??
"###);

// Test abandoning the same commit twice directly
Expand All @@ -123,11 +123,11 @@ fn test_basics() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] e
├─╮
[vru] d
[roy] c
│ [rlv] a b
[vru] d
[roy] c
│ [rlv] a b
├─╯
[zzz]
[zzz]
"###);

// Test abandoning the same commit twice indirectly
Expand All @@ -146,9 +146,9 @@ fn test_basics() {
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [xlz]
[roy] c d e??
[roy] c d e??
├─╯
[zzz] a b e??
[zzz] a b e??
"###);

let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["abandon", "none()"]);
Expand Down Expand Up @@ -177,13 +177,13 @@ fn test_bug_2600() {
// Test the setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] c
[vru] b
[vru] b
├─╮
[roy] a
[roy] a
├─╯
[zsu] base
[rlv] nottherootcommit
[zzz]
[zsu] base
[rlv] nottherootcommit
[zzz]
"###);
let setup_opid = test_env.current_operation_id(&repo_path);

Expand All @@ -201,12 +201,12 @@ fn test_bug_2600() {
// should keep "a" as second parent.
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] c
[vru] b
[vru] b
├─╮
[roy] a
[roy] a
├─╯
[rlv] base nottherootcommit
[zzz]
[rlv] base nottherootcommit
[zzz]
"###);

test_env.jj_cmd_ok(&repo_path, &["op", "restore", &setup_opid]);
Expand All @@ -224,10 +224,10 @@ fn test_bug_2600() {
// "a".
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] c
[vru] b
[zsu] a base
[rlv] nottherootcommit
[zzz]
[vru] b
[zsu] a base
[rlv] nottherootcommit
[zzz]
"###);

test_env.jj_cmd_ok(&repo_path, &["op", "restore", &setup_opid]);
Expand All @@ -245,24 +245,24 @@ fn test_bug_2600() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] c
├─╮
[roy] a b??
[roy] a b??
├─╯
[zsu] b?? base
[rlv] nottherootcommit
[zzz]
[zsu] b?? base
[rlv] nottherootcommit
[zzz]
"###);

test_env.jj_cmd_ok(&repo_path, &["op", "restore", &setup_opid]);
// ========= Reminder of the setup ===========
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] c
[vru] b
[vru] b
├─╮
[roy] a
[roy] a
├─╯
[zsu] base
[rlv] nottherootcommit
[zzz]
[zsu] base
[rlv] nottherootcommit
[zzz]
"###);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["abandon", "a", "b"]);
insta::assert_snapshot!(stdout, @"");
Expand All @@ -279,9 +279,9 @@ fn test_bug_2600() {
// not have two parent pointers to the same commit.
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [znk] c
[zsu] a b base
[rlv] nottherootcommit
[zzz]
[zsu] a b base
[rlv] nottherootcommit
[zzz]
"###);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list", "b"]);
insta::assert_snapshot!(stdout, @r###"
Expand All @@ -305,12 +305,12 @@ fn test_bug_2600_rootcommit_special_case() {
// Setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ [vru] c
[roy] b
[roy] b
├─╮
[zsu] a
[zsu] a
├─╯
[rlv] base
[zzz]
[rlv] base
[zzz]
"###);

// Now, the test
Expand Down
14 changes: 7 additions & 7 deletions cli/tests/test_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fn test_alias_cannot_override_builtin() {
// Alias should be ignored
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "root()"]);
insta::assert_snapshot!(stdout, @r###"
zzzzzzzz root() 00000000
zzzzzzzz root() 00000000
"###);
}

Expand Down Expand Up @@ -206,28 +206,28 @@ fn test_alias_global_args_before_and_after() {
let stdout = test_env.jj_cmd_success(&repo_path, &["l"]);
insta::assert_snapshot!(stdout, @r###"
@ 230dd059e1b059aefc0da06a2e5a7dbf22362f22
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
"###);

// Can pass global args before
let stdout = test_env.jj_cmd_success(&repo_path, &["l", "--at-op", "@-"]);
insta::assert_snapshot!(stdout, @r###"
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
"###);
// Can pass global args after
let stdout = test_env.jj_cmd_success(&repo_path, &["--at-op", "@-", "l"]);
insta::assert_snapshot!(stdout, @r###"
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
"###);
// Test passing global args both before and after
let stdout = test_env.jj_cmd_success(&repo_path, &["--at-op", "abc123", "l", "--at-op", "@-"]);
insta::assert_snapshot!(stdout, @r###"
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
"###);
let stdout = test_env.jj_cmd_success(&repo_path, &["-R", "../nonexistent", "l", "-R", "."]);
insta::assert_snapshot!(stdout, @r###"
@ 230dd059e1b059aefc0da06a2e5a7dbf22362f22
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
"###);
}

Expand All @@ -243,7 +243,7 @@ fn test_alias_global_args_in_definition() {
// The global argument in the alias is respected
let stdout = test_env.jj_cmd_success(&repo_path, &["l"]);
insta::assert_snapshot!(stdout, @r###"
0000000000000000000000000000000000000000
◆ 0000000000000000000000000000000000000000
"###);
}

Expand Down
Loading