Skip to content

Commit

Permalink
DescendantRebaser: change rebased() method to into_map() that con…
Browse files Browse the repository at this point in the history
…sumes the rebaser

This prevents a clone and does not affect the public API, as suggested
in jj-vcs#2738 (comment).
  • Loading branch information
ilyagr committed Jan 2, 2024
1 parent ddec3f9 commit 8f2e459
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ impl MutableRepo {
) -> Result<usize, TreeMergeError> {
let result = self
.rebase_descendants_return_rebaser(settings, options)?
.map_or(0, |rebaser| rebaser.rebased().len());
.map_or(0, |rebaser| rebaser.into_map().len());
self.clear_descendant_rebaser_plans();
Ok(result)
}
Expand Down Expand Up @@ -942,7 +942,7 @@ impl MutableRepo {
// enough information to describe the results of a rebase if some commits got
// abandoned
.rebase_descendants_return_rebaser(settings, options)?
.map_or(HashMap::new(), |rebaser| rebaser.rebased().clone()));
.map_or(HashMap::new(), |rebaser| rebaser.into_map()));
self.clear_descendant_rebaser_plans();
result
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
/// Returns a map from `CommitId` of old commit to new commit. Includes the
/// commits rebase so far. Does not include the inputs passed to
/// `rebase_descendants`.
pub fn rebased(&self) -> &HashMap<CommitId, CommitId> {
&self.rebased
pub fn into_map(self) -> HashMap<CommitId, CommitId> {
self.rebased
}

/// Panics if `parent_mapping` contains cycles
Expand Down

0 comments on commit 8f2e459

Please sign in to comment.