(
hash: &Hash,
changes: &std::collections::HashMap<Hash, Change>,
visited: &mut HashSet<Hash>,
in_progress: &mut HashSet<Hash>,
order: &mut Vec<Hash>,
)
| 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)?; |
no test coverage detected