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

Method clone_additional_views

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

Clone every remote view not already applied by the primary chain. Each view arrives as a manifest and is applied with the same primitive as the primary view, so scope and parent are preserved. Manifests are ordered parents-before-children; changes are content-addressed and deduplicated against everything already downloaded. Returns the number of additional views cloned.

(
        &self,
        repo: &mut Repository,
        remote: &HttpRemote,
        stats: &mut CloneStats,
        applied: &mut HashSet<String>,
    )

Source from the content-addressed store, hash-verified

600 /// content-addressed and deduplicated against everything already
601 /// downloaded. Returns the number of additional views cloned.
602 async fn clone_additional_views(
603 &self,
604 repo: &mut Repository,
605 remote: &HttpRemote,
606 stats: &mut CloneStats,
607 applied: &mut HashSet<String>,
608 ) -> CliResult<usize> {
609 // The user explicitly asked for every view, so a missing inventory
610 // is a hard error, not a silent single-view clone.
611 let remote_views = remote
612 .list_views()
613 .await
614 .map_err(|e| CliError::RemoteError {
615 message: format!(
616 "--all-views requires the view inventory (?views), but the request failed: {}",
617 e
618 ),
619 url: Some(self.url.clone()),
620 })?;
621
622 let names: Vec<String> = remote_views.into_iter().map(|v| v.name).collect();
623 let others = match classify_inventory(&names, applied) {
624 InventoryOutcome::Views(others) => others,
625 InventoryOutcome::NothingNew => return Ok(0),
626 InventoryOutcome::Unsupported => {
627 return Err(CliError::RemoteError {
628 message: "--all-views requires the view inventory (?views), but this \
629 server does not support it (empty inventory). Upgrade the \
630 server, or clone a single view without --all-views."
631 .to_string(),
632 url: Some(self.url.clone()),
633 })
634 }
635 };
636
637 print_blank();
638 println!(
639 "Cloning {} additional {}:",
640 others.len(),
641 if others.len() == 1 { "view" } else { "views" }
642 );
643
644 // Fetch manifests for every remaining view.
645 let mut manifests: Vec<ViewManifest> = Vec::with_capacity(others.len());
646 for name in &others {
647 match self.fetch_view_manifest(remote, name).await {
648 Ok(Some(m)) => manifests.push(m),
649 Ok(None) => {
650 print_warning(&format!(
651 "View '{}' vanished from the remote — skipped",
652 name
653 ));
654 }
655 Err(e) => {
656 print_warning(&format!(
657 "Failed to fetch manifest for view '{}': {}",
658 name, e
659 ));

Callers 1

run_asyncMethod · 0.80

Calls 15

classify_inventoryFunction · 0.85
print_blankFunction · 0.85
print_warningFunction · 0.85
manifest_apply_orderFunction · 0.85
change_unionFunction · 0.85
fetch_view_manifestMethod · 0.80
apply_view_manifestMethod · 0.80
list_viewsMethod · 0.45
cloneMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected