Skip to content

Commit

Permalink
conflicts: consider the empty tree a non-legacy tree
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinvonz committed May 27, 2024
1 parent 43bf866 commit 7e6a968
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
8 changes: 4 additions & 4 deletions cli/tests/test_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00
Expand Down Expand Up @@ -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 [email protected] 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00
Expand Down Expand Up @@ -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###"
Expand All @@ -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###"
Expand Down
2 changes: 1 addition & 1 deletion lib/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>) -> Commit {
Expand Down
9 changes: 0 additions & 9 deletions lib/tests/test_merged_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 7e6a968

Please sign in to comment.