MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / run_change_insert

Function run_change_insert

atomic-cli/src/commands/insert.rs:614–660  ·  view source on GitHub ↗

Insert specific change(s) by hash (the `insert change` subcommand).

(
    repo: &Repository,
    working_copy: WorkingCopyId,
    workspace_view: &str,
    args: &ChangeArgs,
)

Source from the content-addressed store, hash-verified

612
613/// Insert specific change(s) by hash (the `insert change` subcommand).
614fn run_change_insert(
615 repo: &Repository,
616 working_copy: WorkingCopyId,
617 workspace_view: &str,
618 args: &ChangeArgs,
619) -> CliResult<()> {
620 let to_view = args
621 .to_view
622 .clone()
623 .unwrap_or_else(|| workspace_view.to_string());
624 let is_current_view = to_view == workspace_view;
625
626 // Parse all change hashes
627 let mut hashes = Vec::new();
628 for change_str in &args.changes {
629 let hash = parse_change_hash(repo, change_str)?;
630 hashes.push(hash);
631 }
632
633 output::print_info(&format!(
634 "Cherry-picking {} change(s) to '{}'...",
635 hashes.len(),
636 to_view
637 ));
638
639 let outcome =
640 repo.cherry_pick(&hashes, "", Some(&to_view))
641 .map_err(|e| CliError::Conflict {
642 description: e.to_string(),
643 })?;
644
645 print_cross_view_outcome(&outcome, false);
646
647 // Update working copy if we inserted into its desired view.
648 if is_current_view && outcome.changes_applied > 0 {
649 let output_result = repo.materialize(working_copy).map_err(|e| {
650 CliError::Internal(anyhow::anyhow!("Failed to update working copy: {}", e))
651 })?;
652 output::print_success(&format!(
653 "{} files updated, {} directories",
654 output_result.files_written, output_result.directories_created
655 ));
656 print_conflict_summary(repo, working_copy);
657 }
658
659 Ok(())
660}
661
662/// Preview what would be inserted.
663fn run_preview(repo: &Repository, workspace_view: &str, args: &PreviewArgs) -> CliResult<()> {

Callers 1

runMethod · 0.85

Calls 9

print_infoFunction · 0.85
print_cross_view_outcomeFunction · 0.85
print_successFunction · 0.85
print_conflict_summaryFunction · 0.85
cherry_pickMethod · 0.80
parse_change_hashFunction · 0.70
cloneMethod · 0.45
pushMethod · 0.45
materializeMethod · 0.45

Tested by

no test coverage detected