From 08faf7318e1a782ad9024af3417e275e44ff4a7f Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 25 Mar 2024 22:12:09 -0700 Subject: [PATCH] rewrite: exclude already rewritten commits from set to rebase We currently include the commits in `parent_mapping` and `abandoned` in the set of commits to visit when rebasing descendants. The reason was that we used to update branches and working copies when we visited these commits. Since we started updating refs after rebasing all commits, there's no need to even visit these commits. --- lib/src/rewrite.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index c594cb27f67..2cf1b2892ee 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -301,7 +301,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { RevsetExpression::commits(mut_repo.parent_mapping.keys().cloned().collect()).union( &RevsetExpression::commits(mut_repo.abandoned.iter().cloned().collect()), ); - let to_visit_expression = old_commits_expression.descendants(); + let to_visit_expression = old_commits_expression.descendants().minus(&old_commits_expression); let to_visit_revset = to_visit_expression.evaluate_programmatic(mut_repo).unwrap(); let to_visit: Vec<_> = to_visit_revset.iter().commits(store).try_collect().unwrap(); drop(to_visit_revset); @@ -439,12 +439,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { fn rebase_one(&mut self, old_commit: Commit) -> Result<(), TreeMergeError> { let old_commit_id = old_commit.id().clone(); - if self.mut_repo.parent_mapping.contains_key(&old_commit_id) { - // This is a commit that had already been rebased before `self` was created - // (i.e. it's part of the input for this rebase). We don't need - // to rebase it. - return Ok(()); - } + assert!(!self.mut_repo.parent_mapping.contains_key(&old_commit_id)); let old_parent_ids = old_commit.parent_ids(); let new_parent_ids = self.mut_repo.new_parents(old_parent_ids); if new_parent_ids == old_parent_ids {