mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-13 15:37:55 +00:00
cli: make squash
and unsquash
commands record abandoned commits
This change makes `jj squash` and `jj unsquash` record the child or parent (respectively) as abandoned if it becomes empty. We need to do that because it won't get automatically recorded by `CommitBuilder`. We could make `CommitBuilder` record abandoned commits when `set_pruned()` was called, but that would be short-sighted since we're about to delete that function as part of removing support for evolution (#32).
This commit is contained in:
parent
76352564ad
commit
6949dab389
1 changed files with 15 additions and 4 deletions
|
@ -2323,6 +2323,9 @@ from the source will be moved into the parent.
|
|||
.set_parents(vec![new_parent.id().clone()])
|
||||
.set_pruned(abandon_child)
|
||||
.write_to_repo(mut_repo);
|
||||
if abandon_child {
|
||||
mut_repo.record_abandoned_commit(commit.id().clone());
|
||||
}
|
||||
repo_command.finish_transaction(ui, tx)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -2380,10 +2383,18 @@ aborted.
|
|||
.set_predecessors(vec![parent.id().clone(), commit.id().clone()])
|
||||
.set_pruned(abandon_parent)
|
||||
.write_to_repo(mut_repo);
|
||||
// Commit the new child on top of the new parent.
|
||||
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit)
|
||||
.set_parents(vec![new_parent.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
if abandon_parent {
|
||||
mut_repo.record_abandoned_commit(parent.id().clone());
|
||||
// Commit the new child on top of the parent's parents.
|
||||
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit)
|
||||
.set_parents(parent.parent_ids())
|
||||
.write_to_repo(mut_repo);
|
||||
} else {
|
||||
// Commit the new child on top of the new parent.
|
||||
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit)
|
||||
.set_parents(vec![new_parent.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
}
|
||||
repo_command.finish_transaction(ui, tx)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue