Skip to content

Commit

Permalink
config: use shiny, colored graph nodes by default
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Seipp <[email protected]>
Change-Id: I4e7e5f6cd3c1afa0b42ee88725bc89d3bfafdc0a
  • Loading branch information
thoughtpolice committed Mar 27, 2024
1 parent 6c5a54a commit 41f040c
Show file tree
Hide file tree
Showing 39 changed files with 1,335 additions and 1,251 deletions.
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
9 changes: 8 additions & 1 deletion cli/src/config/colors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,12 @@
"op_log time" = "cyan"
"op_log current_operation" = { bold = true }
"op_log current_operation id" = "bright blue"
"op_log current_operation user" = "yellow" # No bright yellow, see comment above
"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 wcc" = { fg = "green" }
"node immutable" = { fg = "bright cyan" }
"node wip" = { fg = "yellow" }
"node normal" = { bold = false }
16 changes: 16 additions & 0 deletions cli/src/config/templates.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ log = 'builtin_log_compact'
op_log = 'builtin_op_log_compact'
show = 'builtin_log_detailed'

op_log_node = 'if(current_operation, "@", "◉")'

log_node = '''
label("node",
if(!self, label("elided", "⇋"),
if(current_working_copy, label("wcc", "@"),
if(immutable, label("immutable", "◆"),
if(description.starts_with("wip: "), label("wip", "!"),
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###"
[38;5;4m0000000000000000000000000000000000000000[39m
[1m[38;5;14m◆[0m [38;5;4m0000000000000000000000000000000000000000[39m
"###);
}

Expand Down
Loading

0 comments on commit 41f040c

Please sign in to comment.