From 2ee1147145c6cdf39864528886b3f9250095943b Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 24 Mar 2024 23:47:12 -0700 Subject: [PATCH] rewrite: calculate `heads_to_remove` later, remove it from state Similar to the previous commit. --- lib/src/rewrite.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index 4c1ca55e8..8ea43a8f3 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -286,7 +286,6 @@ pub(crate) struct DescendantRebaser<'settings, 'repo> { // Parents of rebased/abandoned commit that should become new heads once their descendants // have been rebased. heads_to_add: HashSet, - heads_to_remove: Vec, // Options to apply during a rebase. options: RebaseOptions, @@ -367,7 +366,6 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { rebased: Default::default(), branches, heads_to_add, - heads_to_remove: Default::default(), options: Default::default(), } } @@ -518,21 +516,21 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { .cloned() .collect(); + let mut heads_to_remove = vec![]; for old_parent_id in self.mut_repo.parent_mapping.keys() { self.heads_to_add.remove(old_parent_id); if !new_commits.contains(old_parent_id) || self.rebased.contains_key(old_parent_id) { - self.heads_to_remove.push(old_parent_id.clone()); + heads_to_remove.push(old_parent_id.clone()); } } let mut view = self.mut_repo.view().store_view().clone(); - for commit_id in &self.heads_to_remove { + for commit_id in &heads_to_remove { view.head_ids.remove(commit_id); } for commit_id in &self.heads_to_add { view.head_ids.insert(commit_id.clone()); } - self.heads_to_remove.clear(); self.heads_to_add.clear(); self.mut_repo.set_view(view); }