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

Function visit

atomic-repository/src/apply/mod.rs:164–195  ·  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

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

Callers 1

compute_insert_orderFunction · 0.85

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