transaction: don't walk to root when adding on top of non-head

I don't know why I made the walk stop at heads instead of indexed
commits before. Perhaps I did it because it's cheap to check in the
set of head. However, it gets very expensive to walk all the way back
to the root if the parents are not in the set of heads.
This commit is contained in:
Martin von Zweigbergk 2021-02-14 18:53:52 -08:00
parent 0f56e014b7
commit 37cf6a8395

View file

@ -145,6 +145,7 @@ impl<'r> Transaction<'r> {
mut_repo.view_mut().add_head(head);
mut_repo.evolution_mut().add_commit(head);
} else {
let index = mut_repo.index();
let missing_commits = topo_order_reverse(
vec![head.clone()],
Box::new(|commit: &Commit| commit.id().clone()),
@ -152,7 +153,7 @@ impl<'r> Transaction<'r> {
commit
.parents()
.into_iter()
.filter(|parent| !current_heads.contains(parent.id()))
.filter(|parent| !index.has_id(parent.id()))
.collect()
}),
);