index: make first level in stats be the root index

I've confused myself a few times already thinking that level 0 is the
root, so that's probably more intuitive. It also makes tests simpler
because the initial part of the list is unchanged when a new
transaction commits.
This commit is contained in:
Martin von Zweigbergk 2021-02-15 11:04:06 -08:00
parent b122f33312
commit a51543b752
2 changed files with 3 additions and 2 deletions

View file

@ -591,6 +591,7 @@ impl<'a> CompositeIndex<'a> {
});
parent_file = file.segment_parent_file().clone();
}
levels.reverse();
IndexStats {
num_commits,

View file

@ -387,8 +387,8 @@ fn test_index_commits_incremental_empty_transaction(use_git: bool) {
assert_eq!(stats.num_merges, 0);
assert_eq!(stats.max_generation_number, 1);
assert_eq!(stats.levels.len(), 2);
assert_eq!(stats.levels[0].num_commits, 1);
assert_eq!(stats.levels[1].num_commits, 2);
assert_eq!(stats.levels[0].num_commits, 2);
assert_eq!(stats.levels[1].num_commits, 1);
assert_eq!(generation_number(index.clone(), root_commit.id()), 0);
assert_eq!(generation_number(index.clone(), commit_a.id()), 1);