diff --git a/CHANGELOG.md b/CHANGELOG.md index df804949a5..67a804b512 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking changes -* The default template alias `builtin_op_log_root(op_id: OperationId)` was replaced by `format_root_operation(root: Operation)`. - -* The default template alias `builtin_log_root(change_id: ChangeId, commit_id: CommitId)` was replaced by `format_root_commit(root: Commit)`. +* The default template aliases were replaced as follows: + * `builtin_op_log_root(op_id: OperationId)` -> + `format_root_operation(root: Operation)` + * `builtin_log_root(change_id: ChangeId, commit_id: CommitId)` -> + `format_root_commit(root: Commit)` + * `builtin_change_id_with_hidden_and_divergent_info` -> + `format_short_change_id_with_hidden_and_divergent_info(commit: Commit)` ### New features diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 01410fad79..f188f43b2e 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -1,28 +1,6 @@ [templates] -commit_summary = ''' -separate(" ", - builtin_change_id_with_hidden_and_divergent_info, - format_short_commit_id(commit_id), - separate(commit_summary_separator, - branches, - separate(" ", - if(conflict, label("conflict", "(conflict)")), - if(empty, label("empty", "(empty)")), - if(description, description.first_line(), description_placeholder), - ) - ) -) -''' - -commit_summary_no_branches = ''' -separate(" ", - builtin_change_id_with_hidden_and_divergent_info, - format_short_commit_id(commit_id), - if(conflict, label("conflict", "(conflict)")), - if(empty, label("empty", "(empty)")), - if(description, description.first_line(), description_placeholder), -) -''' +commit_summary = 'format_commit_summary_with_refs(self, branches)' +commit_summary_no_branches = 'format_commit_summary_with_refs(self, "")' config_list = ''' label(if(overridden, "overridden"), @@ -46,7 +24,7 @@ if(root, label(if(current_working_copy, "working_copy"), concat( separate(" ", - builtin_change_id_with_hidden_and_divergent_info, + format_short_change_id_with_hidden_and_divergent_info(self), if(author.email(), author.username(), email_placeholder), format_timestamp(committer.timestamp()), branches, @@ -56,7 +34,10 @@ if(root, format_short_commit_id(commit_id), if(conflict, label("conflict", "conflict")), if(empty, label("empty", "(empty)")), - if(description, description.first_line(), description_placeholder), + if(description, + description.first_line(), + label(if(empty, "empty"), description_placeholder), + ), ) ++ "\n", ), ) @@ -68,7 +49,7 @@ if(root, label(if(current_working_copy, "working_copy"), concat( separate(" ", - builtin_change_id_with_hidden_and_divergent_info, + format_short_change_id_with_hidden_and_divergent_info(self), format_short_signature(author), format_timestamp(committer.timestamp()), branches, @@ -80,7 +61,10 @@ if(root, ) ++ "\n", separate(" ", if(empty, label("empty", "(empty)")), - if(description, description.first_line(), description_placeholder), + if(description, + description.first_line(), + label(if(empty, "empty"), description_placeholder), + ), ) ++ "\n", ), ) @@ -96,7 +80,8 @@ concat( "Author: " ++ format_detailed_signature(author) ++ "\n", "Committer: " ++ format_detailed_signature(committer) ++ "\n", "\n", - indent(" ", coalesce(description, description_placeholder ++ "\n")), + indent(" ", + coalesce(description, label(if(empty, "empty"), description_placeholder) ++ "\n")), "\n", ) ''' @@ -112,9 +97,7 @@ label(if(current_operation, "current_operation"), ''' builtin_op_log_comfortable = 'builtin_op_log_compact ++ "\n"' - -description_placeholder = ''' - label(if(empty, "empty ") ++ "description placeholder", "(no description set)")''' +description_placeholder = 'label("description placeholder", "(no description set)")' email_placeholder = 'label("email placeholder", "(no email set)")' name_placeholder = 'label("name placeholder", "(no name set)")' commit_summary_separator = 'label("separator", " | ")' @@ -133,6 +116,24 @@ commit_summary_separator = 'label("separator", " | ")' time_range.start().ago() ++ label("time", ", lasted ") ++ time_range.duration()''' 'format_timestamp(timestamp)' = 'timestamp.local().format("%Y-%m-%d %H:%M:%S")' +'format_commit_summary_with_refs(commit, refs)' = ''' +separate(" ", + format_short_change_id_with_hidden_and_divergent_info(commit), + format_short_commit_id(commit.commit_id()), + separate(commit_summary_separator, + refs, + separate(" ", + if(commit.conflict(), label("conflict", "(conflict)")), + if(commit.empty(), label("empty", "(empty)")), + if(commit.description(), + commit.description().first_line(), + label(if(commit.empty(), "empty"), description_placeholder), + ), + ), + ), +) +''' + 'format_root_commit(root)' = ''' separate(" ", format_short_change_id(root.change_id()), @@ -155,13 +156,13 @@ separate(" ", # 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 = ''' -if(hidden, +'format_short_change_id_with_hidden_and_divergent_info(commit)' = ''' +if(commit.hidden(), label("hidden", - format_short_change_id(change_id) ++ " hidden" + format_short_change_id(commit.change_id()) ++ " hidden" ), - label(if(divergent, "divergent"), - format_short_change_id(change_id) ++ if(divergent, "??") + label(if(commit.divergent(), "divergent"), + format_short_change_id(commit.change_id()) ++ if(commit.divergent(), "??") ) ) ''' diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index dbccba748b..176e7e43be 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -40,7 +40,6 @@ fn test_log_with_no_template() { For more information, try '--help'. Hint: The following template aliases are defined: - - builtin_change_id_with_hidden_and_divergent_info - builtin_log_comfortable - builtin_log_compact - builtin_log_detailed diff --git a/cli/tests/test_obslog_command.rs b/cli/tests/test_obslog_command.rs index 4647a6a45f..dec0cda0ad 100644 --- a/cli/tests/test_obslog_command.rs +++ b/cli/tests/test_obslog_command.rs @@ -275,7 +275,6 @@ fn test_obslog_with_no_template() { For more information, try '--help'. Hint: The following template aliases are defined: - - builtin_change_id_with_hidden_and_divergent_info - builtin_log_comfortable - builtin_log_compact - builtin_log_detailed diff --git a/cli/tests/test_operations.rs b/cli/tests/test_operations.rs index e0b54b9384..eee55db184 100644 --- a/cli/tests/test_operations.rs +++ b/cli/tests/test_operations.rs @@ -136,7 +136,6 @@ fn test_op_log_with_no_template() { For more information, try '--help'. Hint: The following template aliases are defined: - - builtin_change_id_with_hidden_and_divergent_info - builtin_log_comfortable - builtin_log_compact - builtin_log_detailed diff --git a/cli/tests/test_show_command.rs b/cli/tests/test_show_command.rs index 15cf1cffc1..16273bea9a 100644 --- a/cli/tests/test_show_command.rs +++ b/cli/tests/test_show_command.rs @@ -60,7 +60,6 @@ fn test_show_with_no_template() { For more information, try '--help'. Hint: The following template aliases are defined: - - builtin_change_id_with_hidden_and_divergent_info - builtin_log_comfortable - builtin_log_compact - builtin_log_detailed diff --git a/cli/tests/test_templater.rs b/cli/tests/test_templater.rs index 08e2308a3b..d58ad16f78 100644 --- a/cli/tests/test_templater.rs +++ b/cli/tests/test_templater.rs @@ -111,7 +111,7 @@ fn test_templater_parse_error() { | ^-----^ | = Keyword "builtin" doesn't exist - Hint: Did you mean "builtin_change_id_with_hidden_and_divergent_info", "builtin_log_comfortable", "builtin_log_compact", "builtin_log_detailed", "builtin_log_node", "builtin_log_node_ascii", "builtin_log_oneline", "builtin_op_log_comfortable", "builtin_op_log_compact", "builtin_op_log_node", "builtin_op_log_node_ascii"? + Hint: Did you mean "builtin_log_comfortable", "builtin_log_compact", "builtin_log_detailed", "builtin_log_node", "builtin_log_node_ascii", "builtin_log_oneline", "builtin_op_log_comfortable", "builtin_op_log_compact", "builtin_op_log_node", "builtin_op_log_node_ascii"? "###); }