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

Function run_change_insert

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

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

Callers 1

runMethod · 0.85

Calls 9

print_infoFunction · 0.85
print_cross_view_outcomeFunction · 0.85
print_successFunction · 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