Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make node symbols templatable in the graphs #3313

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

algmyr
Copy link
Contributor

@algmyr algmyr commented Mar 16, 2024

No-op change styling wise for now. I suspect there will be room for bikeshedding the default style after this.

Hopefully I'm not stepping on @zummenix's toes too much here after the great idea in #3260 to just use a separate template for the elided node. 😅

Some stuff is a bit odd still, like what template to even use for the elided node? Commit template for the root it happens to be associated with? Just make it not a template and let it be a string?

Still need to update docs.

Hopefully just dropping the symbol configs I added recently is fine, especially considering there hasn't been a release with them included.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@algmyr algmyr force-pushed the push-rvnytzvxrulo branch 3 times, most recently from 3fd7760 to 6884ce8 Compare March 16, 2024 18:28
@zummenix
Copy link
Contributor

Hopefully I'm not stepping on @zummenix's toes too much here after the great idea in #3260 to just use a separate template for the elided node. 😅

Not at all. I appreciate you working on this, thank you!

I skimmed through the changes. Nice work! Seems fine to me, but I'll let owners properly review them.

Some stuff is a bit odd still, like what template to even use for the elided node? Commit template for the root it happens to be associated with? Just make it not a template and let it be a string?

I wondered almost the same questions. I was also wondering should there be different templates for different kinds of graphs (log, op log, obslog)? And users would be able to override them in their config, like for example:

[templates]
graph-log = 'my_fancy_graph_log'
graph-op-log = 'my_simple_graph_log'
graph-obslog = 'my_simple_graph_log'

cli/src/cli_util.rs Show resolved Hide resolved
cli/src/config-schema.json Outdated Show resolved Hide resolved
lib/src/settings.rs Show resolved Hide resolved
@algmyr algmyr force-pushed the push-rvnytzvxrulo branch from 6884ce8 to 230f1df Compare March 17, 2024 05:44
cli/src/commands/log.rs Outdated Show resolved Hide resolved
@algmyr algmyr force-pushed the push-rvnytzvxrulo branch 2 times, most recently from 0c84e6f to d0d5b1e Compare March 17, 2024 06:11
cli/src/commands/operation.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
@algmyr algmyr force-pushed the push-rvnytzvxrulo branch from d0d5b1e to b86f6df Compare March 17, 2024 15:40
@algmyr
Copy link
Contributor Author

algmyr commented Mar 17, 2024

Another open question. It seems feasible to include the elided revision text in the template and stop having it be hard-coded, and it seems some people have been eager to have the ability to not have that. Is it worth making the default something like this?

'"◌  " ++ label("elided", "(elided revisions)")'

@algmyr algmyr force-pushed the push-rvnytzvxrulo branch from b86f6df to e6dafb0 Compare March 17, 2024 16:29
@algmyr algmyr marked this pull request as ready for review March 17, 2024 16:29
@algmyr algmyr force-pushed the push-rvnytzvxrulo branch from e6dafb0 to 4d17661 Compare March 17, 2024 16:49
@martinvonz
Copy link
Member

'"◌ " ++ label("elided", "(elided revisions)")'

Then we would have to split that up after reading it from the config (or maybe after rendering it), right? Because the node is passed separately from the text to the graph renderer.

@algmyr
Copy link
Contributor Author

algmyr commented Mar 17, 2024

Then we would have to split that up after reading it from the config (or maybe after rendering it), right? Because the node is passed separately from the text to the graph renderer.

One option is to just write a newline in the graph, but it feels a bit hacky and maybe the two spaces for alignment in the template is not always the right spacing?

         let elided_key = (elided_target, true);
         let real_key = (elided_key.0.clone(), false);
         let edges = [Edge::Direct(real_key)];
-        let mut buffer = vec![];
-        with_content_format.write_graph_text(
-            ui.new_formatter(&mut buffer).as_mut(),
-            |formatter| writeln!(formatter.labeled("elided"), "(elided revisions)"),
-            || graph.width(&elided_key, &edges),
-        )?;
         let node_symbol = format_template(ui, &(), elided_node_template.as_ref());
         graph.add_node(
             &elided_key,
             &edges,
             &node_symbol,
-            &String::from_utf8_lossy(&buffer),
+            &"\n",
         )?;
     }
 }

@martinvonz
Copy link
Member

is not always the right spacing?

Right, there can be lines to the right of the elided node, like this:

◌ │  (elided revisions)
├─╯

@algmyr
Copy link
Contributor Author

algmyr commented Mar 17, 2024

Gotcha, let's just leave things as is then. I guess there could be yet another template introduced in the future if someone really wants it.

@algmyr algmyr force-pushed the push-rvnytzvxrulo branch from 4d17661 to c786889 Compare March 19, 2024 08:36
CHANGELOG.md Outdated Show resolved Hide resolved
@algmyr algmyr force-pushed the push-rvnytzvxrulo branch 2 times, most recently from 72284c9 to 82f5349 Compare March 20, 2024 11:56
@algmyr algmyr changed the title Make node symbols templatable in the graphs. Make node symbols templatable in the graphs Mar 20, 2024
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks, but I'll let @yuja give the final approval since he's already done a few rounds of reviews

cli/tests/test_obslog_command.rs Outdated Show resolved Hide resolved
cli/tests/test_obslog_command.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks good, thanks!

Two questions:

(To be clear, I don't intend to block this PR. I can reorder my PRs even if we agree with Option<Commit> idea.)

lib/src/settings.rs Outdated Show resolved Hide resolved
cli/src/commands/log.rs Show resolved Hide resolved
cli/src/commands/obslog.rs Show resolved Hide resolved
docs/config.md Show resolved Hide resolved
cli/src/cli_util.rs Show resolved Hide resolved
@algmyr algmyr force-pushed the push-rvnytzvxrulo branch from 82f5349 to f55adb8 Compare March 21, 2024 15:17
Adds config options
* templates.log_graph_node
* templates.log_graph_node_elided
* templates.op_log_graph_node
@algmyr algmyr force-pushed the push-rvnytzvxrulo branch from f55adb8 to 47cb14e Compare March 21, 2024 16:21
@algmyr algmyr merged commit e2eb5bd into jj-vcs:main Mar 21, 2024
16 checks passed
@algmyr algmyr deleted the push-rvnytzvxrulo branch March 21, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants