ok/jj
1
0
Fork 0
forked from mirrors/jj

repo: when setting rewritten or divergent, remove from abandoned

I don't think we have any transactions that mark commit as abandoned
and then later mark it as rewritten or divergent. But if we ever do, I
think it should be considered just rewritten/divergent. So let's
enforce that invariant by removing the old value from the set of
abandoned commits.
This commit is contained in:
Martin von Zweigbergk 2024-03-29 23:05:52 -07:00 committed by Martin von Zweigbergk
parent 08b5b66ad4
commit db4b905bc9

View file

@ -827,6 +827,7 @@ impl MutableRepo {
pub fn set_rewritten_commit(&mut self, old_id: CommitId, new_id: CommitId) {
assert_ne!(old_id, *self.store().root_commit_id());
self.divergent.remove(&old_id);
self.abandoned.remove(&old_id);
self.parent_mapping.insert(old_id, vec![new_id]);
}
@ -843,6 +844,7 @@ impl MutableRepo {
new_ids: impl IntoIterator<Item = CommitId>,
) {
assert_ne!(old_id, *self.store().root_commit_id());
self.abandoned.remove(&old_id);
self.parent_mapping
.insert(old_id.clone(), new_ids.into_iter().collect());
self.divergent.insert(old_id);