Skip to content

graph segmentation spike #8919

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

Merged
merged 6 commits into from
Jun 7, 2025
Merged

Conversation

Byron
Copy link
Collaborator

@Byron Byron commented Jun 5, 2025

Produce a datastructure that can represent any commit-graph as segments, which is the level of detail that we are interested in.
These segments can be traversed forward and backwards, and they know the commits that are uniquely assigned to it.
Segments can have inter-segment relations, to help with dealing with related remote tracking branches.

Problems this should solve

This PR should allow us to see if this is the right way to go, as it should solve a couple of problems, all at once:

  • make complex commit-graphs graspable
    • Even though there are limits inherent to the tree-view, but it seems to do well enough for our idea of stacks.
  • make any commit-graph representable
    • map any such graph to stacks
  • make complex workspace updates possible
    • imagine updates to the rebase-engine to be able to transplant complex graphs as well
      • This would work by having well-known operations, supporting only one at a time for now, and then to return
        a pick-list for the rebase engine that can be reviewed before actually running it (i.e. dry-run built-in).

Tasks

  • research datastructure and visualization
    • use petgraph and visualize as dot (with edge/node getters) and using termtree for tree-like visualization
  • sketch data structure as graph
  • visualise hand-built data structures for testing and validation
  • basic initialisation from graph-walk
    • Find a way to do permutation testing for when there is multiple tips (and there is most of the time) - probably too hard for now with dubious value, there are many additional tests to write.
    • Split across merges
    • Split across potential stack-segments
  • map graphs to stacks.
  • Show how typical segment-walks can now be facilitated with standard algorithms

Research

Petgraph as basis for graphs

It has efficient data structures for graphs and would certainly be a good basis.
This also makes it easy to output graphs in dot format, but besides using the dot verbatim, it's of no use for visualization. Maybe it can be used from time to time to visualize it by hand via pbpaste | dot -Tsvg > out.svg.

dot (Graphviz) for visualisation

As ugly as it might have been, it has a dot -Tascii plugin, but only from v13. And that is unavailable for installation, so I couldn't even see if it is suitable.
It's impossible to build it on a Mac just to get the latest version, and clearly it's not feasible to use -Tascii because of that.

Related

Copy link

vercel bot commented Jun 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2025 3:50am

@vercel vercel bot temporarily deployed to Preview – gitbutler-components June 5, 2025 12:20 Inactive
Copy link

vercel bot commented Jun 5, 2025

@Byron is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@Byron Byron force-pushed the graph-segmentation branch from f2f40e8 to 2aac7e6 Compare June 5, 2025 12:44
@github-actions github-actions bot added the rust Pull requests that update Rust code label Jun 5, 2025
…capabilities.

This serves as basis for algorithms that can produce such a data structure from a commit graph,
on the one side, and on the other, mappings to the current stack-based data structures.

These are in turn mapped to the current data structures as consumed by the UI.
…raph`.

`but-core` really wants to have it, but it has dependencies that the core may never use.
Thus, it must be in `graph` for now until it can be removed entirely.
@Byron
Copy link
Collaborator Author

Byron commented Jun 7, 2025

Merging this first version to avoid conflicts and set the stage for more to come.
This code doesn't affect anything else meaningfully yet, but some refactoring were necessary.

@Byron Byron force-pushed the graph-segmentation branch from 511384c to 37c3017 Compare June 7, 2025 03:49
@Byron Byron merged commit 63eb9c4 into gitbutlerapp:master Jun 7, 2025
19 of 20 checks passed
@Byron Byron deleted the graph-segmentation branch June 7, 2025 04:00
@Byron Byron mentioned this pull request Jun 7, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant