From ae62b5b9466f7e977b6d796b2e6126f872c2570c Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 7 Oct 2024 11:00:37 +0900 Subject: [PATCH] repo: teach OpStore about the root commit id This removes an invalid View state from the root operation. Note that the root index will have to be reindexed in order to resolve "root()" in the root operation. I don't think this would practically matter, so this patch doesn't bump the index version to invalidate the existing indexes. See also 48a9f9ef56c1 "repo: use Transaction for creating repo-init operation." --- cli/tests/test_concurrent_operations.rs | 51 +-- cli/tests/test_debug_command.rs | 6 +- cli/tests/test_duplicate_command.rs | 4 +- cli/tests/test_git_clone.rs | 6 +- cli/tests/test_git_colocated.rs | 2 +- cli/tests/test_git_fetch.rs | 6 +- cli/tests/test_git_import_export.rs | 6 +- cli/tests/test_operations.rs | 553 ++++++++++-------------- cli/tests/test_rebase_command.rs | 2 +- cli/tests/test_util_command.rs | 6 +- cli/tests/test_workspaces.rs | 83 ++-- lib/src/op_store.rs | 37 +- lib/src/repo.rs | 10 +- lib/src/simple_op_store.rs | 16 +- lib/tests/test_commit_concurrent.rs | 12 +- lib/tests/test_operations.rs | 37 +- lib/tests/test_revset.rs | 10 +- 17 files changed, 393 insertions(+), 454 deletions(-) diff --git a/cli/tests/test_concurrent_operations.rs b/cli/tests/test_concurrent_operations.rs index 48109d77d..89642be21 100644 --- a/cli/tests/test_concurrent_operations.rs +++ b/cli/tests/test_concurrent_operations.rs @@ -32,23 +32,21 @@ fn test_concurrent_operation_divergence() { // "--at-op=@" disables op heads merging, and prints head operation ids. let stderr = test_env.jj_cmd_failure(&repo_path, &["op", "log", "--at-op=@"]); - insta::assert_snapshot!(stderr, @r###" + insta::assert_snapshot!(stderr, @r#" Error: The "@" expression resolved to more than one operation - Hint: Try specifying one of the operations by ID: e31015019d90, 48f4a48f3f70 - "###); + Hint: Try specifying one of the operations by ID: 0162305507cc, d74dff64472e + "#); // "op log --at-op" should work without merging the head operations - let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "--at-op=48f4a48f3f70"]); - insta::assert_snapshot!(stdout, @r###" - @ 48f4a48f3f70 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 + let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "--at-op=d74dff64472e"]); + insta::assert_snapshot!(stdout, @r#" + @ d74dff64472e test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 │ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 │ args: jj describe -m 'message 2' --at-op @- - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); // We should be informed about the concurrent modification let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["log", "-T", "description"]); @@ -72,19 +70,17 @@ fn test_concurrent_operations_auto_rebase() { std::fs::write(repo_path.join("file"), "contents").unwrap(); test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); - insta::assert_snapshot!(stdout, @r###" - @ 66d1dd775c54 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + insta::assert_snapshot!(stdout, @r#" + @ c62ace5c0522 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ describe commit 4e8f9d2be039994f589b4e57ac5e9488703e604d │ args: jj describe -m initial - ○ 130d67859810 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + ○ 82d32fc68fc3 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ snapshot working copy │ args: jj describe -m initial - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); let op_id_hex = stdout[3..15].to_string(); test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "rewritten"]); @@ -152,7 +148,7 @@ fn test_concurrent_operations_wc_modified() { // The working copy should be committed after merging the operations let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "-Tdescription"]); - insta::assert_snapshot!(stdout, @r###" + insta::assert_snapshot!(stdout, @r#" @ snapshot working copy ○ reconcile divergent operations ├─╮ @@ -162,9 +158,8 @@ fn test_concurrent_operations_wc_modified() { ○ describe commit 506f4ec3c2c62befa15fabc34ca9d4e6d7bef254 ○ snapshot working copy ○ add workspace 'default' - ○ initialize repo ○ - "###); + "#); } #[test] @@ -187,26 +182,24 @@ fn test_concurrent_snapshot_wc_reloadable() { let template = r#"id ++ "\n" ++ description ++ "\n" ++ tags"#; let op_log_stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "-T", template]); - insta::assert_snapshot!(op_log_stdout, @r###" - @ 9f11958bcf79340028eeabf9b0381cd8d2ae2258d0097b8ce8bd24fe7138eca08d9eb113bb4722ebacd9b7a6fa017e3888f72907be7487f275823c8d21359eed + insta::assert_snapshot!(op_log_stdout, @r#" + @ ec6bf266624bbaed55833a34ae62fa95c0e9efa651b94eb28846972da645845052dcdc8580332a5628849f23f48b9e99fc728dc3fb13106df8d0666d746f8b85 │ commit 554d22b2c43c1c47e279430197363e8daabe2fd6 │ args: jj commit -m 'new child1' - ○ f5460e8f43a04fbc61553d12fa5ba8d3b12e4fdcfda1999db6b67cc8e1e473b7e62cc0536196a53b84f34e18c1c6d608f427bb64bd5f834f845a9859e39cb320 + ○ 23858df860b789e8176a73c0eb21804e3f1848f26d68b70d234c004d08980c41499b6669042bca20fbc2543c437222a084c7cd473e91c7a9a095a02bf38544ab │ snapshot working copy │ args: jj commit -m 'new child1' - ○ 49359b6597ead3fbb66802a6bbd8761c0ad4646a2b089090d6fd72fb6e2568aa99c4a92f9f1f252a83cce56ec84961c36e85f731f19fc5a4c24d6a3f7282b774 + ○ e1db5fa988fc66e5cc0491b00c53fb93e25e730341c850cb42e1e0db0c76d2b4065005787563301b1d292c104f381918897f7deabeb92d2532f42ce75d3fe588 │ commit de71e09289762a65f80bb1c3dae2a949df6bcde7 │ args: jj commit -m initial - ○ 86dbba2b96a4a801abef7f77f8fdf338b6e36f81ea4a531aacf06acbd06f4037731fffef42503c2225fdb206488971c1601ca8b2b4a83a3fe2dce64ee4db085e + ○ 7de878155a459b7751097222132c935f9dcbb8f69a72b0f3a9036345a963010a553dc7c92964220128679ead72b087ca3aaf4ab9e20a221d1ffa4f9e92a32193 │ snapshot working copy │ args: jj commit -m initial - ○ b51416386f2685fd5493f2b20e8eec3c24a1776d9e1a7cb5ed7e30d2d9c88c0c1e1fe71b0b7358cba60de42533d1228ed9878f2f89817d892c803395ccf9fe92 + ○ eac759b9ab75793fd3da96e60939fb48f2cd2b2a9c1f13ffe723cf620f3005b8d3e7e923634a07ea39513e4f2f360c87b9ad5d331cf90d7a844864b83b72eba1 │ add workspace 'default' - ○ 9a7d829846af88a2f7a1e348fb46ff58729e49632bc9c6a052aec8501563cb0d10f4a4e6010ffde529f84a2b9b5b3a4c211a889106a41f6c076dfdacc79f6af7 - │ initialize repo ○ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - "###); + "#); let op_log_lines = op_log_stdout.lines().collect_vec(); let current_op_id = op_log_lines[0].split_once(" ").unwrap().1; let previous_op_id = op_log_lines[6].split_once(" ").unwrap().1; diff --git a/cli/tests/test_debug_command.rs b/cli/tests/test_debug_command.rs index fecb01d44..8aeda3ac8 100644 --- a/cli/tests/test_debug_command.rs +++ b/cli/tests/test_debug_command.rs @@ -235,9 +235,9 @@ fn test_debug_operation_id() { let workspace_path = test_env.env_root().join("repo"); let stdout = test_env.jj_cmd_success(&workspace_path, &["debug", "operation", "--display", "id"]); - assert_snapshot!(filter_index_stats(&stdout), @r###" - b51416386f2685fd5493f2b20e8eec3c24a1776d9e1a7cb5ed7e30d2d9c88c0c1e1fe71b0b7358cba60de42533d1228ed9878f2f89817d892c803395ccf9fe92 - "### + assert_snapshot!(filter_index_stats(&stdout), @r#" + eac759b9ab75793fd3da96e60939fb48f2cd2b2a9c1f13ffe723cf620f3005b8d3e7e923634a07ea39513e4f2f360c87b9ad5d331cf90d7a844864b83b72eba1 + "# ); } diff --git a/cli/tests/test_duplicate_command.rs b/cli/tests/test_duplicate_command.rs index 62c57bd26..a6a30775d 100644 --- a/cli/tests/test_duplicate_command.rs +++ b/cli/tests/test_duplicate_command.rs @@ -76,7 +76,7 @@ fn test_duplicate() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["undo"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Undid operation c4b0b2a977fe 2001-02-03 04:05:17.000 +07:00 - 2001-02-03 04:05:17.000 +07:00 duplicate 1 commit(s) + Undid operation b5bdbb51ab28 2001-02-03 04:05:17.000 +07:00 - 2001-02-03 04:05:17.000 +07:00 duplicate 1 commit(s) "#); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["duplicate" /* duplicates `c` */]); insta::assert_snapshot!(stdout, @""); @@ -280,7 +280,7 @@ fn test_undo_after_duplicate() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["undo"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Undid operation 5a2bcfcdd78b 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 duplicate 1 commit(s) + Undid operation e3dbefa46ed5 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 duplicate 1 commit(s) "#); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @ 2443ea76b0b1 a diff --git a/cli/tests/test_git_clone.rs b/cli/tests/test_git_clone.rs index d8b611fa9..a9022346b 100644 --- a/cli/tests/test_git_clone.rs +++ b/cli/tests/test_git_clone.rs @@ -475,11 +475,11 @@ fn test_git_clone_ignore_working_copy() { // TODO: Correct, but might be better to check out the root commit? let stderr = test_env.jj_cmd_failure(&clone_path, &["status"]); - insta::assert_snapshot!(stderr, @r###" - Error: The working copy is stale (not updated since operation b51416386f26). + insta::assert_snapshot!(stderr, @r##" + Error: The working copy is stale (not updated since operation eac759b9ab75). Hint: Run `jj workspace update-stale` to update it. See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy for more information. - "###); + "##); } #[test] diff --git a/cli/tests/test_git_colocated.rs b/cli/tests/test_git_colocated.rs index 1fc33b3ac..162060c70 100644 --- a/cli/tests/test_git_colocated.rs +++ b/cli/tests/test_git_colocated.rs @@ -757,7 +757,7 @@ fn test_git_colocated_undo_head_move() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["undo"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Undid operation 951a1c249028 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 new empty commit + Undid operation b50ec983d1c1 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 new empty commit Working copy now at: royxmykx eb08b363 (empty) (no description set) Parent commit : qpvuntsm 230dd059 (empty) (no description set) "#); diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index b09980993..5a3c49438 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -932,7 +932,7 @@ fn test_git_fetch_undo() { let (stdout, stderr) = test_env.jj_cmd_ok(&target_jj_repo_path, &["undo"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Undid operation bbebbf6a6ebe 2001-02-03 04:05:18.000 +07:00 - 2001-02-03 04:05:18.000 +07:00 fetch from git remote(s) origin + Undid operation eb2029853b02 2001-02-03 04:05:18.000 +07:00 - 2001-02-03 04:05:18.000 +07:00 fetch from git remote(s) origin "#); // The undo works as expected insta::assert_snapshot!(get_log_output(&test_env, &target_jj_repo_path), @r###" @@ -1018,7 +1018,7 @@ fn test_fetch_undo_what() { ); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Restored to operation b51416386f26 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' + Restored to operation eac759b9ab75 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' "#); insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###" b (deleted) @@ -1047,7 +1047,7 @@ fn test_fetch_undo_what() { ); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Restored to operation b51416386f26 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' + Restored to operation eac759b9ab75 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' "#); insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###" newbookmark: qpvuntsm 230dd059 (empty) (no description set) diff --git a/cli/tests/test_git_import_export.rs b/cli/tests/test_git_import_export.rs index dff6b1136..89e7a59fa 100644 --- a/cli/tests/test_git_import_export.rs +++ b/cli/tests/test_git_import_export.rs @@ -101,7 +101,7 @@ fn test_git_export_undo() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "undo"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Undid operation 1bc51ad79d63 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 export git refs + Undid operation b27a68390bea 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 export git refs "#); insta::assert_debug_snapshot!(get_git_repo_refs(&git_repo), @r###" [ @@ -162,7 +162,7 @@ fn test_git_import_undo() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "restore", &base_operation_id]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Restored to operation b51416386f26 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' + Restored to operation eac759b9ab75 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' "#); insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @""); // Try "git import" again, which should re-import the bookmark "a". @@ -228,7 +228,7 @@ fn test_git_import_move_export_with_default_undo() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "restore", &base_operation_id]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Restored to operation b51416386f26 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' + Restored to operation eac759b9ab75 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' Working copy now at: qpvuntsm 230dd059 (empty) (no description set) Parent commit : zzzzzzzz 00000000 (empty) (no description set) "#); diff --git a/cli/tests/test_operations.rs b/cli/tests/test_operations.rs index 565ac35ff..793f6fb0b 100644 --- a/cli/tests/test_operations.rs +++ b/cli/tests/test_operations.rs @@ -37,24 +37,18 @@ fn test_op_log() { "template-aliases.'format_time_range(x)' = 'x'", ], ); - insta::assert_snapshot!(&stdout, @r###" - @ c1851f1c3d90 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + @ d009cfc04993 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 │ args: jj describe -m 'description 0' - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); let op_log_lines = stdout.lines().collect_vec(); let add_workspace_id = op_log_lines[3].split(' ').nth(2).unwrap(); - let initialize_repo_id = op_log_lines[5].split(' ').nth(2).unwrap(); // Can load the repo at a specific operation ID - insta::assert_snapshot!(get_log_output(&test_env, &repo_path, initialize_repo_id), @r###" - ◆ 0000000000000000000000000000000000000000 - "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path, add_workspace_id), @r###" @ 230dd059e1b059aefc0da06a2e5a7dbf22362f22 ◆ 0000000000000000000000000000000000000000 @@ -70,8 +64,8 @@ fn test_op_log() { ◆ 0000000000000000000000000000000000000000 "###); insta::assert_snapshot!( - test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "@----"]), @r###" - Error: The "@----" expression resolved to no operations + test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "@---"]), @r###" + Error: The "@---" expression resolved to no operations "###); // We get a reasonable message if an invalid operation ID is specified @@ -81,7 +75,7 @@ fn test_op_log() { let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "--op-diff"]); insta::assert_snapshot!(&stdout, @r#" - @ c1851f1c3d90 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + @ d009cfc04993 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 │ args: jj describe -m 'description 0' │ @@ -89,18 +83,12 @@ fn test_op_log() { │ ○ Change qpvuntsmwlqt │ + qpvuntsm 19611c99 (empty) description 0 │ - qpvuntsm hidden 230dd059 (empty) (no description set) - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' │ │ Changed commits: │ ○ Change qpvuntsmwlqt │ + qpvuntsm 230dd059 (empty) (no description set) - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo - │ - │ Changed commits: - │ ○ Change zzzzzzzzzzzz - │ + zzzzzzzz 00000000 (empty) (no description set) ○ 000000000000 root() "#); @@ -115,10 +103,10 @@ fn test_op_log() { add_workspace_id, ], ); - insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "@-"]), @r###" + insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "@-"]), @r#" Error: The "@" expression resolved to more than one operation - Hint: Try specifying one of the operations by ID: c05f56726c27, f9fdb4e100bd - "###); + Hint: Try specifying one of the operations by ID: fd29e648380b, 3e8ef7115a0c + "#); } #[test] @@ -140,16 +128,14 @@ fn test_op_log_with_custom_symbols() { ), ], ); - insta::assert_snapshot!(&stdout, @r###" - $ c1851f1c3d90 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + $ d009cfc04993 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 │ args: jj describe -m 'description 0' - ┝ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ┝ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ┝ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ┴ 000000000000 root() - "###); + "#); } #[test] @@ -201,28 +187,20 @@ fn test_op_log_no_graph() { let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "--no-graph", "--color=always"]); - insta::assert_snapshot!(stdout, @r###" - b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + insta::assert_snapshot!(stdout, @r#" + eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' - 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - initialize repo 000000000000 root() - "###); + "#); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "--op-diff", "--no-graph"]); insta::assert_snapshot!(&stdout, @r#" - b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' Changed commits: Change qpvuntsmwlqt + qpvuntsm 230dd059 (empty) (no description set) - 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - initialize repo - - Changed commits: - Change zzzzzzzzzzzz - + zzzzzzzz 00000000 (empty) (no description set) 000000000000 root() "#); } @@ -245,7 +223,7 @@ fn test_op_log_no_graph_null_terminated() { r#"id.short(4) ++ "\0""#, ], ); - insta::assert_debug_snapshot!(stdout, @r###""8a30\05cec\0b514\09a7d\00000\0""###); + insta::assert_debug_snapshot!(stdout, @r#""ef17\0f412\0eac7\00000\0""#); } #[test] @@ -255,25 +233,22 @@ fn test_op_log_template() { let repo_path = test_env.env_root().join("repo"); let render = |template| test_env.jj_cmd_success(&repo_path, &["op", "log", "-T", template]); - insta::assert_snapshot!(render(r#"id ++ "\n""#), @r###" - @ b51416386f2685fd5493f2b20e8eec3c24a1776d9e1a7cb5ed7e30d2d9c88c0c1e1fe71b0b7358cba60de42533d1228ed9878f2f89817d892c803395ccf9fe92 - ○ 9a7d829846af88a2f7a1e348fb46ff58729e49632bc9c6a052aec8501563cb0d10f4a4e6010ffde529f84a2b9b5b3a4c211a889106a41f6c076dfdacc79f6af7 + insta::assert_snapshot!(render(r#"id ++ "\n""#), @r#" + @ eac759b9ab75793fd3da96e60939fb48f2cd2b2a9c1f13ffe723cf620f3005b8d3e7e923634a07ea39513e4f2f360c87b9ad5d331cf90d7a844864b83b72eba1 ○ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - "###); + "#); insta::assert_snapshot!( render(r#"separate(" ", id.short(5), current_operation, user, - time.start(), time.end(), time.duration()) ++ "\n""#), @r###" - @ b5141 true test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 2001-02-03 04:05:07.000 +07:00 less than a microsecond - ○ 9a7d8 false test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 2001-02-03 04:05:07.000 +07:00 less than a microsecond + time.start(), time.end(), time.duration()) ++ "\n""#), @r#" + @ eac75 true test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 2001-02-03 04:05:07.000 +07:00 less than a microsecond ○ 00000 false @ 1970-01-01 00:00:00.000 +00:00 1970-01-01 00:00:00.000 +00:00 less than a microsecond - "###); + "#); // Negative length shouldn't cause panic. - insta::assert_snapshot!(render(r#"id.short(-1) ++ "|""#), @r###" + insta::assert_snapshot!(render(r#"id.short(-1) ++ "|""#), @r#" @ | ○ | - ○ | - "###); + "#); // Test the default template, i.e. with relative start time and duration. We // don't generally use that template because it depends on the current time, @@ -286,13 +261,11 @@ fn test_op_log_template() { ); let regex = Regex::new(r"\d\d years").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); - insta::assert_snapshot!(regex.replace_all(&stdout, "NN years"), @r###" - @ b51416386f26 test-username@host.example.com NN years ago, lasted less than a microsecond + insta::assert_snapshot!(regex.replace_all(&stdout, "NN years"), @r#" + @ eac759b9ab75 test-username@host.example.com NN years ago, lasted less than a microsecond │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com NN years ago, lasted less than a microsecond - │ initialize repo ○ 000000000000 root() - "###); + "#); } #[test] @@ -307,33 +280,28 @@ fn test_op_log_builtin_templates() { }; test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "description 0"]); - insta::assert_snapshot!(render(r#"builtin_op_log_compact"#), @r###" - c1851f1c3d90 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + insta::assert_snapshot!(render(r#"builtin_op_log_compact"#), @r#" + d009cfc04993 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 args: jj describe -m 'description 0' - b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' - 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - initialize repo 000000000000 root() [EOF] - "###); + "#); - insta::assert_snapshot!(render(r#"builtin_op_log_comfortable"#), @r###" - c1851f1c3d90 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + insta::assert_snapshot!(render(r#"builtin_op_log_comfortable"#), @r#" + d009cfc04993 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 args: jj describe -m 'description 0' - b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' - 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - initialize repo - 000000000000 root() [EOF] - "###); + "#); } #[test] @@ -360,38 +328,31 @@ fn test_op_log_word_wrap() { // ui.log-word-wrap option works insta::assert_snapshot!(render(&["op", "log"], 40, false), @r#" - @ cf25045e0079 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + @ b7cd3d0069f6 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ snapshot working copy │ args: jj debug snapshot - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() "#); insta::assert_snapshot!(render(&["op", "log"], 40, true), @r#" - @ cf25045e0079 + @ b7cd3d0069f6 │ test-username@host.example.com │ 2001-02-03 04:05:08.000 +07:00 - │ 2001-02-03 04:05:08.000 +07:00 │ snapshot working copy │ args: jj debug snapshot - ○ b51416386f26 + ○ eac759b9ab75 │ test-username@host.example.com │ 2001-02-03 04:05:07.000 +07:00 - │ 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af - │ test-username@host.example.com - │ 2001-02-03 04:05:07.000 +07:00 - - │ 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() "#); // Nested graph should be wrapped insta::assert_snapshot!(render(&["op", "log", "--op-diff"], 40, true), @r#" - @ cf25045e0079 + @ b7cd3d0069f6 │ test-username@host.example.com │ 2001-02-03 04:05:08.000 +07:00 - │ 2001-02-03 04:05:08.000 +07:00 @@ -404,7 +365,7 @@ fn test_op_log_word_wrap() { │ description set) │ - qpvuntsm hidden 230dd059 (empty) │ (no description set) - ○ b51416386f26 + ○ eac759b9ab75 │ test-username@host.example.com │ 2001-02-03 04:05:07.000 +07:00 - │ 2001-02-03 04:05:07.000 +07:00 @@ -414,22 +375,12 @@ fn test_op_log_word_wrap() { │ ○ Change qpvuntsmwlqt │ + qpvuntsm 230dd059 (empty) (no │ description set) - ○ 9a7d829846af - │ test-username@host.example.com - │ 2001-02-03 04:05:07.000 +07:00 - - │ 2001-02-03 04:05:07.000 +07:00 - │ initialize repo - │ - │ Changed commits: - │ ○ Change zzzzzzzzzzzz - │ + zzzzzzzz 00000000 (empty) (no - │ description set) ○ 000000000000 root() "#); // Nested diff stat shouldn't exceed the terminal width insta::assert_snapshot!(render(&["op", "log", "-n1", "--stat"], 40, true), @r#" - @ cf25045e0079 + @ b7cd3d0069f6 │ test-username@host.example.com │ 2001-02-03 04:05:08.000 +07:00 - │ 2001-02-03 04:05:08.000 +07:00 @@ -446,7 +397,7 @@ fn test_op_log_word_wrap() { │ 1 file changed, 100 insertions(+), 0 deletions(-) "#); insta::assert_snapshot!(render(&["op", "log", "-n1", "--no-graph", "--stat"], 40, true), @r#" - cf25045e0079 + b7cd3d0069f6 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 @@ -509,25 +460,23 @@ fn test_op_abandon_ancestors() { test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "commit 1"]); test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "commit 2"]); - insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r###" - @ c2878c428b1c test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 + insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "log"]), @r#" + @ 116edde65ded test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 │ commit 81a4ef3dd421f3184289df1c58bd3a16ea1e3d8e │ args: jj commit -m 'commit 2' - ○ 5d0ab09ab0fa test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + ○ bee8c02a64bf test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 │ args: jj commit -m 'commit 1' - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); // Abandon old operations. The working-copy operation id should be updated. let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "abandon", "..@-"]); - insta::assert_snapshot!(stderr, @r###" - Abandoned 3 operations and reparented 1 descendant operations. - "###); + insta::assert_snapshot!(stderr, @r#" + Abandoned 2 operations and reparented 1 descendant operations. + "#); insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["debug", "local-working-copy", "--ignore-working-copy"]), @r###" Current operation: OperationId("8545e013752445fd845c84eb961dbfbce47e1deb628e4ef20df10f6dc9aae2ef9e47200b0fcc70ca51f050aede05d0fa6dd1db40e20ae740876775738a07d02e") @@ -623,36 +572,36 @@ fn test_op_abandon_without_updating_working_copy() { Abandoned 1 operations and reparented 1 descendant operations. "###); insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["debug", "local-working-copy", "--ignore-working-copy"]), @r###" - Current operation: OperationId("cd2b4690faf20cdc477e90c224f15a1f4d62b4d16d0d515fc0f9c998ff91a971cb114d82075c9a7331f3f94d7188c1f93628b7b93e4ca77ac89435a7b536de1e") + test_env.jj_cmd_success(&repo_path, &["debug", "local-working-copy", "--ignore-working-copy"]), @r#" + Current operation: OperationId("b0711a8ac91f5ac088cff9b57c9daf29dc61b1b4fedcbb9a07fe4c7f7da1e60e333c787eacf73d1e0544db048a4fe9c6c089991b4a67e25365c4f411fa8b489f") Current tree: Merge(Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))) - "###); + "#); insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["op", "log", "-n1", "--ignore-working-copy"]), @r###" - @ 467d42715f00 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + test_env.jj_cmd_success(&repo_path, &["op", "log", "-n1", "--ignore-working-copy"]), @r#" + @ 0508a30825ed test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ commit 220cb0b1b5d1c03cc0d351139d824598bb3c1967 │ args: jj commit -m 'commit 3' - "###); + "#); // The working-copy operation id isn't updated if it differs from the repo. // It could be updated if the tree matches, but there's no extra logic for // that. let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "abandon", "@-"]); - insta::assert_snapshot!(stderr, @r###" + insta::assert_snapshot!(stderr, @r#" Abandoned 1 operations and reparented 1 descendant operations. - Warning: The working copy operation cd2b4690faf2 is not updated because it differs from the repo 467d42715f00. - "###); + Warning: The working copy operation b0711a8ac91f is not updated because it differs from the repo 0508a30825ed. + "#); insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["debug", "local-working-copy", "--ignore-working-copy"]), @r###" - Current operation: OperationId("cd2b4690faf20cdc477e90c224f15a1f4d62b4d16d0d515fc0f9c998ff91a971cb114d82075c9a7331f3f94d7188c1f93628b7b93e4ca77ac89435a7b536de1e") + test_env.jj_cmd_success(&repo_path, &["debug", "local-working-copy", "--ignore-working-copy"]), @r#" + Current operation: OperationId("b0711a8ac91f5ac088cff9b57c9daf29dc61b1b4fedcbb9a07fe4c7f7da1e60e333c787eacf73d1e0544db048a4fe9c6c089991b4a67e25365c4f411fa8b489f") Current tree: Merge(Resolved(TreeId("4b825dc642cb6eb9a060e54bf8d69288fbee4904"))) - "###); + "#); insta::assert_snapshot!( - test_env.jj_cmd_success(&repo_path, &["op", "log", "-n1", "--ignore-working-copy"]), @r###" - @ 050b33d674ff test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + test_env.jj_cmd_success(&repo_path, &["op", "log", "-n1", "--ignore-working-copy"]), @r#" + @ 2631d5576876 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ commit 220cb0b1b5d1c03cc0d351139d824598bb3c1967 │ args: jj commit -m 'commit 3' - "###); + "#); } #[test] @@ -670,33 +619,33 @@ fn test_op_abandon_multiple_heads() { &["op", "log", "--no-graph", r#"-Tid.short() ++ "\n""#], ); let (head_op_id, prev_op_id) = stdout.lines().next_tuple().unwrap(); - insta::assert_snapshot!(head_op_id, @"cd2b4690faf2"); - insta::assert_snapshot!(prev_op_id, @"c2878c428b1c"); + insta::assert_snapshot!(head_op_id, @"b0711a8ac91f"); + insta::assert_snapshot!(prev_op_id, @"116edde65ded"); // Create 1 other concurrent operation. test_env.jj_cmd_ok(&repo_path, &["commit", "--at-op=@--", "-m", "commit 4"]); // Can't resolve operation relative to @. let stderr = test_env.jj_cmd_failure(&repo_path, &["op", "abandon", "@-"]); - insta::assert_snapshot!(stderr, @r###" + insta::assert_snapshot!(stderr, @r#" Error: The "@" expression resolved to more than one operation - Hint: Try specifying one of the operations by ID: cd2b4690faf2, 603773cdd351 - "###); + Hint: Try specifying one of the operations by ID: b0711a8ac91f, 617923db9f7a + "#); let (_, other_head_op_id) = stderr.trim_end().rsplit_once(", ").unwrap(); - insta::assert_snapshot!(other_head_op_id, @"603773cdd351"); + insta::assert_snapshot!(other_head_op_id, @"617923db9f7a"); assert_ne!(head_op_id, other_head_op_id); // Can't abandon one of the head operations. let stderr = test_env.jj_cmd_failure(&repo_path, &["op", "abandon", head_op_id]); - insta::assert_snapshot!(stderr, @r###" - Error: Cannot abandon the current operation cd2b4690faf2 - "###); + insta::assert_snapshot!(stderr, @r#" + Error: Cannot abandon the current operation b0711a8ac91f + "#); // Can't abandon the other head operation. let stderr = test_env.jj_cmd_failure(&repo_path, &["op", "abandon", other_head_op_id]); - insta::assert_snapshot!(stderr, @r###" - Error: Cannot abandon the current operation 603773cdd351 - "###); + insta::assert_snapshot!(stderr, @r#" + Error: Cannot abandon the current operation 617923db9f7a + "#); // Can abandon the operation which is not an ancestor of the other head. // This would crash if we attempted to remap the unchanged op in the op @@ -707,25 +656,23 @@ fn test_op_abandon_multiple_heads() { "###); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "log"]); - insta::assert_snapshot!(stdout, @r###" - @ fb7f33a29cd8 test-username@host.example.com 2001-02-03 04:05:17.000 +07:00 - 2001-02-03 04:05:17.000 +07:00 + insta::assert_snapshot!(stdout, @r#" + @ 7e65e7e27e34 test-username@host.example.com 2001-02-03 04:05:17.000 +07:00 - 2001-02-03 04:05:17.000 +07:00 ├─╮ reconcile divergent operations │ │ args: jj op log - ○ │ 467d42715f00 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + ○ │ 0508a30825ed test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ │ commit 220cb0b1b5d1c03cc0d351139d824598bb3c1967 │ │ args: jj commit -m 'commit 3' - │ ○ 603773cdd351 test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 + │ ○ 617923db9f7a test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 ├─╯ commit 81a4ef3dd421f3184289df1c58bd3a16ea1e3d8e │ args: jj commit '--at-op=@--' -m 'commit 4' - ○ 5d0ab09ab0fa test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + ○ bee8c02a64bf test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 │ args: jj commit -m 'commit 1' - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); insta::assert_snapshot!(stderr, @r###" Concurrent modification detected, resolving automatically. "###); @@ -754,8 +701,8 @@ fn test_op_recover_from_bad_gc() { &["op", "log", "--no-graph", r#"-Tid.short() ++ "\n""#], ); let (head_op_id, _, _, bad_op_id) = stdout.lines().next_tuple().unwrap(); - insta::assert_snapshot!(head_op_id, @"43d51d9b0c0c"); - insta::assert_snapshot!(bad_op_id, @"e02cba71e65d"); + insta::assert_snapshot!(head_op_id, @"f999e12a5d8b"); + insta::assert_snapshot!(bad_op_id, @"e7377e6a642b"); // Corrupt the repo by removing hidden but reachable commit object. let bad_commit_id = test_env.jj_cmd_success( @@ -778,47 +725,45 @@ fn test_op_recover_from_bad_gc() { let stderr = test_env.jj_cmd_internal_error(&repo_path, &["--at-op", head_op_id, "debug", "reindex"]); - insta::assert_snapshot!(strip_last_line(&stderr), @r###" - Internal error: Failed to index commits at operation e02cba71e65dc9b58bb46e4a31500d94c31ce217f19459883fc85c2d1cfde7124f556565be4f8a3bcd059fe1faee317c3e3eacd3034d419083fd6b85aea396f4 + insta::assert_snapshot!(strip_last_line(&stderr), @r#" + Internal error: Failed to index commits at operation e7377e6a642bae88039615ee159117d49688719e9d5ece9de8b0b42d7be7076904d2fa8381391f8289a0c3527405de81e8dd6504655311c69175c3681786dd3c Caused by: 1: Object ddf84fc5e0dd314092b3dfb13e09e37fa7d04ef9 of type commit not found - "###); + "#); // "op log" should still be usable. let (stdout, stderr) = test_env.jj_cmd_ok( &repo_path, &["op", "log", "--ignore-working-copy", "--at-op", head_op_id], ); - insta::assert_snapshot!(stdout, @r###" - @ 43d51d9b0c0c test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 + insta::assert_snapshot!(stdout, @r#" + @ f999e12a5d8b test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 │ describe commit 37bb762e5dc08073ec4323bdffc023a0f0cc901e │ args: jj describe -m4 - ○ 13035304f7d6 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 + ○ fb75e6b1c70a test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 │ new empty commit │ args: jj new -m3 - ○ fcf34f8ae8ac test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + ○ 44d11f83204d test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ abandon commit ddf84fc5e0dd314092b3dfb13e09e37fa7d04ef9 │ args: jj abandon - ○ e02cba71e65d test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 + ○ e7377e6a642b test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 │ describe commit 8b64ddff700dc214dec05d915e85ac692233e6e3 │ args: jj describe -m2 - ○ 0d7016e495d7 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + ○ 319610522e90 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 │ args: jj describe -m1 - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); insta::assert_snapshot!(stderr, @""); // "op abandon" should work. let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "abandon", &format!("..{bad_op_id}")]); - insta::assert_snapshot!(stderr, @r###" - Abandoned 4 operations and reparented 4 descendant operations. - "###); + insta::assert_snapshot!(stderr, @r#" + Abandoned 3 operations and reparented 4 descendant operations. + "#); // The repo should no longer be corrupt. let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["log"]); @@ -846,19 +791,17 @@ fn test_op_diff() { // Overview of op log. let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); - insta::assert_snapshot!(&stdout, @r###" - @ ea112f6a02be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + @ 4d05b146ac44 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ check out git remote's default branch │ args: jj git clone git-repo repo - ○ cba9d7096849 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ 85a54acdbc88 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ fetch from git remote into empty repo │ args: jj git clone git-repo repo - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); // Diff between the same operation should be empty. let stdout = test_env.jj_cmd_success( @@ -871,8 +814,8 @@ fn test_op_diff() { "#); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff", "--from", "@", "--to", "@"]); insta::assert_snapshot!(&stdout, @r#" - From operation ea112f6a02be 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch - To operation ea112f6a02be 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch + From operation 4d05b146ac44 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch + To operation 4d05b146ac44 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch "#); // Diff from parent operation to latest operation. @@ -880,8 +823,8 @@ fn test_op_diff() { // @- --to @` (if `@` is not a merge commit). let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff", "--from", "@-", "--to", "@"]); insta::assert_snapshot!(&stdout, @r#" - From operation cba9d7096849 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 fetch from git remote into empty repo - To operation ea112f6a02be 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch + From operation 85a54acdbc88 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 fetch from git remote into empty repo + To operation 4d05b146ac44 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch Changed commits: ○ Change sqpuoqvxutmz @@ -906,19 +849,17 @@ fn test_op_diff() { let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff", "--from", "0000000"]); insta::assert_snapshot!(&stdout, @r#" From operation 000000000000 root() - To operation ea112f6a02be 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch + To operation 4d05b146ac44 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch Changed commits: ○ Change sqpuoqvxutmz │ + sqpuoqvx 9708515f (empty) (no description set) ○ Change ulyvmwyzwuwt - │ + ulyvmwyz 1d843d1f bookmark-1 | Commit 1 - │ ○ Change tqyxmsztkvot - ├─╯ + tqyxmszt 3e785984 bookmark-3@origin | Commit 3 - │ ○ Change yuvsmzqkmpws - ├─╯ + yuvsmzqk 3d9189bc bookmark-2@origin | Commit 2 - ○ Change zzzzzzzzzzzz - + zzzzzzzz 00000000 (empty) (no description set) + + ulyvmwyz 1d843d1f bookmark-1 | Commit 1 + ○ Change tqyxmsztkvot + + tqyxmszt 3e785984 bookmark-3@origin | Commit 3 + ○ Change yuvsmzqkmpws + + yuvsmzqk 3d9189bc bookmark-2@origin | Commit 2 Changed local bookmarks: bookmark-1: @@ -940,20 +881,18 @@ fn test_op_diff() { // Diff from latest operation to root operation let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff", "--to", "0000000"]); insta::assert_snapshot!(&stdout, @r#" - From operation ea112f6a02be 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch + From operation 4d05b146ac44 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch To operation 000000000000 root() Changed commits: ○ Change sqpuoqvxutmz │ - sqpuoqvx hidden 9708515f (empty) (no description set) ○ Change ulyvmwyzwuwt - │ - ulyvmwyz hidden 1d843d1f Commit 1 - │ ○ Change tqyxmsztkvot - ├─╯ - tqyxmszt hidden 3e785984 Commit 3 - │ ○ Change yuvsmzqkmpws - ├─╯ - yuvsmzqk hidden 3d9189bc Commit 2 - ○ Change zzzzzzzzzzzz - - zzzzzzzz hidden 00000000 (empty) (no description set) + - ulyvmwyz hidden 1d843d1f Commit 1 + ○ Change tqyxmsztkvot + - tqyxmszt hidden 3e785984 Commit 3 + ○ Change yuvsmzqkmpws + - yuvsmzqk hidden 3d9189bc Commit 2 Changed local bookmarks: bookmark-1: @@ -990,25 +929,23 @@ fn test_op_diff() { Concurrent modification detected, resolving automatically. "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); - insta::assert_snapshot!(&stdout, @r###" - @ f534dfc3151b test-username@host.example.com 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + @ cd3fc3ddbdd9 test-username@host.example.com 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 ├─╮ reconcile divergent operations │ │ args: jj log - ○ │ ea112f6a02be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ │ 4d05b146ac44 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ │ check out git remote's default branch │ │ args: jj git clone git-repo repo - │ ○ 9ded7e2755e1 test-username@host.example.com 2001-02-03 04:05:15.000 +07:00 - 2001-02-03 04:05:15.000 +07:00 + │ ○ 484785c371e5 test-username@host.example.com 2001-02-03 04:05:15.000 +07:00 - 2001-02-03 04:05:15.000 +07:00 ├─╯ point bookmark bookmark-1 to commit 3d9189bc56a1972729350456eb95ec5bf90be2a8 │ args: jj bookmark set bookmark-1 -r bookmark-2@origin --at-op @- - ○ cba9d7096849 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ 85a54acdbc88 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ fetch from git remote into empty repo │ args: jj git clone git-repo repo - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); let op_log_lines = stdout.lines().collect_vec(); let op_id = op_log_lines[0].split(' ').nth(4).unwrap(); let first_parent_id = op_log_lines[3].split(' ').nth(3).unwrap(); @@ -1020,8 +957,8 @@ fn test_op_diff() { &["op", "diff", "--from", first_parent_id, "--to", op_id], ); insta::assert_snapshot!(&stdout, @r#" - From operation ea112f6a02be 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch - To operation f534dfc3151b 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 reconcile divergent operations + From operation 4d05b146ac44 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch + To operation cd3fc3ddbdd9 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 reconcile divergent operations Changed local bookmarks: bookmark-1: @@ -1037,8 +974,8 @@ fn test_op_diff() { &["op", "diff", "--from", second_parent_id, "--to", op_id], ); insta::assert_snapshot!(&stdout, @r#" - From operation 9ded7e2755e1 2001-02-03 04:05:15.000 +07:00 - 2001-02-03 04:05:15.000 +07:00 point bookmark bookmark-1 to commit 3d9189bc56a1972729350456eb95ec5bf90be2a8 - To operation f534dfc3151b 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 reconcile divergent operations + From operation 484785c371e5 2001-02-03 04:05:15.000 +07:00 - 2001-02-03 04:05:15.000 +07:00 point bookmark bookmark-1 to commit 3d9189bc56a1972729350456eb95ec5bf90be2a8 + To operation cd3fc3ddbdd9 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 reconcile divergent operations Changed commits: ○ Change sqpuoqvxutmz @@ -1071,8 +1008,8 @@ fn test_op_diff() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff"]); insta::assert_snapshot!(&stdout, @r#" - From operation f534dfc3151b 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 reconcile divergent operations - To operation 8a21e297a587 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 fetch from git remote(s) origin + From operation cd3fc3ddbdd9 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 reconcile divergent operations + To operation 894f1f54aabe 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 fetch from git remote(s) origin Changed commits: ○ Change qzxslznxxpoz @@ -1119,8 +1056,8 @@ fn test_op_diff() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff"]); insta::assert_snapshot!(&stdout, @r#" - From operation 8a21e297a587 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 fetch from git remote(s) origin - To operation ef314062f7f5 2001-02-03 04:05:22.000 +07:00 - 2001-02-03 04:05:22.000 +07:00 create bookmark bookmark-2 pointing to commit d487febd08e690ee775a4e0387e30d544307e409 + From operation 894f1f54aabe 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 fetch from git remote(s) origin + To operation ed134e3dc5c6 2001-02-03 04:05:22.000 +07:00 - 2001-02-03 04:05:22.000 +07:00 create bookmark bookmark-2 pointing to commit d487febd08e690ee775a4e0387e30d544307e409 Changed local bookmarks: bookmark-2: @@ -1138,8 +1075,8 @@ fn test_op_diff() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff"]); insta::assert_snapshot!(&stdout, @r#" - From operation ef314062f7f5 2001-02-03 04:05:22.000 +07:00 - 2001-02-03 04:05:22.000 +07:00 create bookmark bookmark-2 pointing to commit d487febd08e690ee775a4e0387e30d544307e409 - To operation bc306c9bb67f 2001-02-03 04:05:24.000 +07:00 - 2001-02-03 04:05:24.000 +07:00 track remote bookmark bookmark-2@origin + From operation ed134e3dc5c6 2001-02-03 04:05:22.000 +07:00 - 2001-02-03 04:05:22.000 +07:00 create bookmark bookmark-2 pointing to commit d487febd08e690ee775a4e0387e30d544307e409 + To operation 871bda1a359f 2001-02-03 04:05:24.000 +07:00 - 2001-02-03 04:05:24.000 +07:00 track remote bookmark bookmark-2@origin Changed remote bookmarks: bookmark-2@origin: @@ -1159,8 +1096,8 @@ fn test_op_diff() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff"]); insta::assert_snapshot!(&stdout, @r#" - From operation ef314062f7f5 2001-02-03 04:05:22.000 +07:00 - 2001-02-03 04:05:22.000 +07:00 create bookmark bookmark-2 pointing to commit d487febd08e690ee775a4e0387e30d544307e409 - To operation bc306c9bb67f 2001-02-03 04:05:24.000 +07:00 - 2001-02-03 04:05:24.000 +07:00 track remote bookmark bookmark-2@origin + From operation ed134e3dc5c6 2001-02-03 04:05:22.000 +07:00 - 2001-02-03 04:05:22.000 +07:00 create bookmark bookmark-2 pointing to commit d487febd08e690ee775a4e0387e30d544307e409 + To operation 871bda1a359f 2001-02-03 04:05:24.000 +07:00 - 2001-02-03 04:05:24.000 +07:00 track remote bookmark bookmark-2@origin Changed remote bookmarks: bookmark-2@origin: @@ -1182,8 +1119,8 @@ fn test_op_diff() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff"]); insta::assert_snapshot!(&stdout, @r#" - From operation bc306c9bb67f 2001-02-03 04:05:24.000 +07:00 - 2001-02-03 04:05:24.000 +07:00 track remote bookmark bookmark-2@origin - To operation 1ae777a7acc8 2001-02-03 04:05:28.000 +07:00 - 2001-02-03 04:05:28.000 +07:00 new empty commit + From operation 871bda1a359f 2001-02-03 04:05:24.000 +07:00 - 2001-02-03 04:05:24.000 +07:00 track remote bookmark bookmark-2@origin + To operation 2604b8b3b9e5 2001-02-03 04:05:28.000 +07:00 - 2001-02-03 04:05:28.000 +07:00 new empty commit Changed commits: ○ Change wvuyspvkupzz @@ -1202,8 +1139,8 @@ fn test_op_diff() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff"]); insta::assert_snapshot!(&stdout, @r#" - From operation 1ae777a7acc8 2001-02-03 04:05:28.000 +07:00 - 2001-02-03 04:05:28.000 +07:00 new empty commit - To operation 5728693d7de3 2001-02-03 04:05:30.000 +07:00 - 2001-02-03 04:05:30.000 +07:00 point bookmark bookmark-1 to commit 358b82d6be53fa9b062325abb8bc820a8b34c68d + From operation 2604b8b3b9e5 2001-02-03 04:05:28.000 +07:00 - 2001-02-03 04:05:28.000 +07:00 new empty commit + To operation e64617a51cdb 2001-02-03 04:05:30.000 +07:00 - 2001-02-03 04:05:30.000 +07:00 point bookmark bookmark-1 to commit 358b82d6be53fa9b062325abb8bc820a8b34c68d Changed local bookmarks: bookmark-1: @@ -1221,8 +1158,8 @@ fn test_op_diff() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff"]); insta::assert_snapshot!(&stdout, @r#" - From operation 5728693d7de3 2001-02-03 04:05:30.000 +07:00 - 2001-02-03 04:05:30.000 +07:00 point bookmark bookmark-1 to commit 358b82d6be53fa9b062325abb8bc820a8b34c68d - To operation 0f77d601f1cd 2001-02-03 04:05:32.000 +07:00 - 2001-02-03 04:05:32.000 +07:00 delete bookmark bookmark-2 + From operation e64617a51cdb 2001-02-03 04:05:30.000 +07:00 - 2001-02-03 04:05:30.000 +07:00 point bookmark bookmark-1 to commit 358b82d6be53fa9b062325abb8bc820a8b34c68d + To operation e07e94fbdd09 2001-02-03 04:05:32.000 +07:00 - 2001-02-03 04:05:32.000 +07:00 delete bookmark bookmark-2 Changed local bookmarks: bookmark-2: @@ -1244,8 +1181,8 @@ fn test_op_diff() { "#); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff"]); insta::assert_snapshot!(&stdout, @r#" - From operation 0f77d601f1cd 2001-02-03 04:05:32.000 +07:00 - 2001-02-03 04:05:32.000 +07:00 delete bookmark bookmark-2 - To operation 65409e59d36a 2001-02-03 04:05:34.000 +07:00 - 2001-02-03 04:05:34.000 +07:00 push all tracked bookmarks to git remote origin + From operation e07e94fbdd09 2001-02-03 04:05:32.000 +07:00 - 2001-02-03 04:05:32.000 +07:00 delete bookmark bookmark-2 + To operation 203fe2a7ed9e 2001-02-03 04:05:34.000 +07:00 - 2001-02-03 04:05:34.000 +07:00 push all tracked bookmarks to git remote origin Changed commits: ○ Change oupztwtkortx @@ -1277,8 +1214,8 @@ fn test_op_diff_patch() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff", "--op", "@-", "-p", "--git"]); insta::assert_snapshot!(&stdout, @r#" - From operation b51416386f26 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' - To operation 6188e9d1f7da 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy + From operation eac759b9ab75 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' + To operation 187a5a9d8a22 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy Changed commits: ○ Change qpvuntsmwlqt @@ -1294,8 +1231,8 @@ fn test_op_diff_patch() { "#); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff", "--op", "@", "-p", "--git"]); insta::assert_snapshot!(&stdout, @r#" - From operation 6188e9d1f7da 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy - To operation 8f6a879bef11 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 new empty commit + From operation 187a5a9d8a22 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy + To operation a7e535e73c4b 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 new empty commit Changed commits: ○ Change rlvkpnrzqnoo @@ -1312,8 +1249,8 @@ fn test_op_diff_patch() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff", "-p", "--git"]); insta::assert_snapshot!(&stdout, @r#" - From operation 874d3a8b4c77 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 snapshot working copy - To operation c53f5f1afbc6 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 squash commits into 6b1027d2770cd0a39c468e525e52bf8c47e1464a + From operation 15c3c5d0baf0 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 snapshot working copy + To operation 894c12d90345 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 squash commits into 6b1027d2770cd0a39c468e525e52bf8c47e1464a Changed commits: ○ Change mzvwutvlkqwt @@ -1349,8 +1286,8 @@ fn test_op_diff_patch() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "diff", "-p", "--git"]); insta::assert_snapshot!(&stdout, @r#" - From operation c53f5f1afbc6 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 squash commits into 6b1027d2770cd0a39c468e525e52bf8c47e1464a - To operation e13dc1c7a3b3 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 abandon commit 9f4fb57fba25a7b47ce5980a5d9a4766778331e8 + From operation 894c12d90345 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 squash commits into 6b1027d2770cd0a39c468e525e52bf8c47e1464a + To operation e5505aa79d31 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 abandon commit 9f4fb57fba25a7b47ce5980a5d9a4766778331e8 Changed commits: ○ Change yqosqzytrlsw @@ -1371,7 +1308,7 @@ fn test_op_diff_sibling() { &["op", "log", "--no-graph", r#"-Tid.short() ++ "\n""#], ); let base_op_id = stdout.lines().next().unwrap(); - insta::assert_snapshot!(base_op_id, @"b51416386f26"); + insta::assert_snapshot!(base_op_id, @"eac759b9ab75"); // Create merge commit at one operation side. The parent trees will have to // be merged when diffing, which requires the commit index of this side. @@ -1385,34 +1322,32 @@ fn test_op_diff_sibling() { test_env.jj_cmd_ok(&repo_path, &["describe", "--at-op", base_op_id, "-mB"]); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "log"]); - insta::assert_snapshot!(&stdout, @r###" - @ 2629707e5305 test-username@host.example.com 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + @ 779ecb7ea7f0 test-username@host.example.com 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 ├─╮ reconcile divergent operations │ │ args: jj op log - ○ │ b8584dcdb220 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 + ○ │ d700dc16fded test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 │ │ new empty commit │ │ args: jj new 'all:@-+' -mA - ○ │ f0bb05eb2e7e test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 + ○ │ b47de32023e1 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 │ │ snapshot working copy │ │ args: jj new 'all:@-+' -mA - ○ │ ee4ec332e269 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + ○ │ 8a31868f615d test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ │ new empty commit │ │ args: jj new 'root()' -mA.2 - ○ │ 971683f333fa test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + ○ │ 2cd33ddecde8 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ │ snapshot working copy │ │ args: jj new 'root()' -mA.2 - ○ │ 3df45c2cdcb4 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 + ○ │ d86c1ae55c48 test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 │ │ new empty commit │ │ args: jj new 'root()' -mA.1 - │ ○ 654f3215449e test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 + │ ○ 13b143e1f4f9 test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 ├─╯ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 - │ args: jj describe --at-op b51416386f26 -mB - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + │ args: jj describe --at-op eac759b9ab75 -mB + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); insta::assert_snapshot!(&stderr, @r###" Concurrent modification detected, resolving automatically. "###); @@ -1421,9 +1356,9 @@ fn test_op_diff_sibling() { &["op", "log", "--no-graph", r#"-Tid.short() ++ "\n""#], ); let (head_op_id, p1_op_id, _, _, _, _, p2_op_id) = stdout.lines().next_tuple().unwrap(); - insta::assert_snapshot!(head_op_id, @"2629707e5305"); - insta::assert_snapshot!(p1_op_id, @"b8584dcdb220"); - insta::assert_snapshot!(p2_op_id, @"654f3215449e"); + insta::assert_snapshot!(head_op_id, @"779ecb7ea7f0"); + insta::assert_snapshot!(p1_op_id, @"d700dc16fded"); + insta::assert_snapshot!(p2_op_id, @"13b143e1f4f9"); // Diff between p1 and p2 operations should work no matter if p2 is chosen // as a base operation. @@ -1442,8 +1377,8 @@ fn test_op_diff_sibling() { ], ); insta::assert_snapshot!(&stdout, @r#" - From operation b8584dcdb220 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 new empty commit - To operation 654f3215449e 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 + From operation d700dc16fded 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 new empty commit + To operation 13b143e1f4f9 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 Changed commits: ○ Change qpvuntsmwlqt @@ -1472,8 +1407,8 @@ fn test_op_diff_sibling() { ], ); insta::assert_snapshot!(&stdout, @r#" - From operation 654f3215449e 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 - To operation b8584dcdb220 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 new empty commit + From operation 13b143e1f4f9 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 + To operation d700dc16fded 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 new empty commit Changed commits: ○ Change mzvwutvlkqwt @@ -1516,8 +1451,8 @@ fn test_op_diff_word_wrap() { // ui.log-word-wrap option works, and diff stat respects content width insta::assert_snapshot!(render(&["op", "diff", "--from=@---", "--stat"], 40, true), @r#" - From operation b51416386f26 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' - To operation d12081b11443 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy + From operation eac759b9ab75 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' + To operation f3052392e08c 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy Changed commits: ○ Change sqpuoqvxutmz @@ -1570,8 +1505,8 @@ fn test_op_diff_word_wrap() { let config = r#"templates.commit_summary='"0 1 2 3 4 5 6 7 8 9"'"#; insta::assert_snapshot!( render(&["op", "diff", "--from=@---", "--config-toml", config], 10, true), @r#" - From operation b51416386f26 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' - To operation d12081b11443 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy + From operation eac759b9ab75 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 add workspace 'default' + To operation f3052392e08c 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy Changed commits: @@ -1649,19 +1584,17 @@ fn test_op_show() { // Overview of op log. let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); - insta::assert_snapshot!(&stdout, @r###" - @ ea112f6a02be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + @ 4d05b146ac44 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ check out git remote's default branch │ args: jj git clone git-repo repo - ○ cba9d7096849 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ 85a54acdbc88 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ fetch from git remote into empty repo │ args: jj git clone git-repo repo - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); // The root operation is empty. let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show", "0000000"]); @@ -1671,8 +1604,8 @@ fn test_op_show() { // Showing the latest operation. let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show", "@"]); - insta::assert_snapshot!(&stdout, @r###" - ea112f6a02be test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + 4d05b146ac44 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 check out git remote's default branch args: jj git clone git-repo repo @@ -1691,15 +1624,15 @@ fn test_op_show() { bookmark-1@origin: + tracked ulyvmwyz 1d843d1f bookmark-1 | Commit 1 - untracked ulyvmwyz 1d843d1f bookmark-1 | Commit 1 - "###); + "#); // `jj op show @` should behave identically to `jj op show`. let stdout_without_op_id = test_env.jj_cmd_success(&repo_path, &["op", "show"]); assert_eq!(stdout, stdout_without_op_id); // Showing a given operation. let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show", "@-"]); - insta::assert_snapshot!(&stdout, @r###" - cba9d7096849 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + 85a54acdbc88 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 fetch from git remote into empty repo args: jj git clone git-repo repo @@ -1721,7 +1654,7 @@ fn test_op_show() { bookmark-3@origin: + untracked tqyxmszt 3e785984 bookmark-3@origin | Commit 3 - untracked (absent) - "###); + "#); // Create a conflicted bookmark using a concurrent operation. test_env.jj_cmd_ok( @@ -1742,11 +1675,11 @@ fn test_op_show() { "###); // Showing a merge operation is empty. let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - 5d52ce7672bb test-username@host.example.com 2001-02-03 04:05:14.000 +07:00 - 2001-02-03 04:05:14.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + 140254f5a707 test-username@host.example.com 2001-02-03 04:05:14.000 +07:00 - 2001-02-03 04:05:14.000 +07:00 reconcile divergent operations args: jj log - "###); + "#); // Test fetching from git remote. modify_git_repo(git_repo); @@ -1760,8 +1693,8 @@ fn test_op_show() { Abandoned 1 commits that are no longer reachable. "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - 5eed0f5f5fbc test-username@host.example.com 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + 4d5647c16e09 test-username@host.example.com 2001-02-03 04:05:16.000 +07:00 - 2001-02-03 04:05:16.000 +07:00 fetch from git remote(s) origin args: jj git fetch @@ -1790,7 +1723,7 @@ fn test_op_show() { bookmark-3@origin: + untracked (absent) - untracked tqyxmszt hidden 3e785984 Commit 3 - "###); + "#); // Test creation of bookmark. let (stdout, stderr) = test_env.jj_cmd_ok( @@ -1809,8 +1742,8 @@ fn test_op_show() { Created 1 bookmarks pointing to qzxslznx d487febd bookmark-2 bookmark-2@origin | Commit 5 "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - 25b687bb01b6 test-username@host.example.com 2001-02-03 04:05:18.000 +07:00 - 2001-02-03 04:05:18.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + c23f32312992 test-username@host.example.com 2001-02-03 04:05:18.000 +07:00 - 2001-02-03 04:05:18.000 +07:00 create bookmark bookmark-2 pointing to commit d487febd08e690ee775a4e0387e30d544307e409 args: jj bookmark create bookmark-2 -r bookmark-2@origin @@ -1818,7 +1751,7 @@ fn test_op_show() { bookmark-2: + qzxslznx d487febd bookmark-2 bookmark-2@origin | Commit 5 - (absent) - "###); + "#); // Test tracking of a bookmark. let (stdout, stderr) = @@ -1829,8 +1762,8 @@ fn test_op_show() { Started tracking 1 remote bookmarks. "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - 48cf434c463d test-username@host.example.com 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + eb6a6c523f67 test-username@host.example.com 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 track remote bookmark bookmark-2@origin args: jj bookmark track bookmark-2@origin @@ -1838,7 +1771,7 @@ fn test_op_show() { bookmark-2@origin: + tracked qzxslznx d487febd bookmark-2 | Commit 5 - untracked qzxslznx d487febd bookmark-2 | Commit 5 - "###); + "#); // Test creation of new commit. let (stdout, stderr) = @@ -1850,8 +1783,8 @@ fn test_op_show() { Nothing changed. "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - 48cf434c463d test-username@host.example.com 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + eb6a6c523f67 test-username@host.example.com 2001-02-03 04:05:20.000 +07:00 - 2001-02-03 04:05:20.000 +07:00 track remote bookmark bookmark-2@origin args: jj bookmark track bookmark-2@origin @@ -1859,7 +1792,7 @@ fn test_op_show() { bookmark-2@origin: + tracked qzxslznx d487febd bookmark-2 | Commit 5 - untracked qzxslznx d487febd bookmark-2 | Commit 5 - "###); + "#); // Test creation of new commit. let (stdout, stderr) = test_env.jj_cmd_ok( @@ -1874,8 +1807,8 @@ fn test_op_show() { Added 1 files, modified 0 files, removed 1 files "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - 89aa6cca51fc test-username@host.example.com 2001-02-03 04:05:24.000 +07:00 - 2001-02-03 04:05:24.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + 0228d6c4044a test-username@host.example.com 2001-02-03 04:05:24.000 +07:00 - 2001-02-03 04:05:24.000 +07:00 new empty commit args: jj new bookmark-1@origin -m 'new commit' @@ -1884,7 +1817,7 @@ fn test_op_show() { + xznxytkn eb6c2b21 (empty) new commit ○ Change sqpuoqvxutmz - sqpuoqvx hidden 9708515f (empty) (no description set) - "###); + "#); // Test updating of local bookmark. let (stdout, stderr) = @@ -1895,8 +1828,8 @@ fn test_op_show() { Moved 1 bookmarks to xznxytkn eb6c2b21 bookmark-1* | (empty) new commit "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - 6d6bf9b35d8a test-username@host.example.com 2001-02-03 04:05:26.000 +07:00 - 2001-02-03 04:05:26.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + f37c3d23beab test-username@host.example.com 2001-02-03 04:05:26.000 +07:00 - 2001-02-03 04:05:26.000 +07:00 point bookmark bookmark-1 to commit eb6c2b21ec20a33ab6a1c44bc86c59d84ffd93ac args: jj bookmark set bookmark-1 -r @ @@ -1905,7 +1838,7 @@ fn test_op_show() { + xznxytkn eb6c2b21 bookmark-1* | (empty) new commit - (added) slvtnnzx 4f856199 bookmark-1@origin | Commit 4 - (added) yuvsmzqk 3d9189bc Commit 2 - "###); + "#); // Test deletion of local bookmark. let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "delete", "bookmark-2"]); @@ -1915,8 +1848,8 @@ fn test_op_show() { Deleted 1 bookmarks. "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - a50c95a6b180 test-username@host.example.com 2001-02-03 04:05:28.000 +07:00 - 2001-02-03 04:05:28.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + ee9e64b76138 test-username@host.example.com 2001-02-03 04:05:28.000 +07:00 - 2001-02-03 04:05:28.000 +07:00 delete bookmark bookmark-2 args: jj bookmark delete bookmark-2 @@ -1924,7 +1857,7 @@ fn test_op_show() { bookmark-2: + (absent) - qzxslznx d487febd bookmark-2@origin | Commit 5 - "###); + "#); // Test pushing to Git remote. let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "push", "--tracked"]); @@ -1939,8 +1872,8 @@ fn test_op_show() { Parent commit : xznxytkn eb6c2b21 bookmark-1 | (empty) new commit "#); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show"]); - insta::assert_snapshot!(&stdout, @r###" - 5d994bb7d230 test-username@host.example.com 2001-02-03 04:05:30.000 +07:00 - 2001-02-03 04:05:30.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + cd1704964f59 test-username@host.example.com 2001-02-03 04:05:30.000 +07:00 - 2001-02-03 04:05:30.000 +07:00 push all tracked bookmarks to git remote origin args: jj git push --tracked @@ -1955,7 +1888,7 @@ fn test_op_show() { bookmark-2@origin: + untracked (absent) - tracked qzxslznx d487febd Commit 5 - "###); + "#); } #[test] @@ -1973,8 +1906,8 @@ fn test_op_show_patch() { Parent commit : qpvuntsm 6b1027d2 (no description set) "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show", "@-", "-p", "--git"]); - insta::assert_snapshot!(&stdout, @r###" - 6188e9d1f7da test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + 187a5a9d8a22 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 snapshot working copy args: jj new @@ -1989,17 +1922,17 @@ fn test_op_show_patch() { +++ b/file @@ -1,0 +1,1 @@ +a - "###); + "#); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show", "@", "-p", "--git"]); - insta::assert_snapshot!(&stdout, @r###" - 8f6a879bef11 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + a7e535e73c4b test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 new empty commit args: jj new Changed commits: ○ Change rlvkpnrzqnoo + rlvkpnrz 56950632 (empty) (no description set) - "###); + "#); // Squash the working copy commit. std::fs::write(repo_path.join("file"), "b\n").unwrap(); @@ -2010,8 +1943,8 @@ fn test_op_show_patch() { Parent commit : qpvuntsm 2ac85fd1 (no description set) "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show", "-p", "--git"]); - insta::assert_snapshot!(&stdout, @r###" - c53f5f1afbc6 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + 894c12d90345 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 squash commits into 6b1027d2770cd0a39c468e525e52bf8c47e1464a args: jj squash @@ -2037,7 +1970,7 @@ fn test_op_show_patch() { @@ -1,1 +1,1 @@ -a +b - "###); + "#); // Abandon the working copy commit. let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["abandon"]); @@ -2048,8 +1981,8 @@ fn test_op_show_patch() { Parent commit : qpvuntsm 2ac85fd1 (no description set) "###); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "show", "-p", "--git"]); - insta::assert_snapshot!(&stdout, @r###" - e13dc1c7a3b3 test-username@host.example.com 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 + insta::assert_snapshot!(&stdout, @r#" + e5505aa79d31 test-username@host.example.com 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 abandon commit 9f4fb57fba25a7b47ce5980a5d9a4766778331e8 args: jj abandon @@ -2058,12 +1991,12 @@ fn test_op_show_patch() { + yqosqzyt 33f321c4 (empty) (no description set) ○ Change mzvwutvlkqwt - mzvwutvl hidden 9f4fb57f (empty) (no description set) - "###); + "#); // Try again with "op log". let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log", "--git"]); insta::assert_snapshot!(&stdout, @r#" - @ e13dc1c7a3b3 test-username@host.example.com 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 + @ e5505aa79d31 test-username@host.example.com 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 │ abandon commit 9f4fb57fba25a7b47ce5980a5d9a4766778331e8 │ args: jj abandon │ @@ -2072,7 +2005,7 @@ fn test_op_show_patch() { │ + yqosqzyt 33f321c4 (empty) (no description set) │ ○ Change mzvwutvlkqwt │ - mzvwutvl hidden 9f4fb57f (empty) (no description set) - ○ c53f5f1afbc6 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 + ○ 894c12d90345 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 │ squash commits into 6b1027d2770cd0a39c468e525e52bf8c47e1464a │ args: jj squash │ @@ -2098,7 +2031,7 @@ fn test_op_show_patch() { │ @@ -1,1 +1,1 @@ │ -a │ +b - ○ 874d3a8b4c77 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 + ○ 15c3c5d0baf0 test-username@host.example.com 2001-02-03 04:05:11.000 +07:00 - 2001-02-03 04:05:11.000 +07:00 │ snapshot working copy │ args: jj squash │ @@ -2113,14 +2046,14 @@ fn test_op_show_patch() { │ @@ -1,1 +1,1 @@ │ -a │ +b - ○ 8f6a879bef11 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + ○ a7e535e73c4b test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ new empty commit │ args: jj new │ │ Changed commits: │ ○ Change rlvkpnrzqnoo │ + rlvkpnrz 56950632 (empty) (no description set) - ○ 6188e9d1f7da test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + ○ 187a5a9d8a22 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ snapshot working copy │ args: jj new │ @@ -2135,18 +2068,12 @@ fn test_op_show_patch() { │ +++ b/file │ @@ -1,0 +1,1 @@ │ +a - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' │ │ Changed commits: │ ○ Change qpvuntsmwlqt │ + qpvuntsm 230dd059 (empty) (no description set) - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo - │ - │ Changed commits: - │ ○ Change zzzzzzzzzzzz - │ + zzzzzzzz 00000000 (empty) (no description set) ○ 000000000000 root() "#); } diff --git a/cli/tests/test_rebase_command.rs b/cli/tests/test_rebase_command.rs index 2da8e7775..01c3f6df7 100644 --- a/cli/tests/test_rebase_command.rs +++ b/cli/tests/test_rebase_command.rs @@ -681,7 +681,7 @@ fn test_rebase_revision_onto_descendant() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "restore", &setup_opid]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r#" - Restored to operation 0957966a18b4 2001-02-03 04:05:15.000 +07:00 - 2001-02-03 04:05:15.000 +07:00 create bookmark merge pointing to commit b05964d109522cd06e48f1a2661e1a0f58be0984 + Restored to operation cc1a7e3419ad 2001-02-03 04:05:15.000 +07:00 - 2001-02-03 04:05:15.000 +07:00 create bookmark merge pointing to commit b05964d109522cd06e48f1a2661e1a0f58be0984 Working copy now at: vruxwmqv b05964d1 merge | merge Parent commit : royxmykx cea87a87 b | b Parent commit : zsuskuln 2c5b7858 a | a diff --git a/cli/tests/test_util_command.rs b/cli/tests/test_util_command.rs index dc3f3563c..bd019b2f2 100644 --- a/cli/tests/test_util_command.rs +++ b/cli/tests/test_util_command.rs @@ -90,9 +90,9 @@ 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 "54c5f04ab3dbb32ac86f805c819cb1ef78a3c9758ee560680a465e843fa0b05f42706d0641805905ef4bab550ca805effd1ba73d1980f6cdcc42126f008e51f4" - "###); + insta::assert_snapshot!(stderr, @r#" + Error: No operation ID matching "8382f401329617b0c91a63354b86ca48fc28dee8d7a916fdad5310030f9a1260e969c43ed2b13d1d48eaf38f6f45541ecf593bcb6105495d514d21b3b6a98846" + "#); } #[test] diff --git a/cli/tests/test_workspaces.rs b/cli/tests/test_workspaces.rs index 3c6cfe337..db6f07e51 100644 --- a/cli/tests/test_workspaces.rs +++ b/cli/tests/test_workspaces.rs @@ -224,7 +224,7 @@ fn test_workspaces_add_at_operation() { "###); let stdout = test_env.jj_cmd_success(&secondary_path, &["op", "log", "-Tdescription"]); - insta::assert_snapshot!(stdout, @r###" + insta::assert_snapshot!(stdout, @r#" @ snapshot working copy ○ reconcile divergent operations ├─╮ @@ -236,9 +236,8 @@ fn test_workspaces_add_at_operation() { ○ commit 1c867a0762e30de4591890ea208849f793742c1b ○ snapshot working copy ○ add workspace 'default' - ○ initialize repo ○ - "###); + "#); } /// Test adding a workspace, but at a specific revision using '-r' @@ -500,18 +499,18 @@ fn test_workspaces_conflicting_edits() { ◆ 000000000000 "###); let stderr = test_env.jj_cmd_failure(&secondary_path, &["st"]); - insta::assert_snapshot!(stderr, @r###" - Error: The working copy is stale (not updated since operation 0da24da631e3). + insta::assert_snapshot!(stderr, @r##" + Error: The working copy is stale (not updated since operation c81af45155a2). Hint: Run `jj workspace update-stale` to update it. See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy for more information. - "###); + "##); // Same error on second run, and from another command let stderr = test_env.jj_cmd_failure(&secondary_path, &["log"]); - insta::assert_snapshot!(stderr, @r###" - Error: The working copy is stale (not updated since operation 0da24da631e3). + insta::assert_snapshot!(stderr, @r##" + Error: The working copy is stale (not updated since operation c81af45155a2). Hint: Run `jj workspace update-stale` to update it. See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy for more information. - "###); + "##); let (stdout, stderr) = test_env.jj_cmd_ok(&secondary_path, &["workspace", "update-stale"]); // It was detected that the working copy is now stale. // Since there was an uncommitted change in the working copy, it should @@ -587,11 +586,11 @@ fn test_workspaces_updated_by_other() { ◆ 000000000000 "###); let stderr = test_env.jj_cmd_failure(&secondary_path, &["st"]); - insta::assert_snapshot!(stderr, @r###" - Error: The working copy is stale (not updated since operation 0da24da631e3). + insta::assert_snapshot!(stderr, @r##" + Error: The working copy is stale (not updated since operation c81af45155a2). Hint: Run `jj workspace update-stale` to update it. See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy for more information. - "###); + "##); let (stdout, stderr) = test_env.jj_cmd_ok(&secondary_path, &["workspace", "update-stale"]); // It was detected that the working copy is now stale, but clean. So no // divergent commit should be created. @@ -658,18 +657,17 @@ fn test_workspaces_current_op_discarded_by_other() { r#"id.short(10) ++ " " ++ description"#, ], ); - insta::assert_snapshot!(stdout, @r###" - @ 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 + insta::assert_snapshot!(stdout, @r#" + @ 757bc1140b abandon commit 20dd439c4bd12c6ad56c187ac490bd0141804618f638dc5c4dc92ff9aecba20f152b23160db9dcf61beb31a5cb14091d9def5a36d11c9599cc4d2e5689236af1 + ○ 8d4abed655 create initial working-copy commit in workspace secondary + ○ 3de27432e5 add workspace 'secondary' + ○ bcf69de808 new empty commit + ○ a36b99a15c snapshot working copy + ○ ddf023d319 new empty commit + ○ 829c93f6a3 snapshot working copy + ○ 2557266dd2 add workspace 'default' ○ 0000000000 - "###); + "#); // Abandon ops, including the one the secondary workspace is currently on. test_env.jj_cmd_ok(&main_path, &["operation", "abandon", "..@-"]); @@ -691,10 +689,10 @@ 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 f4bd4d046b3cdf61b0fda7738a0b1414c0aedc6c8229d39a35ee26facc358cad8b588b04d7eba1302a82409c529f69dbb1ff9ea28789d935b74f123f377aa30b of type operation not found + insta::assert_snapshot!(stderr, @r#" + Failed to read working copy's current operation; attempting recovery. Error message from read attempt: Object 8d4abed655badb70b1bab62aa87136619dbc3c8015a8ce8dfb7abfeca4e2f36c713d8f84e070a0613907a6cee7e1cc05323fe1205a319b93fe978f11a060c33c 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###" @@ -761,11 +759,10 @@ fn test_workspaces_update_stale_noop() { "###); let stdout = test_env.jj_cmd_success(&main_path, &["op", "log", "-Tdescription"]); - insta::assert_snapshot!(stdout, @r###" + insta::assert_snapshot!(stdout, @r#" @ add workspace 'default' - ○ initialize repo ○ - "###); + "#); } /// Test "update-stale" in a dirty, but not stale working copy. @@ -895,11 +892,11 @@ fn test_workspaces_forget_multi_transaction() { // the op log should have multiple workspaces forgotten in a single tx let stdout = test_env.jj_cmd_success(&main_path, &["op", "log", "--limit", "1"]); - insta::assert_snapshot!(stdout, @r###" - @ b7ab9f1c16cc test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 + insta::assert_snapshot!(stdout, @r#" + @ 60b2b5a71a84 test-username@host.example.com 2001-02-03 04:05:12.000 +07:00 - 2001-02-03 04:05:12.000 +07:00 │ forget workspaces second, third │ args: jj workspace forget second third - "###); + "#); // now, undo, and that should restore both workspaces test_env.jj_cmd_ok(&main_path, &["op", "undo"]); @@ -1051,31 +1048,27 @@ fn test_debug_snapshot() { std::fs::write(repo_path.join("file"), "contents").unwrap(); test_env.jj_cmd_ok(&repo_path, &["debug", "snapshot"]); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); - insta::assert_snapshot!(stdout, @r###" - @ e1e762d39b39 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + insta::assert_snapshot!(stdout, @r#" + @ c55ebc67e3db test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ snapshot working copy │ args: jj debug snapshot - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); - insta::assert_snapshot!(stdout, @r###" - @ 9ac6e7144e8a test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + insta::assert_snapshot!(stdout, @r#" + @ c9a40b951848 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ describe commit 4e8f9d2be039994f589b4e57ac5e9488703e604d │ args: jj describe -m initial - ○ e1e762d39b39 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + ○ c55ebc67e3db test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ snapshot working copy │ args: jj debug snapshot - ○ b51416386f26 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + ○ eac759b9ab75 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 │ add workspace 'default' - ○ 9a7d829846af test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 - │ initialize repo ○ 000000000000 root() - "###); + "#); } #[test] diff --git a/lib/src/op_store.rs b/lib/src/op_store.rs index 23eaf7fbf..0c64e07e0 100644 --- a/lib/src/op_store.rs +++ b/lib/src/op_store.rs @@ -264,7 +264,7 @@ pub struct BookmarkTarget<'a> { /// Represents the way the repo looks at a given time, just like how a Tree /// object represents how the file system looks at a given time. -#[derive(ContentHash, PartialEq, Eq, Clone, Debug, Default)] +#[derive(ContentHash, PartialEq, Eq, Clone, Debug)] pub struct View { /// All head commits pub head_ids: HashSet, @@ -282,6 +282,37 @@ pub struct View { pub wc_commit_ids: HashMap, } +impl View { + /// Creates new truly empty view. + /// + /// The caller should add at least one commit ID to `head_ids`. The other + /// fields may be empty. + pub fn empty() -> Self { + View { + head_ids: HashSet::new(), + local_bookmarks: BTreeMap::new(), + tags: BTreeMap::new(), + remote_views: BTreeMap::new(), + git_refs: BTreeMap::new(), + git_head: RefTarget::absent(), + wc_commit_ids: HashMap::new(), + } + } + + /// Creates new (mostly empty) view containing the given commit as the head. + pub fn make_root(root_commit_id: CommitId) -> Self { + View { + head_ids: HashSet::from([root_commit_id]), + local_bookmarks: BTreeMap::new(), + tags: BTreeMap::new(), + remote_views: BTreeMap::new(), + git_refs: BTreeMap::new(), + git_head: RefTarget::absent(), + wc_commit_ids: HashMap::new(), + } + } +} + /// Represents the state of the remote repo. #[derive(ContentHash, Clone, Debug, Default, Eq, PartialEq)] pub struct RemoteView { @@ -368,7 +399,7 @@ pub struct Operation { } impl Operation { - pub fn make_root(empty_view_id: ViewId) -> Operation { + pub fn make_root(root_view_id: ViewId) -> Operation { let timestamp = Timestamp { timestamp: MillisSinceEpoch(0), tz_offset: 0, @@ -383,7 +414,7 @@ impl Operation { tags: HashMap::new(), }; Operation { - view_id: empty_view_id, + view_id: root_view_id, parents: vec![], metadata, } diff --git a/lib/src/repo.rs b/lib/src/repo.rs index d61550577..d4293756c 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -233,24 +233,20 @@ impl ReadonlyRepo { let root_operation = loader.root_operation(); let root_view = root_operation.view().expect("failed to read root view"); + assert!(!root_view.heads().is_empty()); let index = loader .index_store .get_index_at_op(&root_operation, &loader.store) // If the root op index couldn't be read, the index backend wouldn't // be initialized properly. .map_err(|err| BackendInitError(err.into()))?; - let repo = Arc::new(ReadonlyRepo { + Ok(Arc::new(ReadonlyRepo { loader, operation: root_operation, index, change_id_index: OnceCell::new(), view: root_view, - }); - let mut tx = repo.start_transaction(user_settings); - tx.repo_mut() - .add_head(&repo.store().root_commit()) - .expect("failed to add root commit as head"); - Ok(tx.commit("initialize repo")) + })) } pub fn loader(&self) -> &RepoLoader { diff --git a/lib/src/simple_op_store.rs b/lib/src/simple_op_store.rs index 13835511c..a1ecbde94 100644 --- a/lib/src/simple_op_store.rs +++ b/lib/src/simple_op_store.rs @@ -82,8 +82,9 @@ impl From for OpStoreError { #[derive(Debug)] pub struct SimpleOpStore { path: PathBuf, - empty_view_id: ViewId, + root_data: RootOperationData, root_operation_id: OperationId, + root_view_id: ViewId, } impl SimpleOpStore { @@ -99,11 +100,12 @@ impl SimpleOpStore { } /// Load an existing OpStore - pub fn load(store_path: &Path, _root_data: RootOperationData) -> Self { + pub fn load(store_path: &Path, root_data: RootOperationData) -> Self { SimpleOpStore { path: store_path.to_path_buf(), - empty_view_id: ViewId::from_bytes(&[0; VIEW_ID_LENGTH]), + root_data, root_operation_id: OperationId::from_bytes(&[0; OPERATION_ID_LENGTH]), + root_view_id: ViewId::from_bytes(&[0; VIEW_ID_LENGTH]), } } @@ -130,8 +132,8 @@ impl OpStore for SimpleOpStore { } fn read_view(&self, id: &ViewId) -> OpStoreResult { - if *id == self.empty_view_id { - return Ok(View::default()); + if *id == self.root_view_id { + return Ok(View::make_root(self.root_data.root_commit_id.clone())); } let path = self.view_path(id); @@ -164,7 +166,7 @@ impl OpStore for SimpleOpStore { fn read_operation(&self, id: &OperationId) -> OpStoreResult { if *id == self.root_operation_id { - return Ok(Operation::make_root(self.empty_view_id.clone())); + return Ok(Operation::make_root(self.root_view_id.clone())); } let path = self.operation_path(id); @@ -460,7 +462,7 @@ fn view_to_proto(view: &View) -> crate::protos::op_store::View { } fn view_from_proto(proto: crate::protos::op_store::View) -> View { - let mut view = View::default(); + let mut view = View::empty(); // For compatibility with old repos before we had support for multiple working // copies #[allow(deprecated)] diff --git a/lib/tests/test_commit_concurrent.rs b/lib/tests/test_commit_concurrent.rs index 6537eaebf..540bd0174 100644 --- a/lib/tests/test_commit_concurrent.rs +++ b/lib/tests/test_commit_concurrent.rs @@ -69,9 +69,9 @@ fn test_commit_parallel(backend: TestRepoBackend) { // the root commit assert_eq!(repo.view().heads().len(), num_threads + 1); - // One additional operation for the root commit, one for initializing the repo, - // one for checking out the initial commit. - assert_eq!(count_non_merge_operations(&repo), num_threads + 3); + // One additional operation for the root operation, one for checking out the + // initial commit. + assert_eq!(count_non_merge_operations(&repo), num_threads + 2); } #[test_case(TestRepoBackend::Local ; "local backend")] @@ -99,7 +99,7 @@ fn test_commit_parallel_instances(backend: TestRepoBackend) { let repo = load_repo_at_head(&settings, test_workspace.repo_path()); assert_eq!(repo.view().heads().len(), num_threads + 1); - // One additional operation for the root commit, one for initializing the repo, - // one for checking out the initial commit. - assert_eq!(count_non_merge_operations(&repo), num_threads + 3); + // One additional operation for the root operation, one for checking out the + // initial commit. + assert_eq!(count_non_merge_operations(&repo), num_threads + 2); } diff --git a/lib/tests/test_operations.rs b/lib/tests/test_operations.rs index 1ba2fb736..e6d47c3e4 100644 --- a/lib/tests/test_operations.rs +++ b/lib/tests/test_operations.rs @@ -422,23 +422,22 @@ fn test_resolve_op_id() { let mut operations = Vec::new(); // The actual value of `i` doesn't matter, we just need to make sure we end // up with hashes with ambiguous prefixes. - for i in (1..7).chain([16]) { + for i in (1..5).chain([39, 62]) { let tx = repo.start_transaction(&settings); let repo = tx.commit(format!("transaction {i}")); operations.push(repo.operation().clone()); } - // "2" and "0" are ambiguous - insta::assert_debug_snapshot!(operations.iter().map(|op| op.id().hex()).collect_vec(), @r###" + // "b" and "0" are ambiguous + insta::assert_debug_snapshot!(operations.iter().map(|op| op.id().hex()).collect_vec(), @r#" [ - "5aebb24d08d6f5282d9e06bded4b51febbb4ff4bc822cdd4db9043961339955d6af912e783c3864245867d0cf6d609cb004c5ff0cef5e914c15a415ba92e38a2", - "ad1cda629b220f2651d972475fba75e47c30cd57862c51a727e57b7b6e2fbaa937d0bcb881cf6fcff30ba1a088a4ad588cf880765b9d9680b551cdc446f3489e", - "2feaf9eb61232582d35f1cb0203b69425f7a7d07140a5f8ff0d0bf98dd9f433b941e4c9e0882f65a007266affee275e235ae1614b159ceadbf9fe6879077a5da", - "0b183be5767c3ff9945c8a9e3ac7639d249ff9873985a551f4c2070782aea8b5018ebff906036d1658038708ab9de0d867be385b1181aa7a81669e2ef6852355", - "d1c3031dff7b1db4db1bfb592a9aa0ea6faae9300033ef20cb6da488e4b90524c22af8e2541cdb99ca0ee2be3299c213c0f8d48390cd5f11462c4f80c5790f68", - "2369ba98e2596715606978a72608970287aaa064ec890f87c29b7e7df64fdf02b7f24b8b03ee845e132f3e19e3929de359b6cfe1328b42946c45ac5ff80705ca", - "00271842a189d274a2c97ac28f937584a47b84463d5b408c6f998089131e0e1329a287667b2ac5d63f8c576e95323bcf992c99caa4ef4612a1c3798fe8a3f74f", + "bb1ea76bb194556214b1259568d5f3381fb4209f10b86d6c3c7d162a9b8ee1a5d98da57cf21ceadeecd2416c20508348ed4c1a24226c708f035b138fc7a97d5b", + "5c35c6506eedd9c74ffab46940129cb3b66e5e1968b4eea5bb38701d6d3462b4a34d78efcaa81d41fabf6937d79c4431e2adc4361095c9fb795004da420d8a26", + "b43387cf7a5808ebb6cdacd5c95de9d4b315c6edc465a49ff290b731da1c3d57315af49686e5ffd4c2fc4478af40b4a70cba7334bbca8e3d4e69176de807a916", + "fcd828a3033f9a9f44c8f06cd0d7f79570d53895c9d7d794ea51a7ee4b7871c8fe245ec18d2ece76ec7b51a998b04da811c232668c7c2c53f72b5baf0ad20797", + "091574d16d89ab848ac08c9a8e35276484c5e332ea97f1fad7b794763aa280ce5b663d835b555b5b763cbdbb6d8dba5a35ad1f2780ebdca5e598f07f82dcd3c7", + "06e9f38473578a4b1a8672ab474eb2741269fffb2f765a610de47fddafc60a88c002f7cdb9d82a9d1dfdbdd3b4045cd62e34215e7a781ed149332980e90227f1", ] - "###); + "#); let repo_loader = repo.loader(); let resolve = |op_str: &str| op_walk::resolve_op_for_load(repo_loader, op_str); @@ -457,7 +456,7 @@ fn test_resolve_op_id() { ); // Ambiguous id assert_matches!( - resolve("2"), + resolve("b"), Err(OpsetEvaluationError::OpsetResolution( OpsetResolutionError::AmbiguousIdPrefix(_) )) @@ -479,8 +478,8 @@ fn test_resolve_op_id() { // Virtual root id let root_operation = loader.root_operation(); assert_eq!(resolve(&root_operation.id().hex()).unwrap(), root_operation); - assert_eq!(resolve("000").unwrap(), root_operation); - assert_eq!(resolve("002").unwrap(), operations[6]); + assert_eq!(resolve("00").unwrap(), root_operation); + assert_eq!(resolve("09").unwrap(), operations[4]); assert_matches!( resolve("0"), Err(OpsetEvaluationError::OpsetResolution( @@ -607,7 +606,7 @@ fn test_gc() { // |/ // B // A - // 0 (initial) + // 0 (root) let empty_tx = |repo: &Arc| repo.start_transaction(&settings); let random_tx = |repo: &Arc| { let mut tx = repo.start_transaction(&settings); @@ -624,8 +623,8 @@ fn test_gc() { // Sanity check for the original state let mut expected_op_entries = list_dir(&op_dir); let mut expected_view_entries = list_dir(&view_dir); - assert_eq!(expected_op_entries.len(), 7); - assert_eq!(expected_view_entries.len(), 6); + assert_eq!(expected_op_entries.len(), 6); + assert_eq!(expected_view_entries.len(), 5); // No heads, but all kept by file modification time op_store.gc(&[], SystemTime::UNIX_EPOCH).unwrap(); @@ -663,6 +662,6 @@ fn test_gc() { assert_eq!(list_dir(&view_dir), expected_view_entries); // Sanity check for the last state - assert_eq!(expected_op_entries.len(), 2); - assert_eq!(expected_view_entries.len(), 2); + assert_eq!(expected_op_entries.len(), 1); + assert_eq!(expected_view_entries.len(), 1); } diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index 54f6ea768..6ec652150 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -957,12 +957,10 @@ fn test_evaluate_expression_root_and_checkout() { vec![root_commit.id().clone()] ); - // but not in the root operation. It might be okay to pretend that the root - // commit exists in the root operation, but queries like "root()" shouldn't - // panic in any case. - assert_matches!( - resolve_symbol(root_repo.as_ref(), "root()"), - Err(RevsetResolutionError::NoSuchRevision { .. }) + // Can find the root commit in the root view + assert_eq!( + resolve_commit_ids(root_repo.as_ref(), "root()"), + vec![root_commit.id().clone()] ); // Can find the current working-copy commit