forked from mirrors/jj
cli: make jj close
manually check out the new commit
When a commit gets rewritten, we update any workspaces pointing to the old commit to check out the rewritten commit. If the rewritten commit is closed, we create a new working-copy commit on top of it. Since we're thinking about removing the open/closed concept, we need to make `jj close` manually create the new working-copy commit.
This commit is contained in:
parent
b0912b3199
commit
3e3299fbab
1 changed files with 14 additions and 1 deletions
|
@ -3353,7 +3353,20 @@ fn cmd_close(ui: &mut Ui, command: &CommandHelper, args: &CloseArgs) -> Result<(
|
|||
commit_builder = commit_builder.set_description(description);
|
||||
let mut tx =
|
||||
workspace_command.start_transaction(&format!("close commit {}", commit.id().hex()));
|
||||
commit_builder.write_to_repo(tx.mut_repo());
|
||||
let new_commit = commit_builder.write_to_repo(tx.mut_repo());
|
||||
let workspace_ids = tx.mut_repo().view().workspaces_for_checkout(commit.id());
|
||||
if !workspace_ids.is_empty() {
|
||||
let new_checkout = CommitBuilder::for_open_commit(
|
||||
ui.settings(),
|
||||
repo.store(),
|
||||
new_commit.id().clone(),
|
||||
new_commit.tree_id().clone(),
|
||||
)
|
||||
.write_to_repo(tx.mut_repo());
|
||||
for workspace_id in workspace_ids {
|
||||
tx.mut_repo().edit(workspace_id, &new_checkout);
|
||||
}
|
||||
}
|
||||
workspace_command.finish_transaction(ui, tx)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue