From eeb93cc8beed5a0860ebcc5c859283f64096e3eb Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Wed, 25 Oct 2023 21:18:58 -0700 Subject: [PATCH] cli change id templates: make "hidden" override "divergent" See the test changes in `test_undo.rs` for motivation. This matters rarely, but seems to be better. --- cli/src/config/colors.toml | 3 --- cli/src/config/templates.toml | 16 +++++++++++----- cli/tests/test_commit_template.rs | 8 ++++---- cli/tests/test_undo.rs | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/cli/src/config/colors.toml b/cli/src/config/colors.toml index 17b4ee3ce..df74742cf 100644 --- a/cli/src/config/colors.toml +++ b/cli/src/config/colors.toml @@ -15,9 +15,6 @@ "divergent rest" = "red" "divergent prefix" = {fg = "red", underline=true} "hidden prefix" = "default" -"divergent hidden" = {fg = "default", bold = true} -"divergent hidden prefix" = {fg = "default", underline = false} -"divergent hidden rest" = {fg ="bright black", bold = false} "email" = "yellow" "username" = "yellow" diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 00ea214e1..3d2b99294 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -133,10 +133,16 @@ commit_summary_separator = 'label("separator", " | ")' time_range.start().ago() ++ label("time", ", lasted ") ++ time_range.duration()''' 'format_timestamp(timestamp)' = 'timestamp' +# We have "hidden" override "divergent", since a hidden revision does not cause +# change id conflicts and is not affected by such conflicts; you have to use the +# commit id to refer to a hidden revision regardless. builtin_change_id_with_hidden_and_divergent_info = ''' -label( - separate(" ", if(divergent, "divergent"), if(hidden, "hidden")), - separate(" ", - format_short_change_id(change_id) ++ if(divergent, "??"), - if(hidden, "hidden"))) +if(hidden, + label("hidden", + format_short_change_id(change_id) ++ " hidden" + ), + label(if(divergent, "divergent"), + format_short_change_id(change_id) ++ if(divergent,"??") + ) +) ''' diff --git a/cli/tests/test_commit_template.rs b/cli/tests/test_commit_template.rs index 0d175443b..1b7416516 100644 --- a/cli/tests/test_commit_template.rs +++ b/cli/tests/test_commit_template.rs @@ -344,9 +344,9 @@ fn test_log_obslog_divergence() { insta::assert_snapshot!(stdout, @r###" @ qpvuntsm?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e │ description 1 - ◉ qpvuntsm?? hidden test.user@example.com 2001-02-03 04:05:08.000 +07:00 3b68ce25 + ◉ qpvuntsm hidden test.user@example.com 2001-02-03 04:05:08.000 +07:00 3b68ce25 │ (no description set) - ◉ qpvuntsm?? hidden test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 + ◉ qpvuntsm hidden test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set) "###); @@ -355,9 +355,9 @@ fn test_log_obslog_divergence() { insta::assert_snapshot!(stdout, @r###" @ qpvuntsm?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e │ description 1 - ◉ qpvuntsm?? hidden test.user@example.com 2001-02-03 04:05:08.000 +07:00 3b68ce25 + ◉ qpvuntsm hidden test.user@example.com 2001-02-03 04:05:08.000 +07:00 3b68ce25 │ (no description set) - ◉ qpvuntsm?? hidden test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 + ◉ qpvuntsm hidden test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set) "###); } diff --git a/cli/tests/test_undo.rs b/cli/tests/test_undo.rs index ba961a265..685ba1478 100644 --- a/cli/tests/test_undo.rs +++ b/cli/tests/test_undo.rs @@ -112,7 +112,7 @@ fn test_git_push_undo() { // git fetch && jj undo && jj git fetch` would become a no-op. insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" main (conflicted): - - qpvuntsm?? hidden 0cffb614 (empty) AA + - qpvuntsm hidden 0cffb614 (empty) AA + qpvuntsm?? 0a3e99f0 (empty) CC + qpvuntsm?? 8c05de15 (empty) BB @origin (behind by 1 commits): qpvuntsm?? 8c05de15 (empty) BB @@ -270,7 +270,7 @@ fn test_git_push_undo_colocated() { // same result in a seemingly different way? insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" main (conflicted): - - qpvuntsm?? hidden 0cffb614 (empty) AA + - qpvuntsm hidden 0cffb614 (empty) AA + qpvuntsm?? 0a3e99f0 (empty) CC + qpvuntsm?? 8c05de15 (empty) BB @git (behind by 1 commits): qpvuntsm?? 0a3e99f0 (empty) CC