From 890a8e282f6edc589eead98a54c8137543135938 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 23 Mar 2024 06:22:28 -0700 Subject: [PATCH] repo: update working copy to first divergent commit --- lib/src/repo.rs | 12 +++++------- lib/src/rewrite.rs | 3 +-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 0162c700e..56a354ea8 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -732,7 +732,7 @@ pub struct MutableRepo { base_repo: Arc, index: Box, view: DirtyCell, - rewritten_commits: HashMap>, + rewritten_commits: HashMap>, abandoned_commits: HashSet, } @@ -816,18 +816,16 @@ impl MutableRepo { /// docstring for `record_rewritten_commit` for details. pub fn set_rewritten_commit(&mut self, old_id: CommitId, new_id: CommitId) { assert_ne!(old_id, *self.store().root_commit_id()); - self.rewritten_commits - .insert(old_id, std::iter::once(new_id).collect()); + self.rewritten_commits.insert(old_id, vec![new_id]); } /// Record a commit as being rewritten into multiple other commits in this /// transaction. /// /// A later call to `rebase_descendants()` will update branches pointing to - /// `old_id` be conflicted and pointing to all pf `new_ids`. Working - /// copies pointing to `old_id` will be updated to point to an arbitrary - /// commit in `new_ids` (TODO: make it point to the first one). Descendants - /// of `old_id` will be left alone. + /// `old_id` be conflicted and pointing to all pf `new_ids`. Working copies + /// pointing to `old_id` will be updated to point to the first commit in + /// `new_ids``. Descendants of `old_id` will be left alone. pub fn set_divergent_rewrite( &mut self, old_id: CommitId, diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index 1d84d6aef..f3973ac9a 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -313,7 +313,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { pub fn new( settings: &'settings UserSettings, mut_repo: &'repo mut MutableRepo, - rewritten: HashMap>, + rewritten: HashMap>, abandoned: HashSet, ) -> DescendantRebaser<'settings, 'repo> { let store = mut_repo.store(); @@ -372,7 +372,6 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { if new_commits.len() == 1 { parent_mapping.insert(old_commit, vec![new_commits.into_iter().next().unwrap()]); } else { - // The call to index.heads() is mostly to get a predictable order let new_commits = mut_repo.index().heads(&mut new_commits.iter()); parent_mapping.insert(old_commit.clone(), new_commits); divergent.insert(old_commit);