(
txn: &T,
change_id: NodeId,
visiting: &mut HashSet<NodeId>,
visited: &mut HashSet<NodeId>,
ordered: &mut Vec<NodeId>,
)
| 362 | } |
| 363 | |
| 364 | fn visit_change<T: GraphTxnT>( |
| 365 | txn: &T, |
| 366 | change_id: NodeId, |
| 367 | visiting: &mut HashSet<NodeId>, |
| 368 | visited: &mut HashSet<NodeId>, |
| 369 | ordered: &mut Vec<NodeId>, |
| 370 | ) -> Result<(), RepositoryError> { |
| 371 | if visited.contains(&change_id) { |
| 372 | return Ok(()); |
| 373 | } |
| 374 | if !visiting.insert(change_id) { |
| 375 | return Err(RepositoryError::InvalidOperation { |
| 376 | message: format!( |
| 377 | "PATH_CLAIMS migration found a dependency cycle at change {}", |
| 378 | change_id.get() |
| 379 | ), |
| 380 | }); |
| 381 | } |
| 382 | for dependency in txn |
| 383 | .get_indexed_change_deps(change_id) |
| 384 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 385 | { |
| 386 | let dependency_id = txn |
| 387 | .get_internal(&dependency) |
| 388 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 389 | .ok_or_else(|| { |
| 390 | RepositoryError::Database(format!( |
| 391 | "change {} has unregistered dependency {}", |
| 392 | change_id.get(), |
| 393 | dependency |
| 394 | )) |
| 395 | })?; |
| 396 | if !dependency_id.is_root() { |
| 397 | visit_change(txn, dependency_id, visiting, visited, ordered)?; |
| 398 | } |
| 399 | } |
| 400 | visiting.remove(&change_id); |
| 401 | visited.insert(change_id); |
| 402 | ordered.push(change_id); |
| 403 | Ok(()) |
| 404 | } |
| 405 | |
| 406 | fn commit_migration(path: &Path, plan: MigrationPlan) -> Result<(), RepositoryError> { |
| 407 | let db = redb::Builder::new() |
no test coverage detected