Skip to content

Commit

Permalink
Make jj abandon print each abandoned commit once
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Jan 18, 2023
1 parent 667c00b commit 301ac45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
8 changes: 3 additions & 5 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Commit>, CommandError> {
let mut acc = Vec::new();
) -> Result<IndexSet<Commit>, CommandError> {
let mut acc = IndexSet::new();
for revset in revision_args {
let revisions = workspace_command.resolve_revset(revset)?;
workspace_command.check_non_empty(&revisions)?;
Expand All @@ -2058,9 +2058,7 @@ fn cmd_duplicate(
) -> Result<(), CommandError> {
let mut workspace_command = command.workspace_helper(ui)?;
let to_duplicate: IndexSet<Commit> =
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<Commit, Commit> = IndexMap::new();

let mut tx = workspace_command
Expand Down
7 changes: 1 addition & 6 deletions tests/test_abandon_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 301ac45

Please sign in to comment.