Skip to content

Commit

Permalink
cli: add revsets.log-graph-prioritize setting
Browse files Browse the repository at this point in the history
The option will be used to prioritize branches of the `jj log` graph to
be displayed on the left.
This can make them more readable in some situations.
An example would be
```
[revsets]
log-graph-prioritize = "coalesce(description("megamerge\n"), trunk())"
```
  • Loading branch information
jakobhellermann committed Feb 12, 2025
1 parent a1fe2dc commit ee235ee
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
`ellipsis` parameter; passing this prepends or appends the ellipsis to the
content if it is truncated to fit the maximum width.

* Added `revsets.log-graph-prioritize`, which can be used to configure
which branch in the `jj log` graph is displayed on the left instead of `@`
(e.g. `coalesce(description("megamerge\n"), trunk())`)

### Fixed bugs

* `jj status` now shows untracked files under untracked directories.
Expand Down
16 changes: 10 additions & 6 deletions cli/src/commands/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ pub(crate) fn cmd_log(
}
expression
};
let prio_revset = settings.get_string("revsets.log-graph-prioritize")?;
let prio_revset = workspace_command.parse_revset(ui, &RevisionArg::from(prio_revset))?;

let repo = workspace_command.repo();
let matcher = fileset_expression.to_matcher();
Expand Down Expand Up @@ -195,14 +197,16 @@ pub(crate) fn cmd_log(
let mut graph = get_graphlog(graph_style, raw_output.as_mut());
let iter: Box<dyn Iterator<Item = _>> = {
let mut forward_iter = TopoGroupedGraphIterator::new(revset.iter_graph());
// Emit the working-copy branch first, which is usually most
// interesting. This also helps stabilize output order.
if let Some(id) = workspace_command.get_wc_commit_id() {
let has_commit = revset.containing_fn();
if has_commit(id)? {
forward_iter.prioritize_branch(id.clone());

let has_commit = revset.containing_fn();

for prio in prio_revset.evaluate_to_commit_ids()? {
let prio = prio?;
if has_commit(&prio)? {
forward_iter.prioritize_branch(prio);
}
}

// The input to TopoGroupedGraphIterator shouldn't be truncated
// because the prioritized commit must exist in the input set.
let forward_iter = forward_iter.take(args.limit.unwrap_or(usize::MAX));
Expand Down
5 changes: 5 additions & 0 deletions cli/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@
"type": "string",
"description": "Default set of revisions to simplify when no explicit revset is given for jj simplify-parents",
"default": "reachable(@, mutable())"
},
"log-graph-prioritize": {
"type": "string",
"description": "Set of revisions to prioritize when rendering the graph for jj log",
"default": "@"
}
},
"additionalProperties": {
Expand Down
1 change: 1 addition & 0 deletions cli/src/config/revsets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ simplify-parents = "reachable(@, mutable())"
# evaluate, lengthy warning messages would be printed. Use present(expr) to
# suppress symbol resolution error.
log = "present(@) | ancestors(immutable_heads().., 2) | present(trunk())"
log-graph-prioritize = "@"

[revset-aliases]
# trunk() can be overridden as '<bookmark>@<remote>'. Use present(trunk()) if
Expand Down

0 comments on commit ee235ee

Please sign in to comment.