From 8093bc06142b9d40433ab8af5d5de6c46b28f84a Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Fri, 6 Jan 2023 17:49:31 -0800 Subject: [PATCH] `jj log`: Replace divergent label with ?? and red color This follows up on a [discussion] in a previous PR #941. [discussion]: https://github.com/martinvonz/jj/pull/941#issuecomment-1363551162 Screenshot: https://user-images.githubusercontent.com/4123047/209286340-bb83df2d-4020-4608-9755-d965477799c3.png --- CHANGELOG.md | 4 ++++ src/commands.rs | 5 +++-- src/config/colors.toml | 2 ++ tests/test_commit_template.rs | 8 ++++---- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9a7273bf..d89cf6c1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * The `-i` option to `jj restore` was removed in favor of new `--from`/`--to` options to `jj diffedit`. +* To report the situation when a change id corresponds to multiple visible + commits, `jj log` now prints the change id in red and puts `??` after it. + Previously, it printed the word "divergent". + ### New features * The default log format now uses the committer timestamp instead of the author diff --git a/src/commands.rs b/src/commands.rs index 92543968d..0a304d0d3 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1558,8 +1558,9 @@ fn log_template(settings: &UserSettings) -> String { }; let default_template = format!( r#" - change_id.short() - if(divergent, label("divergent", " divergent")) + if(divergent, + label("divergent", change_id.short() "??"), + change_id.short()) " " author.email() " " {committer_timestamp} if(branches, " " branches) diff --git a/src/config/colors.toml b/src/config/colors.toml index 955e2c21e..e0f082814 100644 --- a/src/config/colors.toml +++ b/src/config/colors.toml @@ -17,6 +17,7 @@ "git_refs" = "magenta" "git_head" = "magenta" "divergent" = "red" +"divergent change_id"="red" "conflict" = "red" # TODO: This near-duplication of the lines above is unfortunate. Should we @@ -34,6 +35,7 @@ "working_copy tags" = "bright magenta" "working_copy git_refs" = "bright magenta" "working_copy divergent" = "bright red" +"working_copy divergent change_id"="bright red" "working_copy conflict" = "bright red" "working_copy description" = "bright white" "diff header" = "yellow" diff --git a/tests/test_commit_template.rs b/tests/test_commit_template.rs index 30693888e..5d40e1c50 100644 --- a/tests/test_commit_template.rs +++ b/tests/test_commit_template.rs @@ -109,9 +109,9 @@ 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 9a45c67d3e96 divergent test.user@example.com 2001-02-03 04:05:10.000 +07:00 8979953d4c67 + o 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:10.000 +07:00 8979953d4c67 | description 2 - | @ 9a45c67d3e96 divergent test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c + | @ 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c |/ description 1 o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (no description set) @@ -120,9 +120,9 @@ fn test_log_default_divergence() { // Color let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]); insta::assert_snapshot!(stdout, @r###" - o 9a45c67d3e96 divergent test.user@example.com 2001-02-03 04:05:10.000 +07:00 8979953d4c67 + o 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:10.000 +07:00 8979953d4c67 | description 2 - | @ 9a45c67d3e96 divergent test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c + | @ 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c |/ description 1 o 000000000000  1970-01-01 00:00:00.000 +00:00 000000000000 (no description set)