Replies: 4 comments 10 replies
-
|
Does this include the case of |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for starting this discussion! We should also keep in mind the use case of parallelizing commits (#1079, #2274). Also, you didn't explicitly mention the pretty basic Another important use case that The new API seems more complicated to me at first glance. It would be useful to explain how it makes things simpler. I think the main benefit is that the CLI crate will be able to simply call Actually, since your change to |
Beta Was this translation helpful? Give feedback.
-
I wasn't considering about it that deeper. My point was just low-level |
Beta Was this translation helpful? Give feedback.
-
|
A note about how my plans relate to this. They are rather vague at the moment, so suggestions are welcome in this area as well.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here is a draft my thoughts of where we could go with the rewrite API after #2737 and #2738. This is in a draft state right now, I wrote up my thoughts rather quickly.
The idea is to slowly move logic for the tricky parts of rewrites (especially edge cases like weird ancestry) to the lib crate. It's not entirely obvious what the primitives for the more complicated rewrite operations should be so that one can wrap their mind around them. This write-up is an attempt to pick such primitives.
I hope to reuse pieces of the
DescendantRebaserimplementation to decrease duplication.WDYT, @yuja, @martinvonz? Is there a way to have a simpler mental model that this? Did I miss some important use-case?
Use cases to support
jj splitjj rebase -r -d descendantjj new --afterorjj rebase -r --afterjj new --beforeorjj rebase -r --before(seems simple on second thought)In all of these cases, the CLI crate should care as little as possible about the possible weird ancestry (#2600, #2650 ) in the commit graph.
Design
Step 1
I assume familiarity with the current
MutRepodesign.I propose adding a bit of config to each rewritten commit, called
RemainingRewriteActionsbelow. Then, we add customized options of the current API:UPDATE: Instead of
move_branches, we probably wantabandon_original: bool. This controls another essential piece ofrebase_descendantsfunctionality: ifabandon_originalis false, the original commit is not abandoned and branches are not moved. We could in principle allow moving branches without abandoning commit, but I don't think there's a need right now. The rest of this write-up should work unchanged withabandon_originalreplacingmove_brancheseverywhere.Normal rebase/abandon
No significant changes to their implementation
jj splitRewrite
jj splitto useto make the parent commit. As a result,
DescendantRebasershould ignore this rewrite. Then,splitwould use a normalrewrite_commitfor the child commit.jj rebase -r X -d descendantInstead of the current custom code, use
to rebase the descendants of
Xonto the parents ofXbefore movingXitself (instead of current custom code).The above code should change
to
without moving any branches at
X.Afterwards,
rebasecan actually rebaseXto its destination.rebase_descendantsshould ensure that this works even ifB2is a descendant ofB1.Step 2:
--afterChange
RemainingRewriteActions::rebase_descendantsfrom aboolto andenum:Let's say we start with
and try
jj rebase -r X --after A1.If
Xwas not a descendant ofA1, we could rewriteA1toXifXis an ancestor, but troublesome if it is a descendant.Instead, rebase
XontoA1as usual to getThen use
This should result in
(
jj new --after A1can be done similarly)rebase_descendantsshould ensure that this works even ifB2is a descendant ofB1.--beforeThis seems much easier than
--afterand does not use the new APIs.Let's start with the same graph,
and try
jj new --before B1.We'd create a new commit
Xwithparents(X) = parents(B1):Unless I missed something, we only need to now do a simple rebase of
B1ontoX. (I was originally thinking about usingRebaseDescendants::Only)Step A (orthogonal to the above)
Extract the relevant
MutRepooperations to a wrapper calledIncompleteRewritethat holds an&mut MutReporeference.IncompleteRewrite::dropcalls an analogue ofrebase_descendants.As a result, when you have a
MutRepoobject, you can be sure it does not need arebase_descendantsto be in a consistent state.This is my interpretation of @yuja's suggestion from #2737 (comment).
Step B (orthogonal to the above)
Remember
parent_mappingin the rewrite API. Until this happens, the CLI crate would need to callrebase_descendants_return_mapand keep track of the parent mapping.Step C (orthogonal to the above)
Consider consolidating currently existing
RebaseOptionsandRemainingRewriteActions.Beta Was this translation helpful? Give feedback.
All reactions