Insert specific change(s) by hash (the `insert change` subcommand).
(repo: &Repository, args: &ChangeArgs)
| 521 | |
| 522 | /// Insert specific change(s) by hash (the `insert change` subcommand). |
| 523 | fn run_change_insert(repo: &Repository, args: &ChangeArgs) -> CliResult<()> { |
| 524 | let to_view = args |
| 525 | .to_view |
| 526 | .clone() |
| 527 | .unwrap_or_else(|| repo.current_view().to_string()); |
| 528 | let is_current_view = to_view == repo.current_view(); |
| 529 | |
| 530 | // Parse all change hashes |
| 531 | let mut hashes = Vec::new(); |
| 532 | for change_str in &args.changes { |
| 533 | let hash = parse_change_hash(repo, change_str)?; |
| 534 | hashes.push(hash); |
| 535 | } |
| 536 | |
| 537 | output::print_info(&format!( |
| 538 | "Cherry-picking {} change(s) to '{}'...", |
| 539 | hashes.len(), |
| 540 | to_view |
| 541 | )); |
| 542 | |
| 543 | let outcome = |
| 544 | repo.cherry_pick(&hashes, "", Some(&to_view)) |
| 545 | .map_err(|e| CliError::Conflict { |
| 546 | description: e.to_string(), |
| 547 | })?; |
| 548 | |
| 549 | print_cross_view_outcome(&outcome, false); |
| 550 | |
| 551 | // Update working copy if we inserted into the current view |
| 552 | if is_current_view && outcome.changes_applied > 0 { |
| 553 | let output_result = repo.materialize().map_err(|e| { |
| 554 | CliError::Internal(anyhow::anyhow!("Failed to update working copy: {}", e)) |
| 555 | })?; |
| 556 | output::print_success(&format!( |
| 557 | "{} files updated, {} directories", |
| 558 | output_result.files_written, output_result.directories_created |
| 559 | )); |
| 560 | print_conflict_summary(repo); |
| 561 | } |
| 562 | |
| 563 | Ok(()) |
| 564 | } |
| 565 | |
| 566 | /// Preview what would be inserted. |
| 567 | fn run_preview(repo: &Repository, args: &PreviewArgs) -> CliResult<()> { |
no test coverage detected