-
Notifications
You must be signed in to change notification settings - Fork 346
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
Implement transform_descendants()
, rewrite jj parallelize
#3521
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments. Overall this is really cool and the descendants rebasing API seems very powerful!
b549ada
to
bebd5fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now ready for review
bebd5fe
to
b29608e
Compare
9c2bb3c
to
3e7e65f
Compare
a072d6c
to
c50227a
Compare
…nts()` 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.
We always call `.to_vec()` on the slice, so let's just have the caller pass in an owned vector instead.
`jj parallelize` was a good example of a command that can be simplified by the new API, so I decided to rewrite it as an example. The rewritten version is more flexible and doesn't actually need the restrictions from the old version (such as checking that the commits are connected). I still left the check for now to keep this patch somewhat small. A subsequent commit will remove the restrictions.
The new API makes it easy to leave commits in place if their parents didn't change, so let's do that.
I'm going to make some `jj parallelize` cases that currently error out instead be successful. Some of the will result in ancestor merges with the root commit. This patch updates those tests to avoid that.
Should make it easier to understand the graph shape when there are lots of crossing lines.
The checks are not needed by the new implementation, so just drop them.
The rewritten code is already a no-op when there's a single input. I don't think the case is common enough to warrant having a special case for performance reasons either. Also, by not having the special case, `jj parallelize <immutable commit>` fails consistently with the non-singleton case.
c50227a
to
fa6b01d
Compare
transform_descendants()
, rewrite jj parallelize
transform_descendants()
, rewrite jj parallelize
@yuja: This PR still requires an approval. I don't mean to rush you, just making sure you didn't forget it (I sometimes think that I had approved a PR that I had not approved). Take your time if you need. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thought it might be better to be reviewed by others, but the change looks good to me.
Makes sense. Thanks for reviewing! @bnjmnt4n, @emesterhazy, and/or @ilyagr might want to take a look. I'll merge it based on Yuya's review and to unblock e.g. Benjamin's |
This is following on the rewrite for `parallelize`. - #3521 Since rebase_descendants from rebase.rs is no longer used outside of that file, it can be made private again.
This is following on the rewrite for `parallelize`. - #3521 Since rebase_descendants from rebase.rs is no longer used outside of that file, it can be made private again.
This is following on the rewrite for `parallelize`. - #3521 Since rebase_descendants from rebase.rs is no longer used outside of that file, it can be made private again.
This is following on the rewrite for `parallelize`. - #3521 Since rebase_descendants from rebase.rs is no longer used outside of that file, it can be made private again.
This is following on the rewrite for `parallelize`. - #3521 Since rebase_descendants from rebase.rs is no longer used outside of that file, it can be made private again.
This is following on the rewrite for `parallelize`. - #3521 Since rebase_descendants from rebase.rs is no longer used outside of that file, it can be made private again.
This is following on the rewrite for `parallelize`. - #3521 Since rebase_descendants from rebase.rs is no longer used outside of that file, it can be made private again.
@bnjmnt4n: This PR includes the
transform_descendants()
function.@emesterhazy: FYI, this is how I'm planning to rewrite
jj parallelize
.Checklist
If applicable:
CHANGELOG.md