diff --git a/cli/src/commands/operation/restore.rs b/cli/src/commands/operation/restore.rs index 289b482a73..f0e71644df 100644 --- a/cli/src/commands/operation/restore.rs +++ b/cli/src/commands/operation/restore.rs @@ -55,6 +55,12 @@ pub fn cmd_op_restore( &args.what, ); tx.repo_mut().set_view(new_view); + if let Some(mut formatter) = ui.status_formatter() { + write!(formatter, "Restored to operation ")?; + let template = tx.base_workspace_helper().operation_summary_template(); + template.format(&target_op, formatter.as_mut())?; + writeln!(formatter)?; + } tx.finish(ui, format!("restore to operation {}", target_op.id().hex()))?; Ok(()) diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index e9bd59aa2d..b099809937 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -1017,7 +1017,9 @@ fn test_fetch_undo_what() { &["op", "restore", "--what", "repo", &base_operation_id], ); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @""); + 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' + "#); insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###" b (deleted) @origin: vpupmnsl hidden c7d4bdcb descr_for_b @@ -1044,7 +1046,9 @@ fn test_fetch_undo_what() { ], ); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @""); + 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' + "#); 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 c92c41cd56..dff6b11363 100644 --- a/cli/tests/test_git_import_export.rs +++ b/cli/tests/test_git_import_export.rs @@ -161,7 +161,9 @@ fn test_git_import_undo() { // "git import" can be undone by default. let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "restore", &base_operation_id]); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @""); + 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' + "#); insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @""); // Try "git import" again, which should re-import the bookmark "a". let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "import"]); @@ -225,10 +227,11 @@ fn test_git_import_move_export_with_default_undo() { // repo stay where they were. let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "restore", &base_operation_id]); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @r###" + 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' Working copy now at: qpvuntsm 230dd059 (empty) (no description set) Parent commit : zzzzzzzz 00000000 (empty) (no description set) - "###); + "#); insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @""); insta::assert_debug_snapshot!(get_git_repo_refs(&git_repo), @r###" [ diff --git a/cli/tests/test_rebase_command.rs b/cli/tests/test_rebase_command.rs index 0a8809ffc1..2da8e77757 100644 --- a/cli/tests/test_rebase_command.rs +++ b/cli/tests/test_rebase_command.rs @@ -680,12 +680,13 @@ fn test_rebase_revision_onto_descendant() { // Now, let's rebase onto the descendant merge let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "restore", &setup_opid]); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @r###" + 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 Working copy now at: vruxwmqv b05964d1 merge | merge Parent commit : royxmykx cea87a87 b | b Parent commit : zsuskuln 2c5b7858 a | a Added 1 files, modified 0 files, removed 0 files - "###); + "#); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-r", "base", "-d", "merge"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###"