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

Method clone_additional_views

atomic-cli/src/commands/clone/command.rs:690–787  ·  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,
        pack: &SyncPack,
        change_objects: &HashMap<String, Vec<u8>>,
        stats: &mut CloneStats,
        applied: &mut HashSet<String>,
    )

Source from the content-addressed store, hash-verified

688 /// content-addressed and deduplicated against everything already
689 /// downloaded. Returns the number of additional views cloned.
690 fn clone_additional_views(
691 &self,
692 repo: &mut Repository,
693 pack: &SyncPack,
694 change_objects: &HashMap<String, Vec<u8>>,
695 stats: &mut CloneStats,
696 applied: &mut HashSet<String>,
697 ) -> CliResult<usize> {
698 // With `--all-views` the primary pull requested every view, so the pack
699 // already carries all view refs + snapshots. Derive the inventory from
700 // it — no separate `GET /refs/views` round-trip.
701 let names: Vec<String> = pack.refs.iter().map(|r| r.name.clone()).collect();
702 let others = match classify_inventory(&names, applied) {
703 InventoryOutcome::Views(others) => others,
704 InventoryOutcome::NothingNew => return Ok(0),
705 InventoryOutcome::Unsupported => {
706 return Err(CliError::RemoteError {
707 message: "--all-views requires the view inventory (?views), but this \
708 server does not support it (empty inventory). Upgrade the \
709 server, or clone a single view without --all-views."
710 .to_string(),
711 url: Some(self.url.clone()),
712 })
713 }
714 };
715
716 print_blank();
717 println!(
718 "Cloning {} additional {}:",
719 others.len(),
720 if others.len() == 1 { "view" } else { "views" }
721 );
722
723 // Fetch manifests for every remaining view.
724 let mut manifests: Vec<ViewManifest> = Vec::with_capacity(others.len());
725 for name in &others {
726 match self.view_manifest_from_pack(pack, name) {
727 Ok(Some(m)) => manifests.push(m),
728 Ok(None) => {
729 print_warning(&format!(
730 "View '{}' vanished from the remote — skipped",
731 name
732 ));
733 }
734 Err(e) => {
735 print_warning(&format!(
736 "Failed to fetch manifest for view '{}': {}",
737 name, e
738 ));
739 }
740 }
741 }
742
743 // Parents must apply before children; anything unorderable (parent
744 // cycle or a parent that exists nowhere) is reported and skipped.
745 let (order, stuck) = manifest_apply_order(&manifests, applied);
746 for &i in &stuck {
747 print_warning(&format!(

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
apply_view_manifestMethod · 0.80
iterMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected