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

Function has_visible_span_root

atomic-repository/src/repository/content.rs:1375–1451  ·  view source on GitHub ↗
(
    txn: &T,
    store: &C,
    inode: Inode,
    visibility: &GraphVisibilityClosure,
)

Source from the content-addressed store, hash-verified

1373}
1374
1375pub(super) fn has_visible_span_root<T, C>(
1376 txn: &T,
1377 store: &C,
1378 inode: Inode,
1379 visibility: &GraphVisibilityClosure,
1380) -> Result<bool, RepositoryError>
1381where
1382 T: atomic_core::pristine::span_patch_storage::SpanPatchReadTxn
1383 + atomic_core::pristine::TreeTxnT
1384 + atomic_core::pristine::CapabilityTxnT,
1385 C: atomic_core::change::ChangeStore,
1386{
1387 use atomic_core::pristine::SPAN_RANGE_CAPABILITY;
1388 let capability = txn
1389 .required_capability_version(SPAN_RANGE_CAPABILITY.id())
1390 .map_err(|error| RepositoryError::Database(error.to_string()))?;
1391 let Some(root) = txn
1392 .span_root(inode)
1393 .map_err(|error| RepositoryError::Database(error.to_string()))?
1394 else {
1395 if capability.is_some() {
1396 let position = txn
1397 .inode_position(inode)
1398 .map_err(|error| RepositoryError::Database(error.to_string()))?;
1399 if let Some(position) = position.filter(|position| !position.change.is_root()) {
1400 let hash = txn
1401 .get_external(position.change)
1402 .map_err(|error| RepositoryError::Database(error.to_string()))?
1403 .ok_or_else(|| {
1404 RepositoryError::Database("file origin hash is missing".into())
1405 })?;
1406 let origin = store
1407 .get_change(&hash)
1408 .map_err(|error| RepositoryError::Database(error.to_string()))?;
1409 if origin.hashed.span.is_some() {
1410 return Err(RepositoryError::Database(format!(
1411 "span root missing for inode {}",
1412 inode.get()
1413 )));
1414 }
1415 }
1416 }
1417 use atomic_core::pristine::SPAN_LEGACY_CONTEXT_CAPABILITY;
1418 return match txn
1419 .required_capability_version(SPAN_LEGACY_CONTEXT_CAPABILITY.id())
1420 .map_err(|e| RepositoryError::Database(e.to_string()))?
1421 {
1422 None => {
1423 if !txn
1424 .span_edits_for_inode(inode)
1425 .map_err(|e| RepositoryError::Database(e.to_string()))?
1426 .is_empty()
1427 {
1428 return Err(RepositoryError::Database(
1429 "legacy span index has no matching repository capability".into(),
1430 ));
1431 }
1432 Ok(false)

Callers 5

retrieve_span_if_presentFunction · 0.85
render_if_presentMethod · 0.85

Calls 10

idMethod · 0.45
span_rootMethod · 0.45
inode_positionMethod · 0.45
is_rootMethod · 0.45
get_externalMethod · 0.45
get_changeMethod · 0.45
is_emptyMethod · 0.45
span_edits_for_inodeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected