mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 05:57:10 +00:00
96f5ca47d4
There are several existing commands that would benefit from an API that makes it easier to rewrite a whole graph of commits while transforming them in some way. `jj squash` is one example. When squashing into an ancestor, that command currently rewrites the ancestor, then rebases descendants, and then rewrites the rewritten source commit. It would be better to rewrite the source commit (and any descendants) only once. Another example is the future `jj fix`. That command will want to rewrite a graph while updating the trees. There's currently no good API for that; you have to manually iterate over descendants and rewrite them. This patch adds a new `MutableRepo::transform_descendants()` method that takes a callback which gets a `CommitRewriter` passed to it. The callback can then decide to change the parents, the tree, etc. The callback is also free to leave the commit in place or to abandon it. I updated the regular `rebase_descendants()` to use the new function in order to exercise it. I hope we can replace all of the `rebase_descendant_*()` flavors later. I added a `replace_parent()` method that was a bit useful for the test case. It could easily be hard-coded in the test case instead, but I think the method will be useful for `jj git sync` and similar in the future. |
||
---|---|---|
.. | ||
benches | ||
gen-protos | ||
proc-macros | ||
src | ||
tests | ||
testutils | ||
Cargo.toml | ||
LICENSE |