Skip to content

Commit

Permalink
templates: reimplement builtin_change_id_with_hidden_and_divergent_in…
Browse files Browse the repository at this point in the history
…fo alias

This helps extract commit_summary template as an alias function.
  • Loading branch information
yuja committed Apr 25, 2024
1 parent 5b769c5 commit 29bd371
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions cli/src/config/templates.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[templates]
commit_summary = '''
separate(" ",
builtin_change_id_with_hidden_and_divergent_info,
format_short_change_id_with_hidden_and_divergent_info(self),
format_short_commit_id(commit_id),
separate(commit_summary_separator,
branches,
Expand All @@ -16,7 +16,7 @@ separate(" ",

commit_summary_no_branches = '''
separate(" ",
builtin_change_id_with_hidden_and_divergent_info,
format_short_change_id_with_hidden_and_divergent_info(self),
format_short_commit_id(commit_id),
if(conflict, label("conflict", "(conflict)")),
if(empty, label("empty", "(empty)")),
Expand Down Expand Up @@ -46,7 +46,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,
Expand All @@ -68,7 +68,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,
Expand Down Expand Up @@ -155,13 +155,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(), "??")
)
)
'''
Expand Down
1 change: 0 additions & 1 deletion cli/tests/test_log_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cli/tests/test_obslog_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cli/tests/test_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cli/tests/test_show_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_templater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"?
"###);
}

Expand Down

0 comments on commit 29bd371

Please sign in to comment.