Skip to content

renderdag: box: option to pad between nodes from separate branches#1163

Open
thomasa88 wants to merge 3 commits intofacebook:mainfrom
thomasa88:box-drawing-branch-spacing
Open

renderdag: box: option to pad between nodes from separate branches#1163
thomasa88 wants to merge 3 commits intofacebook:mainfrom
thomasa88:box-drawing-branch-spacing

Conversation

@thomasa88
Copy link
Copy Markdown

@thomasa88 thomasa88 commented Dec 13, 2025

Makes it easier to visually scan the branches and find the heads quickly.

Before:

│ │ │ o  F some text message
│ ├───╯  that continues on the next line
│ │ │ o  E some text message
│ ├───╯  that continues on the next line
│ │ o  D some text message
│ │ │  that continues on the next line
│ │ o  C some text message
│ │ │  that continues on the next line
│ o │  B some text message
│ ├─╯  that continues on the next line
│ o  A some text message
├─╯  that continues on the next line

After:

│ │ │ o  F some text message
│ ├───╯  that continues on the next line
│ │ │
│ │ │ o  E some text message
│ ├───╯  that continues on the next line
│ │ │
│ │ o  D some text message
│ │ │  that continues on the next line
│ │ o  C some text message
│ │ │  that continues on the next line
│ │ │
│ o │  B some text message
│ ├─╯  that continues on the next line
│ o  A some text message
├─╯  that continues on the next line

@meta-cla meta-cla bot added the CLA Signed label Dec 13, 2025
Makes it easier to visually scan the branches and find the heads quickly.

Before:

    │ │ │ o  F some text message
    │ ├───╯  that continues on the next line
    │ │ │ o  E some text message
    │ ├───╯  that continues on the next line
    │ │ o  D some text message
    │ │ │  that continues on the next line
    │ │ o  C some text message
    │ │ │  that continues on the next line
    │ o │  B some text message
    │ ├─╯  that continues on the next line
    │ o  A some text message
    ├─╯  that continues on the next line



After:

    │ │ │ o  F some text message
    │ ├───╯  that continues on the next line
    │ │ │
    │ │ │ o  E some text message
    │ ├───╯  that continues on the next line
    │ │ │
    │ │ o  D some text message
    │ │ │  that continues on the next line
    │ │ o  C some text message
    │ │ │  that continues on the next line
    │ │ │
    │ o │  B some text message
    │ ├─╯  that continues on the next line
    │ o  A some text message
    ├─╯  that continues on the next line
@thomasa88 thomasa88 force-pushed the box-drawing-branch-spacing branch from 90f5bb8 to f0d2cc3 Compare December 13, 2025 12:08
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@thomasa88 has updated the pull request. You must reimport the pull request before landing.

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Dec 13, 2025

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D89118021. (Because this pull request was imported automatically, there will not be any future comments.)

Copy link
Copy Markdown
Contributor

@quark-zju quark-zju left a comment

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@quark-zju
Copy link
Copy Markdown
Contributor

Sorry for the slow review. In your example it seems inconsistent that there are no spaces between (A, B), or (D, C) but there are spaces between (E, F), (B, C), and (D, E).

If you want more spaces, have you tried appending new lines \n to "that continues on the next line", or use the with_min_row_height(3) API?

Copy link
Copy Markdown
Contributor

@quark-zju quark-zju left a comment

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@thomasa88
Copy link
Copy Markdown
Author

Sorry for the slow review. In your example it seems inconsistent that there are no spaces between (A, B), or (D, C) but there are spaces between (E, F), (B, C), and (D, E).

If you want more spaces, have you tried appending new lines \n to "that continues on the next line", or use the with_min_row_height(3) API?

Hi, DC is in fact correct as it is. It is more apparent if there are more nodes. All nodes belonging to the same branch get grouped and spacing is added between nodes from different branches. If you look at the nodes (o) you see that they are on the same branch.

Looking closer, I realize that AB should likely have the spacing, since even though they are on the same vertical line, the branch between A B should likely make them be considered belonging to different branches. 🤔 . I will have to dig in to the code a bit and see if I can fix it.

@quark-zju
Copy link
Copy Markdown
Contributor

All nodes belonging to the same branch

I see. I'm not sure renderdag is the best place to implement this. Could you check from the call-site and pass an extra newline as commit message as needed? e.g. if a commit's parent has multiple children, in your example, F, E, C, B, then just make their commit message longer by appending a new line.

Also note there is a "shorten graph" mode inherited from https://repo.mercurial-scm.org/hg/rev/ac30adb260ea for compact output. We control this mode via with_min_row_height. So unconditionally adding spaces will break users who want the compact output.

@thomasa88
Copy link
Copy Markdown
Author

I think I ended up adding the implementation into renderdag instead of the call-site (Jujutsu), as the direct caller only has information on each node's parent edges and not information on which branch a node belongs to or the number of children, as it does not, from what I remember, build the graph. Breaking other render options does not sound good 😅 .

I will look to see if I can pass more information to the caller in some good way.

@quark-zju
Copy link
Copy Markdown
Contributor

Got it. If you change renderdag could you make it customizable? This way we can keep current behaviors unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants