mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-13 15:37:55 +00:00
cli: make jj split
manually rebase descendants
When we remove evolution (#32), I don't intend to replicate the hack it had for rebasing descendants onto a split commit. Let's instead have `jj split` manually rebase descendants of the original commit onto the second part of the split. We use `DescendantRebaser` for that. Branches and the working copy pointing to the split commit are still updated using evolution in `RepoCommandHelper::finish_transaction()`. I plan to have `DescendantRebaser` update branches and working copies as well. That should then also work as expected for `jj split`.
This commit is contained in:
parent
5e0e90d81e
commit
0cb43c72d0
1 changed files with 12 additions and 1 deletions
|
@ -2533,7 +2533,7 @@ fn cmd_split(
|
|||
command: &CommandHelper,
|
||||
sub_matches: &ArgMatches,
|
||||
) -> Result<(), CommandError> {
|
||||
let mut repo_command = command.repo_helper(ui)?;
|
||||
let mut repo_command = command.repo_helper(ui)?.evolve_orphans(false);
|
||||
let commit = repo_command.resolve_revision_arg(ui, sub_matches)?;
|
||||
repo_command.check_rewriteable(&commit)?;
|
||||
let repo = repo_command.repo();
|
||||
|
@ -2576,6 +2576,17 @@ any changes, then the operation will be aborted.
|
|||
.generate_new_change_id()
|
||||
.set_description(second_description)
|
||||
.write_to_repo(mut_repo);
|
||||
let mut rebaser = DescendantRebaser::new(
|
||||
ui.settings(),
|
||||
mut_repo,
|
||||
hashmap! { commit.id().clone() => second_commit.id().clone() },
|
||||
hashset! {},
|
||||
);
|
||||
rebaser.rebase_all();
|
||||
let num_rebased = rebaser.rebased().len();
|
||||
if num_rebased > 0 {
|
||||
writeln!(ui, "Rebased {} descendant commits", num_rebased)?;
|
||||
}
|
||||
ui.write("First part: ")?;
|
||||
ui.write_commit_summary(mut_repo.as_repo_ref(), &first_commit)?;
|
||||
ui.write("\nSecond part: ")?;
|
||||
|
|
Loading…
Reference in a new issue