From c6a7c583fef155017b5658eb14a1723c29be5a1d Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 9 Jun 2024 19:32:04 -0700 Subject: [PATCH 1/2] tests: make helpers create non-legacy trees Extracted and modified from #3746 by @ilyagr. --- lib/tests/test_local_working_copy.rs | 2 +- lib/testutils/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tests/test_local_working_copy.rs b/lib/tests/test_local_working_copy.rs index 361aa7aed7..c09b328387 100644 --- a/lib/tests/test_local_working_copy.rs +++ b/lib/tests/test_local_working_copy.rs @@ -969,7 +969,7 @@ fn test_gitignores_ignored_directory_already_tracked() { } } let id = tree_builder.write_tree().unwrap(); - MergedTree::legacy(store.get_tree(RepoPath::root(), &id).unwrap()) + MergedTree::resolved(store.get_tree(RepoPath::root(), &id).unwrap()) }; let gitignore_path = RepoPath::from_internal_string(".gitignore"); diff --git a/lib/testutils/src/lib.rs b/lib/testutils/src/lib.rs index 1eba76252b..e5283d1b91 100644 --- a/lib/testutils/src/lib.rs +++ b/lib/testutils/src/lib.rs @@ -326,7 +326,7 @@ pub fn create_single_tree(repo: &Arc, path_contents: &[(&RepoPath, } pub fn create_tree(repo: &Arc, path_contents: &[(&RepoPath, &str)]) -> MergedTree { - MergedTree::legacy(create_single_tree(repo, path_contents)) + MergedTree::resolved(create_single_tree(repo, path_contents)) } #[must_use] From b798e85e82085decf9c2222b4e026030e739f769 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Tue, 23 Jul 2024 01:04:11 -0700 Subject: [PATCH 2/2] conflicts: use non-legacy `MergedTreeId` for root commit This is part of migrating away from legacy trees (with path-level conflicts). I can't think of any practical impact (we already compare the tree ids equal). --- cli/tests/test_util_command.rs | 2 +- cli/tests/test_workspaces.rs | 42 +++++++++++++++++----------------- lib/src/backend.rs | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cli/tests/test_util_command.rs b/cli/tests/test_util_command.rs index ffd2128af5..4e7502afa7 100644 --- a/cli/tests/test_util_command.rs +++ b/cli/tests/test_util_command.rs @@ -91,7 +91,7 @@ fn test_gc_operation_log() { // Now this doesn't work. let stderr = test_env.jj_cmd_failure(&repo_path, &["debug", "operation", &op_to_remove]); insta::assert_snapshot!(stderr, @r###" - Error: No operation ID matching "1708ccd0d25f313f1559dfd1c4d16f0424de23a58e946830b0f27eb1252ce9295fe018e03fa4356e6aa39520cd8b5d44b7688024428988fe4d015291a4706172" + Error: No operation ID matching "54c5f04ab3dbb32ac86f805c819cb1ef78a3c9758ee560680a465e843fa0b05f42706d0641805905ef4bab550ca805effd1ba73d1980f6cdcc42126f008e51f4" "###); } diff --git a/cli/tests/test_workspaces.rs b/cli/tests/test_workspaces.rs index 94217fbdfe..4bd653ac16 100644 --- a/cli/tests/test_workspaces.rs +++ b/cli/tests/test_workspaces.rs @@ -577,14 +577,14 @@ fn test_workspaces_current_op_discarded_by_other() { ], ); insta::assert_snapshot!(stdout, @r###" - @ 78e49a9ae1 abandon commit 3540d386892997a2a927078635a2d933e37499fb8691938a2f540c25bccffd9e8a60b2d5a8cb94bb3eeab17e1c56f96aafa2bcb66fa1e4eb96911d093d7a579e - ○ 083b1fe855 create initial working-copy commit in workspace secondary - ○ aacb3bda7d add workspace 'secondary' - ○ 46bcf7d75e new empty commit - ○ 4d2f5d7cbf snapshot working copy - ○ 2f863a1573 new empty commit - ○ f01631d976 snapshot working copy - ○ 17dbb2fe40 add workspace 'default' + @ 7337338f0b abandon commit 20dd439c4bd12c6ad56c187ac490bd0141804618f638dc5c4dc92ff9aecba20f152b23160db9dcf61beb31a5cb14091d9def5a36d11c9599cc4d2e5689236af1 + ○ f4bd4d046b create initial working-copy commit in workspace secondary + ○ 0f99641958 add workspace 'secondary' + ○ 5641361f60 new empty commit + ○ 3a6c319c59 snapshot working copy + ○ 42c6005842 new empty commit + ○ 6a45045541 snapshot working copy + ○ a9e6630bf0 add workspace 'default' ○ cecfee9647 initialize repo ○ 0000000000 "###); @@ -594,10 +594,10 @@ fn test_workspaces_current_op_discarded_by_other() { test_env.jj_cmd_ok(&main_path, &["util", "gc", "--expire=now"]); insta::assert_snapshot!(get_log_output(&test_env, &main_path), @r###" - @ cc0b087cb874 default@ - │ ○ 376eee1462a7 secondary@ + ○ 96b31dafdc41 secondary@ + │ @ 6c051bd1ccd5 default@ ├─╯ - ○ 7788883a847c + ○ 7c5b25a4fc8f ◆ 000000000000 "###); @@ -610,17 +610,17 @@ fn test_workspaces_current_op_discarded_by_other() { let (stdout, stderr) = test_env.jj_cmd_ok(&secondary_path, &["workspace", "update-stale"]); insta::assert_snapshot!(stderr, @r###" - Failed to read working copy's current operation; attempting recovery. Error message from read attempt: Object 083b1fe855c23361b504fc78eb827aaa6099067d5ccba28b4e8cd89ed35d850be68ea557f03aaeaa37a09cc91b185c03c7ac638fff1fd8234b2e2a9cc62dc2cf of type operation not found - Created and checked out recovery commit 6803354995e6 + Failed to read working copy's current operation; attempting recovery. Error message from read attempt: Object f4bd4d046b3cdf61b0fda7738a0b1414c0aedc6c8229d39a35ee26facc358cad8b588b04d7eba1302a82409c529f69dbb1ff9ea28789d935b74f123f377aa30b of type operation not found + Created and checked out recovery commit 62f70695e3b0 "###); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(get_log_output(&test_env, &main_path), @r###" - ○ a8f7db7868c1 secondary@ - ○ 376eee1462a7 - │ @ cc0b087cb874 default@ + ○ b0b400439a82 secondary@ + ○ 96b31dafdc41 + │ @ 6c051bd1ccd5 default@ ├─╯ - ○ 7788883a847c + ○ 7c5b25a4fc8f ◆ 000000000000 "###); @@ -638,8 +638,8 @@ fn test_workspaces_current_op_discarded_by_other() { A added D deleted M modified - Working copy : kmkuslsw a8f7db78 (no description set) - Parent commit: rzvqmyuk 376eee14 (empty) (no description set) + Working copy : kmkuslsw b0b40043 (no description set) + Parent commit: rzvqmyuk 96b31daf (empty) (no description set) "###); // The modified file should have the same contents it had before (not reset to // the base contents) @@ -650,9 +650,9 @@ fn test_workspaces_current_op_discarded_by_other() { let (stdout, stderr) = test_env.jj_cmd_ok(&secondary_path, &["obslog"]); insta::assert_snapshot!(stderr, @""); insta::assert_snapshot!(stdout, @r###" - @ kmkuslsw test.user@example.com 2001-02-03 08:05:18 secondary@ a8f7db78 + @ kmkuslsw test.user@example.com 2001-02-03 08:05:18 secondary@ b0b40043 │ (no description set) - ○ kmkuslsw hidden test.user@example.com 2001-02-03 08:05:18 68033549 + ○ kmkuslsw hidden test.user@example.com 2001-02-03 08:05:18 62f70695 (empty) (no description set) "###); } diff --git a/lib/src/backend.rs b/lib/src/backend.rs index 156b76fc1f..ccdad4ec89 100644 --- a/lib/src/backend.rs +++ b/lib/src/backend.rs @@ -380,7 +380,7 @@ pub fn make_root_commit(root_change_id: ChangeId, empty_tree_id: TreeId) -> Comm Commit { parents: vec![], predecessors: vec![], - root_tree: MergedTreeId::Legacy(empty_tree_id), + root_tree: MergedTreeId::resolved(empty_tree_id), change_id: root_change_id, description: String::new(), author: signature.clone(),