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

Function run_change_insert

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

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

(repo: &Repository, args: &ChangeArgs)

Source from the content-addressed store, hash-verified

521
522/// Insert specific change(s) by hash (the `insert change` subcommand).
523fn 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.
567fn run_preview(repo: &Repository, args: &PreviewArgs) -> CliResult<()> {

Callers 1

runMethod · 0.85

Calls 10

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

Tested by

no test coverage detected