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

Function visit

atomic-repository/src/apply/mod.rs:165–196  ·  view source on GitHub ↗
(
        hash: &Hash,
        changes: &std::collections::HashMap<Hash, Change>,
        visited: &mut HashSet<Hash>,
        in_progress: &mut HashSet<Hash>,
        order: &mut Vec<Hash>,
    )

Source from the content-addressed store, hash-verified

163 let mut in_progress = HashSet::new();
164
165 fn visit(
166 hash: &Hash,
167 changes: &std::collections::HashMap<Hash, Change>,
168 visited: &mut HashSet<Hash>,
169 in_progress: &mut HashSet<Hash>,
170 order: &mut Vec<Hash>,
171 ) -> InsertResult<()> {
172 if visited.contains(hash) {
173 return Ok(());
174 }
175 if in_progress.contains(hash) {
176 return Err(InsertError::CyclicDependency {
177 message: format!("Cycle detected involving {}", hash.to_base32()),
178 });
179 }
180
181 in_progress.insert(*hash);
182
183 if let Some(change) = changes.get(hash) {
184 for dep in change.dependencies() {
185 if changes.contains_key(dep) {
186 visit(dep, changes, visited, in_progress, order)?;
187 }
188 }
189 }
190
191 in_progress.remove(hash);
192 visited.insert(*hash);
193 order.push(*hash);
194
195 Ok(())
196 }
197
198 for hash in changes.keys() {
199 visit(hash, changes, &mut visited, &mut in_progress, &mut order)?;

Callers 1

compute_insert_orderFunction · 0.70

Calls 7

contains_keyMethod · 0.80
getMethod · 0.65
removeMethod · 0.65
containsMethod · 0.45
insertMethod · 0.45
dependenciesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected