Skip to content

Commit

Permalink
repo: remove MutableRepo::rebase_descendants_return_map
Browse files Browse the repository at this point in the history
This function is merely a simple wrapper around
`MutableRepo::rebase_descendants_with_options_return_map`.
  • Loading branch information
bnjmnt4n committed Nov 12, 2024
1 parent 44ec7d0 commit 1aad724
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 45 deletions.
22 changes: 1 addition & 21 deletions lib/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,10 +1289,6 @@ impl MutableRepo {
/// tell this case apart since the change ids of the key and the value
/// will not match. The parent will inherit the descendants and the
/// bookmarks of the abandoned commit.
///
/// This function is similar to
/// [`MutableRepo::rebase_descendants_return_map`], but allows for
/// rebase behavior to be customized via [`RebaseOptions`].
pub fn rebase_descendants_with_options_return_map(
&mut self,
settings: &UserSettings,
Expand Down Expand Up @@ -1321,28 +1317,12 @@ impl MutableRepo {
///
/// The descendants of the commits registered in `self.parent_mappings` will
/// be recursively rebased onto the new version of their parents.
/// Returns a map of newly rebased commit ID to original commit ID.
/// Returns the number of rebased descendants.
///
/// All rebased descendant commits will be preserved even if they were
/// emptied following the rebase operation. To customize the rebase
/// behavior, use
/// [`MutableRepo::rebase_descendants_with_options_return_map`].
pub fn rebase_descendants_return_map(
&mut self,
settings: &UserSettings,
) -> BackendResult<HashMap<CommitId, CommitId>> {
self.rebase_descendants_with_options_return_map(settings, Default::default())
}

/// Rebase descendants of the rewritten commits.
///
/// The descendants of the commits registered in `self.parent_mappings` will
/// be recursively rebased onto the new version of their parents.
/// Returns the number of rebased descendants.
///
/// All rebased descendant commits will be preserved even if they were
/// emptied following the rebase operation. To customize the rebase
/// behavior, use [`MutableRepo::rebase_descendants_return_map`].
pub fn rebase_descendants(&mut self, settings: &UserSettings) -> BackendResult<usize> {
let roots = self.parent_mapping.keys().cloned().collect_vec();
let mut num_rebased = 0;
Expand Down
3 changes: 2 additions & 1 deletion lib/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,8 @@ where
// rewritten sources. Otherwise it will likely already have the content
// changes we're moving, so applying them will have no effect and the
// changes will disappear.
let rebase_map = repo.rebase_descendants_return_map(settings)?;
let rebase_map =
repo.rebase_descendants_with_options_return_map(settings, Default::default())?;
let rebased_destination_id = rebase_map.get(destination.id()).unwrap().clone();
rewritten_destination = repo.store().get_commit(&rebased_destination_id)?;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/tests/test_commit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) {
.unwrap();
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert_eq!(rebase_map.len(), 0);

Expand All @@ -365,7 +365,7 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) {
.unwrap();
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit3, &[commit4.id()]);
assert_eq!(rebase_map.len(), 1);
Expand All @@ -379,7 +379,7 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) {
.unwrap();
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert!(rebase_map.is_empty());
}
6 changes: 3 additions & 3 deletions lib/tests/test_mut_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ fn test_rebase_descendants_simple() {
mut_repo.record_abandoned_commit(commit4.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
// Commit 3 got rebased onto commit 2's replacement, i.e. commit 6
assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit3, &[commit6.id()]);
Expand All @@ -567,7 +567,7 @@ fn test_rebase_descendants_simple() {
// No more descendants to rebase if we try again.
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert_eq!(rebase_map.len(), 0);
}
Expand Down Expand Up @@ -601,7 +601,7 @@ fn test_rebase_descendants_divergent_rewrite() {
// commit 4 or commit 5
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert!(rebase_map.is_empty());
}
Expand Down
34 changes: 17 additions & 17 deletions lib/tests/test_rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn test_rebase_descendants_sideways() {
.set_rewritten_commit(commit_b.id().clone(), commit_f.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert_eq!(rebase_map.len(), 3);
let new_commit_c = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_f.id()]);
Expand Down Expand Up @@ -155,7 +155,7 @@ fn test_rebase_descendants_forward() {
.set_rewritten_commit(commit_b.id().clone(), commit_f.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_d =
assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[(commit_f.id())]);
Expand Down Expand Up @@ -216,7 +216,7 @@ fn test_rebase_descendants_reorder() {
.set_rewritten_commit(commit_g.id().clone(), commit_h.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_i = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_i, &[commit_h.id()]);
assert_eq!(rebase_map.len(), 1);
Expand Down Expand Up @@ -252,7 +252,7 @@ fn test_rebase_descendants_backward() {
.set_rewritten_commit(commit_c.id().clone(), commit_b.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_b.id()]);
assert_eq!(rebase_map.len(), 1);
Expand Down Expand Up @@ -294,7 +294,7 @@ fn test_rebase_descendants_chain_becomes_bookmarky() {
.set_rewritten_commit(commit_c.id().clone(), commit_f.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_f = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_f, &[commit_e.id()]);
let new_commit_d =
Expand Down Expand Up @@ -338,7 +338,7 @@ fn test_rebase_descendants_internal_merge() {
.set_rewritten_commit(commit_b.id().clone(), commit_f.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_c = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_f.id()]);
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_f.id()]);
Expand Down Expand Up @@ -386,7 +386,7 @@ fn test_rebase_descendants_external_merge() {
.set_rewritten_commit(commit_c.id().clone(), commit_f.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_e = assert_rebased_onto(
tx.repo_mut(),
Expand Down Expand Up @@ -430,7 +430,7 @@ fn test_rebase_descendants_abandon() {
tx.repo_mut().record_abandoned_commit(commit_e.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_c = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_a.id()]);
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_a.id()]);
Expand Down Expand Up @@ -468,7 +468,7 @@ fn test_rebase_descendants_abandon_no_descendants() {
tx.repo_mut().record_abandoned_commit(commit_c.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert_eq!(rebase_map.len(), 0);

Expand Down Expand Up @@ -507,7 +507,7 @@ fn test_rebase_descendants_abandon_and_replace() {
tx.repo_mut().record_abandoned_commit(commit_c.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_e.id()]);
assert_eq!(rebase_map.len(), 1);
Expand Down Expand Up @@ -633,7 +633,7 @@ fn test_rebase_descendants_abandon_widen_merge() {
tx.repo_mut().record_abandoned_commit(commit_e.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_f = assert_rebased_onto(
tx.repo_mut(),
Expand Down Expand Up @@ -678,7 +678,7 @@ fn test_rebase_descendants_multiple_sideways() {
.set_rewritten_commit(commit_d.id().clone(), commit_f.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_c = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_f.id()]);
let new_commit_e = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_e, &[commit_f.id()]);
Expand Down Expand Up @@ -800,7 +800,7 @@ fn test_rebase_descendants_divergent_rewrite() {
.set_rewritten_commit(commit_f.id().clone(), commit_f2.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let new_commit_c =
assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_b2.id()]);
Expand Down Expand Up @@ -851,7 +851,7 @@ fn test_rebase_descendants_repeated() {
.unwrap();
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let commit_c2 = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_b2.id()]);
assert_eq!(rebase_map.len(), 1);
Expand All @@ -866,7 +866,7 @@ fn test_rebase_descendants_repeated() {
// We made no more changes, so nothing should be rebased.
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert_eq!(rebase_map.len(), 0);

Expand All @@ -879,7 +879,7 @@ fn test_rebase_descendants_repeated() {
.unwrap();
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
let commit_c3 = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c2, &[commit_b3.id()]);
assert_eq!(rebase_map.len(), 1);
Expand Down Expand Up @@ -945,7 +945,7 @@ fn test_rebase_descendants_contents() {
.set_rewritten_commit(commit_b.id().clone(), commit_d.id().clone());
let rebase_map = tx
.repo_mut()
.rebase_descendants_return_map(&settings)
.rebase_descendants_with_options_return_map(&settings, Default::default())
.unwrap();
assert_eq!(rebase_map.len(), 1);
let new_commit_c = repo
Expand Down

0 comments on commit 1aad724

Please sign in to comment.