forked from mirrors/jj
cli: split: narrow scope of temporary variables of first/second commits
This commit is contained in:
parent
d637216c16
commit
4e234c1a18
1 changed files with 55 additions and 51 deletions
|
@ -122,6 +122,7 @@ the operation will be aborted.
|
|||
|
||||
// Create the first commit, which includes the changes selected by the user.
|
||||
let selected_tree = tx.repo().store().get_root_tree(&selected_tree_id)?;
|
||||
let first_commit = {
|
||||
let first_template = description_template_for_commit(
|
||||
ui,
|
||||
command.settings(),
|
||||
|
@ -131,16 +132,18 @@ the operation will be aborted.
|
|||
&base_tree,
|
||||
&selected_tree,
|
||||
)?;
|
||||
let first_description = edit_description(tx.base_repo(), &first_template, command.settings())?;
|
||||
let first_commit = tx
|
||||
.mut_repo()
|
||||
let first_description =
|
||||
edit_description(tx.base_repo(), &first_template, command.settings())?;
|
||||
tx.mut_repo()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.set_tree_id(selected_tree_id)
|
||||
.set_description(first_description)
|
||||
.write()?;
|
||||
.write()?
|
||||
};
|
||||
|
||||
// Create the second commit, which includes everything the user didn't
|
||||
// select.
|
||||
let second_commit = {
|
||||
let (second_tree, second_base_tree) = if args.parallel {
|
||||
// Merge the original commit tree with its parent using the tree
|
||||
// containing the user selected changes as the base for the merge.
|
||||
|
@ -155,7 +158,8 @@ the operation will be aborted.
|
|||
vec![first_commit.id().clone()]
|
||||
};
|
||||
let second_description = if commit.description().is_empty() {
|
||||
// If there was no description before, don't ask for one for the second commit.
|
||||
// If there was no description before, don't ask for one for the
|
||||
// second commit.
|
||||
"".to_string()
|
||||
} else {
|
||||
let second_template = description_template_for_commit(
|
||||
|
@ -169,8 +173,7 @@ the operation will be aborted.
|
|||
)?;
|
||||
edit_description(tx.base_repo(), &second_template, command.settings())?
|
||||
};
|
||||
let second_commit = tx
|
||||
.mut_repo()
|
||||
tx.mut_repo()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.set_parents(second_commit_parents)
|
||||
.set_tree_id(second_tree.id())
|
||||
|
@ -178,7 +181,8 @@ the operation will be aborted.
|
|||
// become divergent.
|
||||
.generate_new_change_id()
|
||||
.set_description(second_description)
|
||||
.write()?;
|
||||
.write()?
|
||||
};
|
||||
|
||||
// Mark the commit being split as rewritten to the second commit. As a
|
||||
// result, if @ points to the commit being split, it will point to the
|
||||
|
|
Loading…
Reference in a new issue