Skip to content

Commit

Permalink
Simplify calls to CommitRewriter::replace_parents()
Browse files Browse the repository at this point in the history
Now that it takes `IntoIterator` the caller doesn't need to clone
the input `CommitIds`.
  • Loading branch information
emesterhazy committed Apr 21, 2024
1 parent 32f6f59 commit 92875bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions cli/src/commands/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,8 @@ the operation will be aborted.
|mut rewriter| {
num_rebased += 1;
if args.siblings {
rewriter.replace_parent(
second_commit.id(),
&[first_commit.id().clone(), second_commit.id().clone()],
);
rewriter
.replace_parent(second_commit.id(), [first_commit.id(), second_commit.id()]);
}
// We don't need to do anything special for the non-siblings case
// since we already marked the original commit as rewritten.
Expand Down
4 changes: 2 additions & 2 deletions lib/tests/test_rewrite_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn test_transform_descendants_sync() {
let mut rebased = HashMap::new();
tx.mut_repo()
.transform_descendants(&settings, vec![commit_b.id().clone()], |mut rewriter| {
rewriter.replace_parent(commit_a.id(), &[commit_g.id().clone()]);
rewriter.replace_parent(commit_a.id(), [commit_g.id()]);
if *rewriter.old_commit() == commit_c {
let old_id = rewriter.old_commit().id().clone();
let new_parent_ids = rewriter.new_parents().to_vec();
Expand Down Expand Up @@ -106,7 +106,7 @@ fn test_transform_descendants_sync_linearize_merge() {
let mut rebased = HashMap::new();
tx.mut_repo()
.transform_descendants(&settings, vec![commit_c.id().clone()], |mut rewriter| {
rewriter.replace_parent(commit_a.id(), &[commit_b.id().clone()]);
rewriter.replace_parent(commit_a.id(), [commit_b.id()]);
let old_commit_id = rewriter.old_commit().id().clone();
let new_commit = rewriter.rebase(&settings)?.write()?;
rebased.insert(old_commit_id, new_commit);
Expand Down

0 comments on commit 92875bf

Please sign in to comment.