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

Function manifest_chain_from_pack

atomic-cli/src/commands/pull/command.rs:116–147  ·  view source on GitHub ↗

Reconstruct the requested view's metadata chain from a sync pack in root-to-leaf order. The server includes the requested ref and every ancestor snapshot. Views are metadata closures over the common graph, so pull applies this whole chain after saving the missing graph objects.

(
    pack: &SyncPack,
    leaf: &str,
    url: &str,
)

Source from the content-addressed store, hash-verified

114/// snapshot. Views are metadata closures over the common graph, so pull applies
115/// this whole chain after saving the missing graph objects.
116fn manifest_chain_from_pack(
117 pack: &SyncPack,
118 leaf: &str,
119 url: &str,
120) -> CliResult<Vec<ViewManifest>> {
121 let mut by_name = HashMap::new();
122 for r in &pack.refs {
123 if let Some(m) = manifest_from_pack(pack, &r.name, url)? {
124 by_name.insert(r.name.clone(), m);
125 }
126 }
127
128 let mut chain = Vec::new();
129 let mut seen = std::collections::HashSet::new();
130 let mut cursor = Some(leaf.to_string());
131 while let Some(name) = cursor {
132 if !seen.insert(name.clone()) {
133 return Err(CliError::RemoteError {
134 message: format!("Remote view parent chain contains a cycle at '{name}'"),
135 url: Some(url.to_string()),
136 });
137 }
138 let manifest = by_name.remove(&name).ok_or_else(|| CliError::RemoteError {
139 message: format!("Remote view metadata is missing '{name}'"),
140 url: Some(url.to_string()),
141 })?;
142 cursor = manifest.parent.clone();
143 chain.push(manifest);
144 }
145 chain.reverse();
146 Ok(chain)
147}
148
149// Constants
150

Callers 1

run_asyncMethod · 0.70

Calls 6

manifest_from_packFunction · 0.70
removeMethod · 0.65
insertMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected