From ad16bec3a629251022dbd575d01b6ff8dd53ca5c Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 24 Mar 2024 07:18:23 -0700 Subject: [PATCH] rewrite: move an assertion a little earlier I'm going to make `DescendantRebaser` share the state about rewritten commits with `MutableRepo` next. That means that the call to `rebase_commit_with_options()` will update that state, which would make this assertion fail. So let's move it a little earlier to avoid that. --- lib/src/rewrite.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index ab3e86df0..352dade38 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -569,6 +569,13 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { // The commit is already in place. return Ok(()); } + assert_eq!( + (self + .rebased.get(&old_commit_id), self + .parent_mapping.get(&old_commit_id)), + (None, None), + "Trying to rebase the same commit {old_commit_id:?} in two different ways", + ); let new_parents: Vec<_> = new_parent_ids .iter() @@ -588,17 +595,12 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { parent } }; - let previous_rebased_value = self + self .rebased .insert(old_commit_id.clone(), new_commit.id().clone()); - let previous_mapping_value = self + self .parent_mapping .insert(old_commit_id.clone(), vec![new_commit.id().clone()]); - assert_eq!( - (previous_rebased_value, previous_mapping_value), - (None, None), - "Trying to rebase the same commit {old_commit_id:?} in two different ways", - ); self.update_references(old_commit_id, vec![new_commit.id().clone()])?; Ok(()) }