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

Function resolve_introduced_by

atomic-core/src/apply/position.rs:200–218  ·  view source on GitHub ↗

Resolve the `introduced_by` field of an edge. Returns the NodeId of the change that introduced the original edge. This is used when modifying edges to track provenance. # Arguments `txn` - Transaction for lookups `introduced_by` - Optional hash of the introducing change `current_change` - NodeId of the change being applied # Returns The NodeId of the introducing change.

(
    txn: &T,
    introduced_by: &Option<Hash>,
    current_change: NodeId,
)

Source from the content-addressed store, hash-verified

198///
199/// The NodeId of the introducing change.
200pub fn resolve_introduced_by<T: GraphTxnT>(
201 txn: &T,
202 introduced_by: &Option<Hash>,
203 current_change: NodeId,
204) -> Result<NodeId, LocalApplyError> {
205 match introduced_by {
206 Some(hash) if hash.is_none() => {
207 // Hash::NONE represents the ROOT node
208 Ok(NodeId::ROOT)
209 }
210 Some(hash) => txn
211 .get_internal(hash)
212 .map_err(|e| LocalApplyError::Internal {
213 message: format!("Failed to resolve introduced_by: {}", e),
214 })?
215 .ok_or(LocalApplyError::DependencyMissing { hash: *hash }),
216 None => Ok(current_change),
217 }
218}
219
220/// Resolve a context position to a span.
221///

Callers 1

write_new_edgeFunction · 0.85

Calls 2

is_noneMethod · 0.80
get_internalMethod · 0.45

Tested by

no test coverage detected