From 6e05c5a829a4b64f37b2b1ada776f3221ab32c55 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sat, 21 Jan 2023 22:30:10 -0800 Subject: [PATCH] `jj log`: Change the default of `ui.unique-prefixes` to "styled" --- CHANGELOG.md | 6 +++-- docs/config.md | 7 +++--- lib/src/settings.rs | 2 +- tests/test_alias.rs | 2 +- tests/test_commit_template.rs | 40 +++++++++++++++---------------- tests/test_init_command.rs | 4 ++-- tests/test_obslog_command.rs | 44 +++++++++++++++++------------------ tests/test_revset_output.rs | 6 ++--- 8 files changed, 56 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dde5790f5..3769e9333 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,8 +76,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 any parent-child relationships between them. For example, the entire tree of descendants of `abc` can be duplicated with `jj duplicate abc:`. -* `jj log` now highlights the shortest unique prefix of every commit and change id - with brackets. To disable, set the new `ui.unique-prefixes` option to `none` +* `jj log` now highlights the shortest unique prefix of every commit and change + id and shows the rest in gray. To disable, set the new `ui.unique-prefixes` + option to `none`. For a presentation that doesn't rely on color, set it to + `brackets`. * `jj print` was renamed to `jj cat`. `jj print` remains as an alias. diff --git a/docs/config.md b/docs/config.md index 4c8debf50..6768556dc 100644 --- a/docs/config.md +++ b/docs/config.md @@ -106,13 +106,12 @@ ui.graph.style = "curved" ``` ### Shortest unique prefixes for ids - ```toml -ui.unique-prefixes = "none" +ui.unique-prefixes = "brackets" # Does not rely on color ``` -Whether to highlight a unique prefix for commit & change ids. Possible values -are `brackets` and `none` (default: `brackets`). +Whether to highlight a unique prefix for commit & change ids. Possible +values are `styled`, `brackets` and `none` (default: `styled`). ### Relative timestamps diff --git a/lib/src/settings.rs b/lib/src/settings.rs index 1f62671d8..9734a7f96 100644 --- a/lib/src/settings.rs +++ b/lib/src/settings.rs @@ -167,7 +167,7 @@ impl UserSettings { pub fn unique_prefixes(&self) -> String { self.config .get_string("ui.unique-prefixes") - .unwrap_or_else(|_| "brackets".to_string()) + .unwrap_or_else(|_| "styled".to_string()) } pub fn config(&self) -> &config::Config { diff --git a/tests/test_alias.rs b/tests/test_alias.rs index 524bf05e5..54df50ef5 100644 --- a/tests/test_alias.rs +++ b/tests/test_alias.rs @@ -135,7 +135,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###" - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); } diff --git a/tests/test_commit_template.rs b/tests/test_commit_template.rs index f0cbe8e73..2213ee4a9 100644 --- a/tests/test_commit_template.rs +++ b/tests/test_commit_template.rs @@ -65,11 +65,11 @@ fn test_log_default() { // Test default log output format let stdout = test_env.jj_cmd_success(&repo_path, &["log"]); insta::assert_snapshot!(stdout, @r###" - @ f[fdaa62087] test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9d[e54178d5] + @ ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9de54178d59d | (empty) description 1 - o 9a[45c67d3e] test.user@example.com 2001-02-03 04:05:08.000 +07:00 4[291e264ae] + o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 | add a file - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -123,22 +123,22 @@ fn test_log_default() { // Color let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]); insta::assert_snapshot!(stdout, @r###" - @ f[fdaa62087] test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9d[e54178d5] + @ ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9de54178d59d | (empty) description 1 - o 9a[45c67d3e] test.user@example.com 2001-02-03 04:05:08.000 +07:00 4[291e264ae] + o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 | add a file - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); // Color without graph let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always", "--no-graph"]); insta::assert_snapshot!(stdout, @r###" - f[fdaa62087] test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9d[e54178d5] + ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9de54178d59d (empty) description 1 - 9a[45c67d3e] test.user@example.com 2001-02-03 04:05:08.000 +07:00 4[291e264ae] + 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 add a file - 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); } @@ -154,9 +154,9 @@ fn test_log_default_divergence() { let stdout = test_env.jj_cmd_success(&repo_path, &["log"]); // No divergence insta::assert_snapshot!(stdout, @r###" - @ 9[a45c67d3e] test.user@example.com 2001-02-03 04:05:08.000 +07:00 7[a17d52e63] + @ 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c | description 1 - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -168,22 +168,22 @@ fn test_log_default_divergence() { let stdout = test_env.jj_cmd_success(&repo_path, &["log"]); insta::assert_snapshot!(stdout, @r###" Concurrent modification detected, resolving automatically. - o 9[a45c67d3e]?? test.user@example.com 2001-02-03 04:05:10.000 +07:00 8[979953d4c] + o 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:10.000 +07:00 8979953d4c67 | description 2 - | @ 9[a45c67d3e]?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7[a17d52e63] + | @ 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c |/ description 1 - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); // Color let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]); insta::assert_snapshot!(stdout, @r###" - o 9[a45c67d3e]?? test.user@example.com 2001-02-03 04:05:10.000 +07:00 8[979953d4c] + o 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:10.000 +07:00 8979953d4c67 | description 2 - | @ 9[a45c67d3e]?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7[a17d52e63] + | @ 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c |/ description 1 - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); } @@ -199,11 +199,11 @@ fn test_log_git_head() { std::fs::write(repo_path.join("file"), "foo\n").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]); insta::assert_snapshot!(stdout, @r###" - @ 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 5[0aaf4754c] + @ 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 50aaf4754c1e | initial - o 9[a45c67d3e] test.user@example.com 2001-02-03 04:05:07.000 +07:00 master HEAD@git 23[0dd059e1] + o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:07.000 +07:00 master HEAD@git 230dd059e1b0 | (empty) (no description set) - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); } diff --git a/tests/test_init_command.rs b/tests/test_init_command.rs index dd0f535dd..e169eb794 100644 --- a/tests/test_init_command.rs +++ b/tests/test_init_command.rs @@ -107,7 +107,7 @@ fn test_init_git_external() { // Check that the Git repo's HEAD got checked out let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "@-"]); insta::assert_snapshot!(stdout, @r###" - o d[3866db7e3] git.user@example.com 1970-01-01 01:02:03.000 +01:00 my-branch HEAD@git 8[d698d4a8e] + o d3866db7e30a git.user@example.com 1970-01-01 01:02:03.000 +01:00 my-branch HEAD@git 8d698d4a8ee1 ~ My commit message "###); } @@ -150,7 +150,7 @@ fn test_init_git_colocated() { // Check that the Git repo's HEAD got checked out let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "@-"]); insta::assert_snapshot!(stdout, @r###" - o d[3866db7e3] git.user@example.com 1970-01-01 01:02:03.000 +01:00 my-branch HEAD@git 8[d698d4a8e] + o d3866db7e30a git.user@example.com 1970-01-01 01:02:03.000 +01:00 my-branch HEAD@git 8d698d4a8ee1 ~ My commit message "###); } diff --git a/tests/test_obslog_command.rs b/tests/test_obslog_command.rs index a6ce61f54..d2a46f6c1 100644 --- a/tests/test_obslog_command.rs +++ b/tests/test_obslog_command.rs @@ -30,13 +30,13 @@ fn test_obslog_with_or_without_diff() { let stdout = test_env.jj_cmd_success(&repo_path, &["obslog"]); insta::assert_snapshot!(stdout, @r###" - @ 8[e4fac809c] test.user@example.com 2001-02-03 04:05:10.000 +07:00 66[b42ad360] + @ 8e4fac809cbb test.user@example.com 2001-02-03 04:05:10.000 +07:00 66b42ad36073 | my description - o 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 af[536e5af6] conflict + o 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 af536e5af67e conflict | my description - o 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 6f[bba7bcb5] + o 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 6fbba7bcb590 | my description - o 8[e4fac809c] test.user@example.com 2001-02-03 04:05:08.000 +07:00 e[ac0d0dae0] + o 8e4fac809cbb test.user@example.com 2001-02-03 04:05:08.000 +07:00 eac0d0dae082 (empty) my description "###); @@ -44,43 +44,43 @@ fn test_obslog_with_or_without_diff() { // (even even though it resulted in a conflict). let stdout = test_env.jj_cmd_success(&repo_path, &["obslog", "-p"]); insta::assert_snapshot!(stdout, @r###" - @ 8[e4fac809c] test.user@example.com 2001-02-03 04:05:10.000 +07:00 66[b42ad360] + @ 8e4fac809cbb test.user@example.com 2001-02-03 04:05:10.000 +07:00 66b42ad36073 | my description | Resolved conflict in file1: | 1 1: <<<<<<>>>>>> - o 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 af[536e5af6] conflict + o 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 af536e5af67e conflict | my description - o 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 6f[bba7bcb5] + o 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 6fbba7bcb590 | my description | Modified regular file file1: | 1 1: foo | 2: bar | Added regular file file2: | 1: foo - o 8[e4fac809c] test.user@example.com 2001-02-03 04:05:08.000 +07:00 e[ac0d0dae0] + o 8e4fac809cbb test.user@example.com 2001-02-03 04:05:08.000 +07:00 eac0d0dae082 (empty) my description "###); // Test `--no-graph` let stdout = test_env.jj_cmd_success(&repo_path, &["obslog", "--no-graph"]); insta::assert_snapshot!(stdout, @r###" - 8[e4fac809c] test.user@example.com 2001-02-03 04:05:10.000 +07:00 66[b42ad360] + 8e4fac809cbb test.user@example.com 2001-02-03 04:05:10.000 +07:00 66b42ad36073 my description - 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 af[536e5af6] conflict + 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 af536e5af67e conflict my description - 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 6f[bba7bcb5] + 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 6fbba7bcb590 my description - 8[e4fac809c] test.user@example.com 2001-02-03 04:05:08.000 +07:00 e[ac0d0dae0] + 8e4fac809cbb test.user@example.com 2001-02-03 04:05:08.000 +07:00 eac0d0dae082 (empty) my description "###); // Test `--git` format, and that it implies `-p` let stdout = test_env.jj_cmd_success(&repo_path, &["obslog", "--no-graph", "--git"]); insta::assert_snapshot!(stdout, @r###" - 8[e4fac809c] test.user@example.com 2001-02-03 04:05:10.000 +07:00 66[b42ad360] + 8e4fac809cbb test.user@example.com 2001-02-03 04:05:10.000 +07:00 66b42ad36073 my description diff --git a/file1 b/file1 index e155302a24...2ab19ae607 100644 @@ -92,9 +92,9 @@ fn test_obslog_with_or_without_diff() { -+bar ->>>>>>> +resolved - 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 af[536e5af6] conflict + 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 af536e5af67e conflict my description - 8[e4fac809c] test.user@example.com 2001-02-03 04:05:09.000 +07:00 6f[bba7bcb5] + 8e4fac809cbb test.user@example.com 2001-02-03 04:05:09.000 +07:00 6fbba7bcb590 my description diff --git a/file1 b/file1 index 257cc5642c...3bd1f0e297 100644 @@ -110,7 +110,7 @@ fn test_obslog_with_or_without_diff() { +++ b/file2 @@ -1,0 +1,1 @@ +foo - 8[e4fac809c] test.user@example.com 2001-02-03 04:05:08.000 +07:00 e[ac0d0dae0] + 8e4fac809cbb test.user@example.com 2001-02-03 04:05:08.000 +07:00 eac0d0dae082 (empty) my description "###); } @@ -132,25 +132,25 @@ fn test_obslog_squash() { let stdout = test_env.jj_cmd_success(&repo_path, &["obslog", "-p", "-r", "@-"]); insta::assert_snapshot!(stdout, @r###" - o 9a[45c67d3e] test.user@example.com 2001-02-03 04:05:10.000 +07:00 27[e721a5ba] + o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:10.000 +07:00 27e721a5ba72 |\ squashed | | Modified regular file file1: | | 1 1: foo | | 2: bar - o | 9a[45c67d3e] test.user@example.com 2001-02-03 04:05:09.000 +07:00 97[64e503e1] + o | 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:09.000 +07:00 9764e503e1a9 | | first | | Added regular file file1: | | 1: foo - o | 9a[45c67d3e] test.user@example.com 2001-02-03 04:05:08.000 +07:00 6[9542c1984] + o | 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 69542c1984c1 | | (empty) first - o | 9a[45c67d3e] test.user@example.com 2001-02-03 04:05:07.000 +07:00 23[0dd059e1] + o | 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059e1b0 / (empty) (no description set) - o ff[daa62087] test.user@example.com 2001-02-03 04:05:10.000 +07:00 f[09a38899f] + o ffdaa62087a2 test.user@example.com 2001-02-03 04:05:10.000 +07:00 f09a38899f2b | second | Modified regular file file1: | 1 1: foo | 2: bar - o ff[daa62087] test.user@example.com 2001-02-03 04:05:09.000 +07:00 5[799653697] + o ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 579965369703 (empty) second "###); } diff --git a/tests/test_revset_output.rs b/tests/test_revset_output.rs index b0609eb95..97f3242fb 100644 --- a/tests/test_revset_output.rs +++ b/tests/test_revset_output.rs @@ -161,13 +161,13 @@ fn test_alias() { let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "my-root"]); insta::assert_snapshot!(stdout, @r###" - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "identity(my-root)"]); insta::assert_snapshot!(stdout, @r###" - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -263,7 +263,7 @@ fn test_bad_alias_decl() { .assert() .success(); insta::assert_snapshot!(get_stdout_string(&assert), @r###" - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); insta::assert_snapshot!(get_stderr_string(&assert), @r###"