forked from mirrors/jj
cli: move a few transaction description variables later
Now that we don't need the transaction until later, let's move the variables closer to where they're used.
This commit is contained in:
parent
60fae3114e
commit
24b1421918
2 changed files with 19 additions and 19 deletions
|
@ -49,15 +49,6 @@ pub(crate) fn cmd_abandon(
|
|||
let mut workspace_command = command.workspace_helper(ui)?;
|
||||
let to_abandon = resolve_multiple_nonempty_revsets(&args.revisions, &workspace_command, ui)?;
|
||||
workspace_command.check_rewritable(to_abandon.iter())?;
|
||||
let transaction_description = if to_abandon.len() == 1 {
|
||||
format!("abandon commit {}", to_abandon[0].id().hex())
|
||||
} else {
|
||||
format!(
|
||||
"abandon commit {} and {} more",
|
||||
to_abandon[0].id().hex(),
|
||||
to_abandon.len() - 1
|
||||
)
|
||||
};
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
for commit in &to_abandon {
|
||||
tx.mut_repo().record_abandoned_commit(commit.id().clone());
|
||||
|
@ -71,10 +62,10 @@ pub(crate) fn cmd_abandon(
|
|||
writeln!(ui.stderr())?;
|
||||
} else if !args.summary {
|
||||
writeln!(ui.stderr(), "Abandoned the following commits:")?;
|
||||
for commit in to_abandon {
|
||||
for commit in &to_abandon {
|
||||
write!(ui.stderr(), " ")?;
|
||||
tx.base_workspace_helper()
|
||||
.write_commit_summary(ui.stderr_formatter().as_mut(), &commit)?;
|
||||
.write_commit_summary(ui.stderr_formatter().as_mut(), commit)?;
|
||||
writeln!(ui.stderr())?;
|
||||
}
|
||||
} else {
|
||||
|
@ -86,6 +77,15 @@ pub(crate) fn cmd_abandon(
|
|||
"Rebased {num_rebased} descendant commits onto parents of abandoned commits"
|
||||
)?;
|
||||
}
|
||||
let transaction_description = if to_abandon.len() == 1 {
|
||||
format!("abandon commit {}", to_abandon[0].id().hex())
|
||||
} else {
|
||||
format!(
|
||||
"abandon commit {} and {} more",
|
||||
to_abandon[0].id().hex(),
|
||||
to_abandon.len() - 1
|
||||
)
|
||||
};
|
||||
tx.finish(ui, transaction_description)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -277,14 +277,6 @@ fn rebase_descendants(
|
|||
for old_commit in old_commits.iter() {
|
||||
check_rebase_destinations(workspace_command.repo(), new_parents, old_commit)?;
|
||||
}
|
||||
let tx_message = if old_commits.len() == 1 {
|
||||
format!(
|
||||
"rebase commit {} and descendants",
|
||||
old_commits.first().unwrap().id().hex()
|
||||
)
|
||||
} else {
|
||||
format!("rebase {} commits and their descendants", old_commits.len())
|
||||
};
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
// `rebase_descendants` takes care of sorting in reverse topological order, so
|
||||
// no need to do it here.
|
||||
|
@ -301,6 +293,14 @@ fn rebase_descendants(
|
|||
+ tx.mut_repo()
|
||||
.rebase_descendants_with_options(settings, rebase_options)?;
|
||||
writeln!(ui.stderr(), "Rebased {num_rebased} commits")?;
|
||||
let tx_message = if old_commits.len() == 1 {
|
||||
format!(
|
||||
"rebase commit {} and descendants",
|
||||
old_commits.first().unwrap().id().hex()
|
||||
)
|
||||
} else {
|
||||
format!("rebase {} commits and their descendants", old_commits.len())
|
||||
};
|
||||
tx.finish(ui, tx_message)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue