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

Function visit_change

atomic-repository/src/repository/migration.rs:364–404  ·  view source on GitHub ↗
(
    txn: &T,
    change_id: NodeId,
    visiting: &mut HashSet<NodeId>,
    visited: &mut HashSet<NodeId>,
    ordered: &mut Vec<NodeId>,
)

Source from the content-addressed store, hash-verified

362}
363
364fn 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
406fn commit_migration(path: &Path, plan: MigrationPlan) -> Result<(), RepositoryError> {
407 let db = redb::Builder::new()

Callers 1

prepare_migrationFunction · 0.85

Calls 7

removeMethod · 0.65
containsMethod · 0.45
insertMethod · 0.45
get_internalMethod · 0.45
is_rootMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected