Skip to content

Commit

Permalink
rewrite: exclude already rewritten commits from set to rebase
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinvonz committed Mar 26, 2024
1 parent 49ff818 commit 9c382fd
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ 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);
Expand Down Expand Up @@ -439,12 +441,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 {
Expand Down

0 comments on commit 9c382fd

Please sign in to comment.