merged_tree: in diff iterator, maintain legacy/modern variant in subtree

As #2165 showed, when diffing two `MergedTree::Legacy` variants (or
one of each variant) and re recurse into a subtree, we need to treat
that as a legacy tree too, so we expand `TreeValue::Conflict`s found
in the diff.
This commit is contained in:
Martin von Zweigbergk 2023-08-25 23:18:24 -07:00 committed by Martin von Zweigbergk
parent f3fbdf9f84
commit 598cfcb89b
2 changed files with 6 additions and 6 deletions

View file

@ -739,10 +739,12 @@ impl<'matcher> TreeDiffIterator<'matcher> {
} else {
Merge::resolved(Tree::null(tree.store().clone(), dir.clone()))
};
// We return a `MergedTree::Merge` variant here even if `self` is a
// `MergedTree::Legacy`. That's fine since we don't expose the
// `MergedTree` to the caller.
MergedTree::Merge(trees)
// Maintain the type of tree, so we resolve `TreeValue::Conflict` as necessary
// in the subtree
match tree {
MergedTree::Legacy(_) => MergedTree::Legacy(trees.into_resolved().unwrap()),
MergedTree::Merge(_) => MergedTree::Merge(trees),
}
}
}

View file

@ -271,8 +271,6 @@ fn test_checkout_file_transitions(use_git: bool) {
// Test case for issue #2165
#[test]
// TODO(#2165): Shouldn't actually panic
#[should_panic]
fn test_conflict_subdirectory() {
let settings = testutils::user_settings();
let mut test_workspace = TestWorkspace::init(&settings, true);