Skip to content

Commit

Permalink
rebase: add --insert-after and --insert-before options for `--rev…
Browse files Browse the repository at this point in the history
…isions`

This allows for rebased commits to be moved before or after any given
commits.

The general steps of the approach taken are:
1. Compute the new parents and children of the rebased commits, based on
   the provided `--insert-after`/`--insert-before` options.
2. "Extract" the commits, by rebasing its descendants onto its parents
   (i.e. identical behavior to `jj rebase -r X -d X` before shifting the
   commit to its new destination)
3. Rebase the commits onto its new parents, then rebase the new children
   and its descendants accordingly using `MutRepo::transform_descendants`.

This means there are 2 separate rebasing steps: one for the descendants
of the rebased commits, and another to shift the rebased commits and its
new children.

This can lead to repeated rebasing of the same commits if the commit to
be rebased is either an ancestor or descendant of the new children.
However, I'm not sure if there's a way to do the rebasing in one step
using the current APIs: I'm not sure if there's a way to customize the
iteration order of commits in `transform_descendants` currently.
  • Loading branch information
bnjmnt4n committed Apr 25, 2024
1 parent 7119397 commit fde5a91
Show file tree
Hide file tree
Showing 4 changed files with 1,124 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `jj rebase` now accepts revsets resolving to multiple revisions with the
`--revisions`/`-r` option.

* `jj rebase -r` now accepts `--insert-after` and `--insert-before` options to
customize the location of the rebased revisions.

### Fixed bugs

* Revsets now support `\`-escapes in string literal.
Expand Down
Loading

0 comments on commit fde5a91

Please sign in to comment.