From 7e6a968415214bec164d23635a565ce1c4ec07aa Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 26 May 2024 11:17:12 -0700 Subject: [PATCH] conflicts: consider the empty tree a non-legacy tree Since we no longer depend on legacy trees being preserved when we build new trees or merge trees, we can consider the root tree a non-legacy tree. --- cli/tests/test_operations.rs | 8 ++++---- lib/src/store.rs | 2 +- lib/tests/test_merged_tree.rs | 9 --------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/cli/tests/test_operations.rs b/cli/tests/test_operations.rs index 1ad88f081..44b22d071 100644 --- a/cli/tests/test_operations.rs +++ b/cli/tests/test_operations.rs @@ -383,7 +383,7 @@ fn test_op_abandon_ancestors() { insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###" Current operation: OperationId("10e856d0579c4aca88972ffea0a515f47f8c09dceaa2b1a5d531c83b04350f7aa64a3eff422def01eebd65df26089ef5e0f925f247a8f929c8cc858d16306e53") - Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")) + Current tree: Merge(Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))) "###); insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###" @ 10e856d0579c test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 @@ -432,7 +432,7 @@ fn test_op_abandon_ancestors() { insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###" Current operation: OperationId("445e93662d714f53fb97e450eb3793a8e1a9a4cca1e329d5a9096e65085fb96d5bb51659531145c8abf0db5da803cd11c4cecdcf9025391bc97fc6a42204a0fe") - Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")) + Current tree: Merge(Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))) "###); insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###" @ 445e93662d71 test-username@host.example.com 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00 @@ -477,7 +477,7 @@ fn test_op_abandon_without_updating_working_copy() { insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###" Current operation: OperationId("61aeade2493b190412c61b9b0711025c2cccf95966870a5f7dc2e34ab313fbef64da70d00cab2cd69ad39816faeb80a6bc866927549b84dce6cb5a437e0e515b") - Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")) + Current tree: Merge(Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))) "###); insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1", "--ignore-working-copy"]), @r###" @@ -497,7 +497,7 @@ fn test_op_abandon_without_updating_working_copy() { insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["debug", "workingcopy", "--ignore-working-copy"]), @r###" Current operation: OperationId("61aeade2493b190412c61b9b0711025c2cccf95966870a5f7dc2e34ab313fbef64da70d00cab2cd69ad39816faeb80a6bc866927549b84dce6cb5a437e0e515b") - Current tree: Legacy(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904")) + Current tree: Merge(Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))) "###); insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["op", "log", "-l1", "--ignore-working-copy"]), @r###" diff --git a/lib/src/store.rs b/lib/src/store.rs index 2b55e0abc..bdd985f5b 100644 --- a/lib/src/store.rs +++ b/lib/src/store.rs @@ -107,7 +107,7 @@ impl Store { } pub fn empty_merged_tree_id(&self) -> MergedTreeId { - MergedTreeId::Legacy(self.backend.empty_tree_id().clone()) + MergedTreeId::resolved(self.backend.empty_tree_id().clone()) } pub fn root_commit(self: &Arc) -> Commit { diff --git a/lib/tests/test_merged_tree.rs b/lib/tests/test_merged_tree.rs index 49f225b7e..daac9d592 100644 --- a/lib/tests/test_merged_tree.rs +++ b/lib/tests/test_merged_tree.rs @@ -211,15 +211,6 @@ fn test_from_legacy_tree() { MergedTreeVal::Resolved(tree.value(dir1_basename)) ); - // Also test that MergedTreeBuilder can create the same tree by starting from an - // empty legacy tree. - let mut tree_builder = MergedTreeBuilder::new(store.empty_merged_tree_id()); - for (path, value) in tree.entries() { - tree_builder.set_or_remove(path, Merge::normal(value)); - } - let recreated_legacy_id = tree_builder.write_tree(store).unwrap(); - assert_eq!(recreated_legacy_id, MergedTreeId::Legacy(tree_id.clone())); - // Create the merged tree by starting from an empty merged tree and adding // entries from the merged tree we created before let empty_merged_id_builder: MergeBuilder<_> = std::iter::repeat(store.empty_tree_id())