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

Method reconcile_scaffold_view

atomic-cli/src/commands/clone/command.rs:509–555  ·  view source on GitHub ↗

Remove an empty locally-created view whose identity conflicts with the manifest about to be applied. `Repository::init` pre-creates a shared root view (e.g. "dev"). If the remote's view of the same name is a draft or has a parent, `apply_view_manifest` would report an identity mismatch even though the local view is just an empty scaffold. Deleting the scaffold lets the manifest recreate the view

(
        &self,
        repo: &mut Repository,
        manifest: &ViewManifest,
    )

Source from the content-addressed store, hash-verified

507 /// Views with changes are left alone: a genuine divergence must surface
508 /// as an apply error, never a silent delete.
509 fn reconcile_scaffold_view(
510 &self,
511 repo: &mut Repository,
512 manifest: &ViewManifest,
513 ) -> CliResult<()> {
514 if !repo
515 .view_exists(&manifest.name)
516 .map_err(CliError::Repository)?
517 {
518 return Ok(());
519 }
520 let info = repo
521 .get_view_info(&manifest.name)
522 .map_err(CliError::Repository)?;
523 if info.scope == manifest.scope && info.parent_name == manifest.parent {
524 // Identity matches; apply_view_manifest handles the log.
525 return Ok(());
526 }
527 if info.change_count > 0 {
528 // Not a scaffold; let apply_view_manifest report the mismatch.
529 return Ok(());
530 }
531
532 // The scaffold may be the current view (init leaves it current),
533 // and the current view cannot be deleted — park on a temporary
534 // root view first. It is removed again before clone finishes.
535 if repo.current_view() == manifest.name {
536 if !repo
537 .view_exists(SCAFFOLD_PARK_VIEW)
538 .map_err(CliError::Repository)?
539 {
540 repo.create_shared_view(SCAFFOLD_PARK_VIEW)
541 .map_err(CliError::Repository)?;
542 }
543 repo.align_to_view(SCAFFOLD_PARK_VIEW)
544 .map_err(CliError::Repository)?;
545 }
546
547 // Shared views cannot be deleted directly; demote first.
548 if info.scope.is_shared() {
549 repo.set_view_scope(&manifest.name, ViewScope::Draft)
550 .map_err(CliError::Repository)?;
551 }
552 repo.delete_view(&manifest.name)
553 .map_err(CliError::Repository)?;
554 Ok(())
555 }
556
557 /// Remove the temporary parking view, if scaffold reconciliation
558 /// created it. Best-effort: a leftover parking view is cosmetic.

Callers 2

apply_manifestsMethod · 0.80

Calls 8

view_existsMethod · 0.80
get_view_infoMethod · 0.80
current_viewMethod · 0.80
create_shared_viewMethod · 0.80
align_to_viewMethod · 0.80
is_sharedMethod · 0.80
set_view_scopeMethod · 0.80
delete_viewMethod · 0.80

Tested by

no test coverage detected