forked from mirrors/jj
rewrite: flatten mapping from EmptyBehaviour to desired action
I think this is slightly easier to follow.
This commit is contained in:
parent
95949e8011
commit
2f93de9299
1 changed files with 14 additions and 14 deletions
|
@ -150,12 +150,15 @@ pub fn rebase_commit_with_options(
|
||||||
// Ensure we don't abandon commits with multiple parents (merge commits), even
|
// Ensure we don't abandon commits with multiple parents (merge commits), even
|
||||||
// if they're empty.
|
// if they're empty.
|
||||||
if let [parent] = new_parents {
|
if let [parent] = new_parents {
|
||||||
match options.empty {
|
let should_abandon = match options.empty {
|
||||||
EmptyBehaviour::AbandonNewlyEmpty | EmptyBehaviour::AbandonAllEmpty => {
|
EmptyBehaviour::Keep => false,
|
||||||
if *parent.tree_id() == new_tree_id
|
EmptyBehaviour::AbandonNewlyEmpty => {
|
||||||
&& (options.empty == EmptyBehaviour::AbandonAllEmpty
|
*parent.tree_id() == new_tree_id
|
||||||
|| old_base_tree_id != Some(old_commit.tree_id().clone()))
|
&& old_base_tree_id != Some(old_commit.tree_id().clone())
|
||||||
{
|
}
|
||||||
|
EmptyBehaviour::AbandonAllEmpty => *parent.tree_id() == new_tree_id,
|
||||||
|
};
|
||||||
|
if should_abandon {
|
||||||
mut_repo.record_abandoned_commit(old_commit.id().clone());
|
mut_repo.record_abandoned_commit(old_commit.id().clone());
|
||||||
// Record old_commit as being succeeded by the parent for the purposes of
|
// Record old_commit as being succeeded by the parent for the purposes of
|
||||||
// the rebase.
|
// the rebase.
|
||||||
|
@ -164,9 +167,6 @@ pub fn rebase_commit_with_options(
|
||||||
return Ok(parent.clone());
|
return Ok(parent.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EmptyBehaviour::Keep => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let new_parent_ids = new_parents
|
let new_parent_ids = new_parents
|
||||||
.iter()
|
.iter()
|
||||||
.map(|commit| commit.id().clone())
|
.map(|commit| commit.id().clone())
|
||||||
|
|
Loading…
Reference in a new issue