cli: add top-level command-name/context labels to graph "node" templates

It's inconsistent that the content templates have e.g. "op_log operation", but
the graph node templates don't.
This commit is contained in:
Yuya Nishihara 2024-10-18 21:43:41 +09:00
parent f8a0fcfc47
commit d43d8c4e23
5 changed files with 18 additions and 18 deletions

View File

@ -119,7 +119,7 @@ pub(crate) fn cmd_evolog(
&language,
&get_node_template(graph_style, workspace_command.settings())?,
)?
.labeled(["node"]);
.labeled(["log", "node"]);
}
ui.request_pager();

View File

@ -177,7 +177,7 @@ pub(crate) fn cmd_log(
.labeled(["log"]);
node_template = workspace_command
.parse_template(ui, &language, &get_node_template(graph_style, settings)?)?
.labeled(["node"]);
.labeled(["log", "node"]);
}
{

View File

@ -139,7 +139,7 @@ fn do_op_log(
.labeled(["op_log", "operation"]);
op_node_template = workspace_env
.parse_template(ui, &language, &get_node_template(graph_style, settings)?)?
.labeled(["node"]);
.labeled(["op_log", "operation", "node"]);
}
let diff_formats = diff_formats_for_log(settings, &args.diff_format, args.patch)?;

View File

@ -457,35 +457,35 @@ fn test_log_builtin_templates_colored_debug() {
.success();
insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r"
<<node working_copy::@>> <<log working_copy change_id shortest prefix::r>><<log working_copy change_id shortest rest::lvkpnrz>><<log working_copy:: >><<log working_copy email placeholder::(no email set)>><<log working_copy:: >><<log working_copy committer timestamp local format::2001-02-03 08:05:08>><<log working_copy:: >><<log working_copy bookmarks name::my-bookmark>><<log working_copy:: >><<log working_copy commit_id shortest prefix::a>><<log working_copy commit_id shortest rest::ec3ec96>><<log working_copy:: >><<log working_copy empty::(empty)>><<log working_copy:: >><<log working_copy empty description placeholder::(no description set)>><<log working_copy::>>
<<node::>> <<log change_id shortest prefix::q>><<log change_id shortest rest::pvuntsm>><<log:: >><<log author email local::test.user>><<log:: >><<log committer timestamp local format::2001-02-03 08:05:07>><<log:: >><<log commit_id shortest prefix::e>><<log commit_id shortest rest::8849ae1>><<log:: >><<log empty::(empty)>><<log:: >><<log empty description placeholder::(no description set)>><<log::>>
<<node immutable::>> <<log change_id shortest prefix::z>><<log change_id shortest rest::zzzzzzz>><<log:: >><<log root::root()>><<log:: >><<log commit_id shortest prefix::0>><<log commit_id shortest rest::0000000>><<log::>>
<<log node working_copy::@>> <<log working_copy change_id shortest prefix::r>><<log working_copy change_id shortest rest::lvkpnrz>><<log working_copy:: >><<log working_copy email placeholder::(no email set)>><<log working_copy:: >><<log working_copy committer timestamp local format::2001-02-03 08:05:08>><<log working_copy:: >><<log working_copy bookmarks name::my-bookmark>><<log working_copy:: >><<log working_copy commit_id shortest prefix::a>><<log working_copy commit_id shortest rest::ec3ec96>><<log working_copy:: >><<log working_copy empty::(empty)>><<log working_copy:: >><<log working_copy empty description placeholder::(no description set)>><<log working_copy::>>
<<log node::>> <<log change_id shortest prefix::q>><<log change_id shortest rest::pvuntsm>><<log:: >><<log author email local::test.user>><<log:: >><<log committer timestamp local format::2001-02-03 08:05:07>><<log:: >><<log commit_id shortest prefix::e>><<log commit_id shortest rest::8849ae1>><<log:: >><<log empty::(empty)>><<log:: >><<log empty description placeholder::(no description set)>><<log::>>
<<log node immutable::>> <<log change_id shortest prefix::z>><<log change_id shortest rest::zzzzzzz>><<log:: >><<log root::root()>><<log:: >><<log commit_id shortest prefix::0>><<log commit_id shortest rest::0000000>><<log::>>
[EOF]
");
insta::assert_snapshot!(render(r#"builtin_log_compact"#), @r"
<<node working_copy::@>> <<log working_copy change_id shortest prefix::r>><<log working_copy change_id shortest rest::lvkpnrz>><<log working_copy:: >><<log working_copy email placeholder::(no email set)>><<log working_copy:: >><<log working_copy committer timestamp local format::2001-02-03 08:05:08>><<log working_copy:: >><<log working_copy bookmarks name::my-bookmark>><<log working_copy:: >><<log working_copy commit_id shortest prefix::a>><<log working_copy commit_id shortest rest::ec3ec96>><<log working_copy::>>
<<log node working_copy::@>> <<log working_copy change_id shortest prefix::r>><<log working_copy change_id shortest rest::lvkpnrz>><<log working_copy:: >><<log working_copy email placeholder::(no email set)>><<log working_copy:: >><<log working_copy committer timestamp local format::2001-02-03 08:05:08>><<log working_copy:: >><<log working_copy bookmarks name::my-bookmark>><<log working_copy:: >><<log working_copy commit_id shortest prefix::a>><<log working_copy commit_id shortest rest::ec3ec96>><<log working_copy::>>
<<log working_copy empty::(empty)>><<log working_copy:: >><<log working_copy empty description placeholder::(no description set)>><<log working_copy::>>
<<node::>> <<log change_id shortest prefix::q>><<log change_id shortest rest::pvuntsm>><<log:: >><<log author email local::test.user>><<log author email::@>><<log author email domain::example.com>><<log:: >><<log committer timestamp local format::2001-02-03 08:05:07>><<log:: >><<log commit_id shortest prefix::e>><<log commit_id shortest rest::8849ae1>><<log::>>
<<log node::>> <<log change_id shortest prefix::q>><<log change_id shortest rest::pvuntsm>><<log:: >><<log author email local::test.user>><<log author email::@>><<log author email domain::example.com>><<log:: >><<log committer timestamp local format::2001-02-03 08:05:07>><<log:: >><<log commit_id shortest prefix::e>><<log commit_id shortest rest::8849ae1>><<log::>>
<<log empty::(empty)>><<log:: >><<log empty description placeholder::(no description set)>><<log::>>
<<node immutable::>> <<log change_id shortest prefix::z>><<log change_id shortest rest::zzzzzzz>><<log:: >><<log root::root()>><<log:: >><<log commit_id shortest prefix::0>><<log commit_id shortest rest::0000000>><<log::>>
<<log node immutable::>> <<log change_id shortest prefix::z>><<log change_id shortest rest::zzzzzzz>><<log:: >><<log root::root()>><<log:: >><<log commit_id shortest prefix::0>><<log commit_id shortest rest::0000000>><<log::>>
[EOF]
");
insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @r"
<<node working_copy::@>> <<log working_copy change_id shortest prefix::r>><<log working_copy change_id shortest rest::lvkpnrz>><<log working_copy:: >><<log working_copy email placeholder::(no email set)>><<log working_copy:: >><<log working_copy committer timestamp local format::2001-02-03 08:05:08>><<log working_copy:: >><<log working_copy bookmarks name::my-bookmark>><<log working_copy:: >><<log working_copy commit_id shortest prefix::a>><<log working_copy commit_id shortest rest::ec3ec96>><<log working_copy::>>
<<log node working_copy::@>> <<log working_copy change_id shortest prefix::r>><<log working_copy change_id shortest rest::lvkpnrz>><<log working_copy:: >><<log working_copy email placeholder::(no email set)>><<log working_copy:: >><<log working_copy committer timestamp local format::2001-02-03 08:05:08>><<log working_copy:: >><<log working_copy bookmarks name::my-bookmark>><<log working_copy:: >><<log working_copy commit_id shortest prefix::a>><<log working_copy commit_id shortest rest::ec3ec96>><<log working_copy::>>
<<log working_copy empty::(empty)>><<log working_copy:: >><<log working_copy empty description placeholder::(no description set)>><<log working_copy::>>
<<log::>>
<<node::>> <<log change_id shortest prefix::q>><<log change_id shortest rest::pvuntsm>><<log:: >><<log author email local::test.user>><<log author email::@>><<log author email domain::example.com>><<log:: >><<log committer timestamp local format::2001-02-03 08:05:07>><<log:: >><<log commit_id shortest prefix::e>><<log commit_id shortest rest::8849ae1>><<log::>>
<<log node::>> <<log change_id shortest prefix::q>><<log change_id shortest rest::pvuntsm>><<log:: >><<log author email local::test.user>><<log author email::@>><<log author email domain::example.com>><<log:: >><<log committer timestamp local format::2001-02-03 08:05:07>><<log:: >><<log commit_id shortest prefix::e>><<log commit_id shortest rest::8849ae1>><<log::>>
<<log empty::(empty)>><<log:: >><<log empty description placeholder::(no description set)>><<log::>>
<<log::>>
<<node immutable::>> <<log change_id shortest prefix::z>><<log change_id shortest rest::zzzzzzz>><<log:: >><<log root::root()>><<log:: >><<log commit_id shortest prefix::0>><<log commit_id shortest rest::0000000>><<log::>>
<<log node immutable::>> <<log change_id shortest prefix::z>><<log change_id shortest rest::zzzzzzz>><<log:: >><<log root::root()>><<log:: >><<log commit_id shortest prefix::0>><<log commit_id shortest rest::0000000>><<log::>>
<<log::>>
[EOF]
");
insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @r"
<<node working_copy::@>> <<log::Commit ID: >><<log commit_id::aec3ec964d0771edea9da48a2a170bc6ffa1c725>><<log::>>
<<log node working_copy::@>> <<log::Commit ID: >><<log commit_id::aec3ec964d0771edea9da48a2a170bc6ffa1c725>><<log::>>
<<log::Change ID: >><<log change_id::rlvkpnrzqnoowoytxnquwvuryrwnrmlp>><<log::>>
<<log::Bookmarks: >><<log local_bookmarks name::my-bookmark>><<log::>>
<<log::Author : >><<log name placeholder::(no name set)>><<log:: <>><<log email placeholder::(no email set)>><<log::> (>><<log author timestamp local format::2001-02-03 08:05:08>><<log::)>>
@ -493,14 +493,14 @@ fn test_log_builtin_templates_colored_debug() {
<<log::>>
<<log empty description placeholder:: (no description set)>><<log::>>
<<log::>>
<<node::>> <<log::Commit ID: >><<log commit_id::e8849ae12c709f2321908879bc724fdb2ab8a781>><<log::>>
<<log node::>> <<log::Commit ID: >><<log commit_id::e8849ae12c709f2321908879bc724fdb2ab8a781>><<log::>>
<<log::Change ID: >><<log change_id::qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu>><<log::>>
<<log::Author : >><<log author name::Test User>><<log:: <>><<log author email local::test.user>><<log author email::@>><<log author email domain::example.com>><<log::> (>><<log author timestamp local format::2001-02-03 08:05:07>><<log::)>>
<<log::Committer: >><<log committer name::Test User>><<log:: <>><<log committer email local::test.user>><<log committer email::@>><<log committer email domain::example.com>><<log::> (>><<log committer timestamp local format::2001-02-03 08:05:07>><<log::)>>
<<log::>>
<<log empty description placeholder:: (no description set)>><<log::>>
<<log::>>
<<node immutable::>> <<log::Commit ID: >><<log commit_id::0000000000000000000000000000000000000000>><<log::>>
<<log node immutable::>> <<log::Commit ID: >><<log commit_id::0000000000000000000000000000000000000000>><<log::>>
<<log::Change ID: >><<log change_id::zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz>><<log::>>
<<log::Author : >><<log name placeholder::(no name set)>><<log:: <>><<log email placeholder::(no email set)>><<log::> (>><<log author timestamp local format::1970-01-01 11:00:00>><<log::)>>
<<log::Committer: >><<log name placeholder::(no name set)>><<log:: <>><<log email placeholder::(no email set)>><<log::> (>><<log committer timestamp local format::1970-01-01 11:00:00>><<log::)>>

View File

@ -1180,11 +1180,11 @@ fn test_graph_template_color() {
");
let output = work_dir.run_jj(["--color=debug", "log", "-T", template]);
insta::assert_snapshot!(output, @r"
<<node working_copy::@>> <<log working_copy description::single line>>
<<node::>> <<log description::first line>>
<<log node working_copy::@>> <<log working_copy description::single line>>
<<log node::>> <<log description::first line>>
<<log description::second line>>
<<log description::third line>>
<<node immutable::>>
<<log node immutable::>>
[EOF]
");
}