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

Function run_change_insert

atomic-cli/src/commands/insert.rs:601–647  ·  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

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