just playing with tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cli: when restoring to a previous operation, don't roll back git_refs

authored by

Martin von Zweigbergk and committed by
Ilya Grigoriev
637b8603 c021f399

+27 -27
+7
src/commands/operation.rs
··· 1 1 use clap::Subcommand; 2 2 use jujutsu_lib::operation; 3 + use jujutsu_lib::repo::Repo; 3 4 4 5 use crate::cli_util::{user_error, CommandError, CommandHelper, LogContentFormat}; 5 6 use crate::graphlog::{get_graphlog, Edge}; ··· 133 134 let bad_repo = repo_loader.load_at(&bad_op); 134 135 let parent_repo = repo_loader.load_at(&parent_ops[0]); 135 136 tx.mut_repo().merge(&bad_repo, &parent_repo); 137 + let mut new_view = tx.repo().view().store_view().clone(); 138 + new_view.git_refs = tx.base_repo().view().store_view().git_refs.clone(); 139 + tx.mut_repo().set_view(new_view); 136 140 tx.finish(ui)?; 137 141 138 142 Ok(()) ··· 148 152 let mut tx = workspace_command 149 153 .start_transaction(&format!("restore to operation {}", target_op.id().hex())); 150 154 tx.mut_repo().set_view(target_op.view().take_store_view()); 155 + let mut new_view = tx.repo().view().store_view().clone(); 156 + new_view.git_refs = tx.base_repo().view().store_view().git_refs.clone(); 157 + tx.mut_repo().set_view(new_view); 151 158 tx.finish(ui)?; 152 159 153 160 Ok(())
+3 -6
tests/test_git_colocated.rs
··· 371 371 ◉ zzzzzzzzzzzz 000000000000 372 372 "###); 373 373 test_env.jj_cmd_success(&repo_path, &["undo"]); 374 - // TODO: There should be no divergence here; 2f376ea1478c should be hidden 375 - // (#922) 374 + // There should be no divergence here; 2f376ea1478c should be hidden 376 375 insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###" 377 - ◉ qpvuntsmwlqt 2f376ea1478c A master !divergence! 378 - │ @ rlvkpnrzqnoo 8f71e3b6a3be 379 - │ ◉ qpvuntsmwlqt a86754f975f9 A HEAD@git !divergence! 380 - ├─╯ 376 + @ rlvkpnrzqnoo 8f71e3b6a3be 377 + ◉ qpvuntsmwlqt a86754f975f9 A master HEAD@git 381 378 ◉ zzzzzzzzzzzz 000000000000 382 379 "###); 383 380 }
+4 -5
tests/test_git_fetch.rs
··· 659 659 "###); 660 660 // Now try to fetch just one branch 661 661 let stdout = test_env.jj_cmd_success(&target_jj_repo_path, &["git", "fetch", "--branch", "b"]); 662 - insta::assert_snapshot!(stdout, @""); 662 + insta::assert_snapshot!(stdout, @r###" 663 + Nothing changed. 664 + "###); 663 665 insta::assert_snapshot!(get_log_output(&test_env, &target_jj_repo_path), @r###" 664 - ◉ c7d4bdcbc215 descr_for_b b 665 - ◉ ff36dc55760e descr_for_trunk1 666 - │ @ 230dd059e1b0 667 - ├─╯ 666 + @ 230dd059e1b0 668 667 ◉ 000000000000 669 668 "###); 670 669 }
+13 -16
tests/test_git_import_export.rs
··· 104 104 105 105 // "git export" can't be undone. 106 106 insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["op", "undo"]), @r###" 107 + Nothing changed. 107 108 "###); 108 109 insta::assert_debug_snapshot!(get_git_refs(&git_repo), @r###" 109 110 [ ··· 118 119 119 120 // This would re-export branch "a" as the internal state has been rolled back. 120 121 // It might be better to preserve the state, and say "Nothing changed" here. 121 - insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["git", "export"]), @""); 122 + insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["git", "export"]), @r###" 123 + Nothing changed. 124 + "###); 122 125 } 123 126 124 127 #[test] ··· 150 153 insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @""); 151 154 152 155 // Try "git import" again, which should re-import the branch "a". 153 - insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["git", "import"]), @""); 154 - insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" 155 - a: 230dd059e1b0 (no description set) 156 + insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["git", "import"]), @r###" 157 + Nothing changed. 156 158 "###); 159 + insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @""); 157 160 } 158 161 159 162 #[test] ··· 208 211 209 212 // The last branch "a" state is imported from git. No idea what's the most 210 213 // intuitive result here. 211 - insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["git", "import"]), @""); 212 - insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" 213 - a: 096dc80da670 (no description set) 214 + insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["git", "import"]), @r###" 215 + Nothing changed. 214 216 "###); 217 + insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @""); 215 218 } 216 219 217 220 #[test] ··· 230 233 test_env.jj_cmd_success(&repo_path, &["undo"]); 231 234 test_env.jj_cmd_success(&repo_path, &["describe", "-m", "v3"]); 232 235 test_env.jj_cmd_success(&repo_path, &["git", "fetch"]); 233 - // TODO: This should probably not be considered a conflict. It currently is 234 - // because the undo made us forget that the remote was at v2, so the fetch 235 - // made us think it updated from v1 to v2 (instead of the no-op it could 236 - // have been). 236 + // There should be no conflict 237 237 insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" 238 - main (conflicted): 239 - - 367d4f2f6deb v1 240 - + cb20e76758a0 v3 241 - + ebba8fecca7e v2 242 - @origin (behind by 1 commits): ebba8fecca7e v2 238 + main: cb20e76758a0 v3 239 + @origin (ahead by 1 commits, behind by 1 commits): 367d4f2f6deb v1 243 240 "###); 244 241 } 245 242