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

FR: Make prioritization in jj log configurable #5506

Open
jakobhellermann opened this issue Jan 28, 2025 · 0 comments
Open

FR: Make prioritization in jj log configurable #5506

jakobhellermann opened this issue Jan 28, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@jakobhellermann
Copy link
Contributor

jakobhellermann commented Jan 28, 2025

When rendering the commit graph in jj log, jj will prioritize rendering the working copy first, and then the remaining branches. This is a good starting point for a heuristic, but it's doesn't always result in the most readable graph.

Example 1: jj prev/next

When traversing a branch with these commands, prioritizing just @ will display the otherwise linear list of commits out of order, instead of 5 4 3 @ 2 1 it will be @ 5 4 3 2 1

@   ooss jakob.hellermann 2m ago main wip
  lmxr jakob.hellermann 2m ago commit 4
  lvzk jakob.hellermann 2m ago commit 3
  romu jakob.hellermann 2m ago commit 2
  pruv jakob.hellermann 3m ago commit 1
  zzzz root()
@  vywr jakob.hellermann 1s ago (empty) (no description set)
   ooss jakob.hellermann 5m ago main wip
├─╯
  lmxr jakob.hellermann 5m ago commit 4
  lvzk jakob.hellermann 5m ago commit 3
  romu jakob.hellermann 5m ago commit 2
  pruv jakob.hellermann 5m ago commit 1
  zzzz root()
@  wrsz jakob.hellermann 27s ago (empty) (no description set)
   ooss jakob.hellermann 5m ago main wip
   lmxr jakob.hellermann 5m ago commit 4
├─╯
  lvzk jakob.hellermann 5m ago commit 3
  romu jakob.hellermann 5m ago commit 2
  pruv jakob.hellermann 5m ago commit 1
  zzzz root()

vs jj log --config 'revsets.graph-prioritize=main':

  ooss jakob.hellermann 7m ago main wip
  lmxr jakob.hellermann 7m ago commit 4
 @  rvzp jakob.hellermann 15s ago (empty) (no description set)
├─╯
  lvzk jakob.hellermann 7m ago commit 3
  romu jakob.hellermann 7m ago commit 2
  pruv jakob.hellermann 7m ago commit 1
  zzzz root()

Example 2: Megamerge

Another situation where I noticed the graph being clearer with nonstandard priorization is when you have a "megamerge" commit of some local branches, and temporarily go work on another branch that's not

jj log

@  qmkx jakob.hellermann 3m ago push-mokuookxrmnu* cli: add dynamic completions for -T template aliases
   pqmm jakob.hellermann 4m ago push-pqmmuqxxzvmt* cli: completion: derive `clap::ValueEnum` for `ColorChoice`
├─╯
   squk jakob.hellermann 4m ago add templater size_hint
├─╯
   qlvu jakob.hellermann 4m ago push-qlvuxttmqltm* templater: add String.replace("from", "to") method
├─╯
     utmp jakob.hellermann 21m ago (empty) dev
 ├─╮
    yomz jakob.hellermann 55m ago jiff-duration use jiff for duration formatting
├───╯
   qxnv jakob.hellermann 55m ago revset-prioritize* add revsets.graph-prioritize
├─╯
  xrnl bsdinis 2h ago main git_head() git: describe codepaths that require git2
  mvvt bsdinis 2h ago cli: relocate git fetch code to cli/src/commands/git/fetch.rs
  zypt bsdinis 2h ago git: update jj git clone|fetch to use new GitFetch api directly.

~
jj log --config 'revsets.graph-prioritize="description(\"dev\")"'

    utmp jakob.hellermann 22m ago (empty) dev
├─╮
   yomz jakob.hellermann 56m ago jiff-duration use jiff for duration formatting
   qxnv jakob.hellermann 56m ago revset-prioritize* add revsets.graph-prioritize
├─╯
 @  qmkx jakob.hellermann 4m ago push-mokuookxrmnu* cli: add dynamic completions for -T template aliases
├─╯
   pqmm jakob.hellermann 5m ago push-pqmmuqxxzvmt* cli: completion: derive `clap::ValueEnum` for `ColorChoice`
├─╯
   squk jakob.hellermann 5m ago add templater size_hint
├─╯
   qlvu jakob.hellermann 5m ago push-qlvuxttmqltm* templater: add String.replace("from", "to") method
├─╯
  xrnl bsdinis 2h ago main git_head() git: describe codepaths that require git2
  mvvt bsdinis 2h ago cli: relocate git fetch code to cli/src/commands/git/fetch.rs
  zypt bsdinis 2h ago git: update jj git clone|fetch to use new GitFetch api directly.

~

Solution

I've experimented with adding a graph-prioritize revset expression and changing the priorization logic to

for prio in prio_revset {
  if log_revset.contains(prio) {
    graph.prioritize_branch(prio)
  }
}
graph.prioritize_branch(@)

which is already usable with

[revsets]
graph-prioritize = "main | description('dev')"

The one thing I don't like about this solution is that it exposes an ordering of revsets, which I don't think is meant to be relied on.

@yuja yuja added the enhancement New feature or request label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants