New concept: "simplify to path" #90
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The last step of "simplify to rebase" is chaining a bunch of commits from the merge diagram into a linear history, taking the metadata for the new commits from the metadata for the corresponding original commits. Currently that is done using specialized code.
But this procedure can be generalized. Add a new function
create_commit_chain()that can string an arbitrary list of commits together using arbitrary commits as the source of the metadata. Also add a methodMergeState._simplify_to_path()that can do the same thing using commits taken from aMergeState.Rewrite
MergeState.simplify_to_rebase()to use the new functions.This will make it easier to add other new functionality (not part of this PR):
git rebaseallows such commits to be omitted from the rebased result, and we should too.git revert. Reverting one or more commits from your current branch can result in merge conflicts just like merging or rebasing. But these conflicts can be resolved in an incremental way using the approach discussed here. "Simplify to path" could be used to string the results together while omitting the unwanted commits and their inverses.git rebase --ontois quite a bit like the previous case, followed by appending more commits to the end of the second branch, as described midway through this comment. For that matter, some uses ofgit cherry-pickare equivalent togit rebase --onto, though I doubt that many scenarios thought of as cherry-picking would be practical to do incrementally.This change is only very lightly tested. (We need better tests!)