From 598cfcb89b614215139645fba96aada4404042c5 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Fri, 25 Aug 2023 23:18:24 -0700 Subject: [PATCH] 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. --- lib/src/merged_tree.rs | 10 ++++++---- lib/tests/test_working_copy.rs | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/merged_tree.rs b/lib/src/merged_tree.rs index 822663184..ceb61ce9a 100644 --- a/lib/src/merged_tree.rs +++ b/lib/src/merged_tree.rs @@ -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), + } } } diff --git a/lib/tests/test_working_copy.rs b/lib/tests/test_working_copy.rs index 3d24568d1..f3c55a61a 100644 --- a/lib/tests/test_working_copy.rs +++ b/lib/tests/test_working_copy.rs @@ -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);