Cherry-pick specific changes.
(repo: &Repository, args: &PickArgs)
| 374 | |
| 375 | /// Cherry-pick specific changes. |
| 376 | fn run_pick(repo: &Repository, args: &PickArgs) -> CliResult<()> { |
| 377 | let to_view = args |
| 378 | .to_view |
| 379 | .clone() |
| 380 | .unwrap_or_else(|| repo.current_view().to_string()); |
| 381 | let is_current_view = to_view == repo.current_view(); |
| 382 | |
| 383 | // Parse all change hashes |
| 384 | let mut hashes = Vec::new(); |
| 385 | for change_str in &args.changes { |
| 386 | let hash = parse_change_hash(repo, change_str)?; |
| 387 | hashes.push(hash); |
| 388 | } |
| 389 | |
| 390 | output::print_info(&format!( |
| 391 | "Cherry-picking {} change(s) to '{}'...", |
| 392 | hashes.len(), |
| 393 | to_view |
| 394 | )); |
| 395 | |
| 396 | let outcome = |
| 397 | repo.cherry_pick(&hashes, "", Some(&to_view)) |
| 398 | .map_err(|e| CliError::Conflict { |
| 399 | description: e.to_string(), |
| 400 | })?; |
| 401 | |
| 402 | print_cross_view_outcome(&outcome, false); |
| 403 | |
| 404 | // Update working copy if we inserted into the current view |
| 405 | if is_current_view && outcome.changes_applied > 0 { |
| 406 | let output_result = repo.materialize().map_err(|e| { |
| 407 | CliError::Internal(anyhow::anyhow!("Failed to update working copy: {}", e)) |
| 408 | })?; |
| 409 | output::print_success(&format!( |
| 410 | "{} files updated, {} directories", |
| 411 | output_result.files_written, output_result.directories_created |
| 412 | )); |
| 413 | } |
| 414 | |
| 415 | Ok(()) |
| 416 | } |
| 417 | |
| 418 | /// Preview what would be inserted. |
| 419 | fn run_preview(repo: &Repository, args: &PreviewArgs) -> CliResult<()> { |
no test coverage detected