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.
This commit is contained in:
Martin von Zweigbergk 2024-03-24 07:18:23 -07:00 committed by Martin von Zweigbergk
parent a6857a7a8f
commit ad16bec3a6

View file

@ -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(())
}