Skip to content

Commit

Permalink
lib repo.rs & rewrite.rs: Move clearing of rewritten/abandoned co…
Browse files Browse the repository at this point in the history
…mmits

This commit is a little out of place in this sequence, but
it seems to make more sense for MutRepo to own these maps.
  • Loading branch information
ilyagr committed Dec 23, 2023
1 parent 2cda46d commit 0671d5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 10 additions & 9 deletions lib/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,6 @@ impl MutableRepo {
.insert(new_id);
}

pub fn clear_rewritten_commits(&mut self) {
self.rewritten_commits.clear();
}

/// Record a commit as having been abandoned in this transaction.
///
/// This record is used by `rebase_descendants` to know which commits have
Expand All @@ -856,7 +852,8 @@ impl MutableRepo {
self.abandoned_commits.insert(old_id);
}

pub fn clear_abandoned_commits(&mut self) {
fn clear_descendant_rebaser_plans(&mut self) {
self.rewritten_commits.clear();
self.abandoned_commits.clear();
}

Expand Down Expand Up @@ -902,9 +899,11 @@ impl MutableRepo {
settings: &UserSettings,
options: RebaseOptions,
) -> Result<usize, TreeMergeError> {
Ok(self
let result = self
.rebase_descendants_return_rebaser(settings, options)?
.map_or(0, |rebaser| rebaser.rebased().len()))
.map_or(0, |rebaser| rebaser.rebased().len());
self.clear_descendant_rebaser_plans();
Ok(result)
}

pub fn rebase_descendants(&mut self, settings: &UserSettings) -> Result<usize, TreeMergeError> {
Expand All @@ -915,12 +914,14 @@ impl MutableRepo {
&mut self,
settings: &UserSettings,
) -> Result<HashMap<CommitId, CommitId>, TreeMergeError> {
Ok(self
let result = Ok(self
// We do not set RebaseOptions here, since this function does not currently return
// enough information to describe the results of a rebase if some commits got
// abandoned
.rebase_descendants_return_rebaser(settings, Default::default())?
.map_or(HashMap::new(), |rebaser| rebaser.rebased().clone()))
.map_or(HashMap::new(), |rebaser| rebaser.rebased().clone()));
self.clear_descendant_rebaser_plans();
result
}

pub fn set_wc_commit(
Expand Down
2 changes: 0 additions & 2 deletions lib/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,6 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
self.heads_to_remove.clear();
self.heads_to_add.clear();
self.mut_repo.set_view(view);
self.mut_repo.clear_rewritten_commits();
self.mut_repo.clear_abandoned_commits();
Ok(None)
}

Expand Down

0 comments on commit 0671d5e

Please sign in to comment.