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

Method clone_additional_views

atomic-cli/src/commands/clone/command.rs:812–909  ·  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

810 /// content-addressed and deduplicated against everything already
811 /// downloaded. Returns the number of additional views cloned.
812 fn clone_additional_views(
813 &self,
814 repo: &mut Repository,
815 pack: &SyncPack,
816 change_objects: &HashMap<String, Vec<u8>>,
817 stats: &mut CloneStats,
818 applied: &mut HashSet<String>,
819 ) -> CliResult<usize> {
820 // With `--all-views` the primary pull requested every view, so the pack
821 // already carries all view refs + snapshots. Derive the inventory from
822 // it — no separate `GET /refs/views` round-trip.
823 let names: Vec<String> = pack.refs.iter().map(|r| r.name.clone()).collect();
824 let others = match classify_inventory(&names, applied) {
825 InventoryOutcome::Views(others) => others,
826 InventoryOutcome::NothingNew => return Ok(0),
827 InventoryOutcome::Unsupported => {
828 return Err(CliError::RemoteError {
829 message: "--all-views requires the view inventory (?views), but this \
830 server does not support it (empty inventory). Upgrade the \
831 server, or clone a single view without --all-views."
832 .to_string(),
833 url: Some(self.url.clone()),
834 })
835 }
836 };
837
838 print_blank();
839 println!(
840 "Cloning {} additional {}:",
841 others.len(),
842 if others.len() == 1 { "view" } else { "views" }
843 );
844
845 // Fetch manifests for every remaining view.
846 let mut manifests: Vec<ViewManifest> = Vec::with_capacity(others.len());
847 for name in &others {
848 match self.view_manifest_from_pack(pack, name) {
849 Ok(Some(m)) => manifests.push(m),
850 Ok(None) => {
851 print_warning(&format!(
852 "View '{}' vanished from the remote — skipped",
853 name
854 ));
855 }
856 Err(e) => {
857 print_warning(&format!(
858 "Failed to fetch manifest for view '{}': {}",
859 name, e
860 ));
861 }
862 }
863 }
864
865 // Parents must apply before children; anything unorderable (parent
866 // cycle or a parent that exists nowhere) is reported and skipped.
867 let (order, stuck) = manifest_apply_order(&manifests, applied);
868 for &i in &stuck {
869 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
collectMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected