From 0cb43c72d0d20afef086f1feb1e6edc1792ad3ac Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 29 Sep 2021 20:36:43 -0700 Subject: [PATCH] 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`. --- src/commands.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/commands.rs b/src/commands.rs index ff61241d3..443487b63 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -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: ")?;