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

Function run_view_insert

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

Insert all changes from another view (the `insert view` subcommand).

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

Source from the content-addressed store, hash-verified

490
491/// Insert all changes from another view (the `insert view` subcommand).
492fn run_view_insert(
493 repo: &Repository,
494 working_copy: WorkingCopyId,
495 workspace_view: &str,
496 args: &ViewArgs,
497) -> CliResult<()> {
498 let to_view = args
499 .to_view
500 .clone()
501 .unwrap_or_else(|| workspace_view.to_string());
502 let is_current_view = to_view == workspace_view;
503
504 output::print_info(&format!(
505 "Inserting changes from '{}' to '{}'...",
506 args.from_view, to_view
507 ));
508
509 let options = CrossViewInsertOptions::new(&args.from_view, &to_view)
510 .with_dependencies(args.deps)
511 .allow_conflicts(args.allow_conflicts)
512 .dry_run(args.dry_run);
513
514 let outcome = repo
515 .insert_from_view(options)
516 .map_err(|e| CliError::Conflict {
517 description: e.to_string(),
518 })?;
519
520 print_cross_view_outcome(&outcome, args.dry_run);
521
522 // Update working copy if we inserted into the current view.
523 // Collect affected file paths from the inserted changes and only
524 // materialize those, avoiding a full rematerialization of the
525 // entire working copy.
526 if is_current_view && !args.dry_run && outcome.changes_applied > 0 {
527 let spinner = output::create_spinner("Materializing files for view...");
528
529 let affected_paths = outcome.affected_paths.clone();
530
531 // An empty canonical delta has no filesystem effects.
532 let output_result = repo
533 .materialize_paths(working_copy, affected_paths)
534 .map_err(|e| {
535 CliError::Internal(anyhow::anyhow!("Failed to update working copy: {}", e))
536 })?;
537
538 output::finish_success(
539 &spinner,
540 &format!(
541 "{} files updated, {} directories",
542 output_result.files_written, output_result.directories_created
543 ),
544 );
545 print_conflict_summary(repo, working_copy);
546 }
547
548 Ok(())
549}

Callers 1

runMethod · 0.85

Calls 11

print_infoFunction · 0.85
print_cross_view_outcomeFunction · 0.85
create_spinnerFunction · 0.85
finish_successFunction · 0.85
print_conflict_summaryFunction · 0.85
allow_conflictsMethod · 0.80
insert_from_viewMethod · 0.80
cloneMethod · 0.45
dry_runMethod · 0.45
with_dependenciesMethod · 0.45
materialize_pathsMethod · 0.45

Tested by

no test coverage detected