| 4293 | } |
| 4294 | |
| 4295 | fn operation_map_reaches( |
| 4296 | start: OperationId, |
| 4297 | target: OperationId, |
| 4298 | operations: &BTreeMap<OperationId, Operation>, |
| 4299 | ) -> Result<bool, RepositoryError> { |
| 4300 | let mut pending = vec![start]; |
| 4301 | let mut visited = BTreeSet::new(); |
| 4302 | while let Some(operation_id) = pending.pop() { |
| 4303 | if operation_id == target { |
| 4304 | return Ok(true); |
| 4305 | } |
| 4306 | if !visited.insert(operation_id) { |
| 4307 | continue; |
| 4308 | } |
| 4309 | let operation = |
| 4310 | operations |
| 4311 | .get(&operation_id) |
| 4312 | .ok_or_else(|| RepositoryError::OperationNotFound { |
| 4313 | selector: operation_id.to_string(), |
| 4314 | })?; |
| 4315 | pending.extend(operation.payload().parents.iter().copied()); |
| 4316 | } |
| 4317 | Ok(false) |
| 4318 | } |
| 4319 | |
| 4320 | fn apply_snapshot_transition( |
| 4321 | snapshot: &mut BTreeMap<MetadataTarget, MetadataValue>, |