From 0e812220af5e58a1221dc98ed643ba34641f96c3 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 22 Jun 2022 15:13:08 -0700 Subject: [PATCH] rewrite: always use `MutableRepo::edit()` when updating checkouts I think it's conceptually simpler to create a new commit and set that commit to be the checkout in each workspace than to check out the commit in one workspace and edit in the others. --- lib/src/rewrite.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index 318820ab2..33ca5c1eb 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -349,19 +349,18 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { } let new_commit = self.mut_repo.store().get_commit(new_commit_id)?; - // If several workspaces had the same old commit checked out, we want them all - // to have the same commit checked out afterwards as well, so we avoid - // calling MutableRepo::check_out() multiple times, since that might - // otherwise create a separate new commit for each workspace. let new_checkout_commit = if new_commit.is_open() { - self.mut_repo - .edit(workspaces_to_update[0].clone(), &new_commit); new_commit } else { - self.mut_repo - .check_out(workspaces_to_update[0].clone(), self.settings, &new_commit) + CommitBuilder::for_open_commit( + self.settings, + self.mut_repo.store(), + new_commit.id().clone(), + new_commit.tree_id().clone(), + ) + .write_to_repo(self.mut_repo) }; - for workspace_id in workspaces_to_update.into_iter().skip(1) { + for workspace_id in workspaces_to_update.into_iter() { self.mut_repo.edit(workspace_id, &new_checkout_commit); } Ok(())