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

Function operation_reaches

atomic-repository/src/repository/operation.rs:4442–4465  ·  view source on GitHub ↗
(
    txn: &atomic_core::pristine::WriteTxn<'_>,
    start: OperationId,
    target: OperationId,
)

Source from the content-addressed store, hash-verified

4440}
4441
4442fn operation_reaches(
4443 txn: &atomic_core::pristine::WriteTxn<'_>,
4444 start: OperationId,
4445 target: OperationId,
4446) -> Result<bool, RepositoryError> {
4447 let mut pending = vec![start];
4448 let mut visited = BTreeSet::new();
4449 while let Some(operation_id) = pending.pop() {
4450 if operation_id == target {
4451 return Ok(true);
4452 }
4453 if !visited.insert(operation_id) {
4454 continue;
4455 }
4456 let operation = txn
4457 .get_operation(operation_id)
4458 .map_err(pristine_error)?
4459 .ok_or_else(|| RepositoryError::OperationNotFound {
4460 selector: operation_id.to_string(),
4461 })?;
4462 pending.extend(operation.payload().parents.iter().copied());
4463 }
4464 Ok(false)
4465}
4466
4467fn merge_commuting_operation_states(
4468 operations: &[Operation],

Callers 1

Calls 5

extendMethod · 0.80
insertMethod · 0.45
get_operationMethod · 0.45
iterMethod · 0.45
payloadMethod · 0.45

Tested by

no test coverage detected