From 3e7791bbc14a320bca88220ed898a9206fc7e97c Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Tue, 17 Jan 2023 20:06:12 -0800 Subject: [PATCH] Make `jj abandon` print each abandoned commit once --- src/commands.rs | 8 +++----- tests/test_abandon_command.rs | 7 +------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 4b9c7e8b5..2ede70e71 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -2038,8 +2038,8 @@ fn cmd_commit(ui: &mut Ui, command: &CommandHelper, args: &CommitArgs) -> Result fn resolve_multiple_rewriteable_revsets( revision_args: &[RevisionArg], workspace_command: &WorkspaceCommandHelper, -) -> Result, CommandError> { - let mut acc = Vec::new(); +) -> Result, CommandError> { + let mut acc = IndexSet::new(); for revset in revision_args { let revisions = workspace_command.resolve_revset(revset)?; workspace_command.check_non_empty(&revisions)?; @@ -2058,9 +2058,7 @@ fn cmd_duplicate( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let to_duplicate: IndexSet = - resolve_multiple_rewriteable_revsets(&args.revisions, &workspace_command)? - .into_iter() - .collect(); + resolve_multiple_rewriteable_revsets(&args.revisions, &workspace_command)?; let mut duplicated_old_to_new: IndexMap = IndexMap::new(); let mut tx = workspace_command diff --git a/tests/test_abandon_command.rs b/tests/test_abandon_command.rs index a66a567f3..44899e439 100644 --- a/tests/test_abandon_command.rs +++ b/tests/test_abandon_command.rs @@ -112,11 +112,8 @@ fn test_rebase_branch_with_merge() { // Test abandoning the same commit twice directly test_env.jj_cmd_success(&repo_path, &["undo"]); let stdout = test_env.jj_cmd_success(&repo_path, &["abandon", "b", "b"]); - // Note that the same commit is listed twice insta::assert_snapshot!(stdout, @r###" - Abandoned the following commits: - 1394f625cbbd b - 1394f625cbbd b + Abandoned commit 1394f625cbbd b "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @ e @@ -131,12 +128,10 @@ fn test_rebase_branch_with_merge() { // Test abandoning the same commit twice indirectly test_env.jj_cmd_success(&repo_path, &["undo"]); let stdout = test_env.jj_cmd_success(&repo_path, &["abandon", "d:", "a:"]); - // Note that the same commit is listed twice insta::assert_snapshot!(stdout, @r###" Abandoned the following commits: 5557ece3e631 e b7c62f28ed10 d - 5557ece3e631 e 1394f625cbbd b 2443ea76b0b1 a Working copy now at: af874bffee6e (no description set)