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

Function resolve_vertex

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

Convert an external span (with Hash) to an internal span (with NodeId). Similar to `resolve_position`, but for vertices which include start and end. # Arguments `txn` - Transaction for looking up internal IDs `span` - External span with optional hash `current_change` - NodeId of the change being applied # Returns The internal span with NodeId. # Special Cases - When `node.change` is `None`,

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

Source from the content-addressed store, hash-verified

118/// Returns `LocalApplyError::DependencyMissing` if the referenced change
119/// is not registered in the repository.
120pub fn resolve_vertex<T: GraphTxnT>(
121 txn: &T,
122 node: &GraphNode<Option<Hash>>,
123 current_change: NodeId,
124) -> Result<GraphNode<NodeId>, LocalApplyError> {
125 let change_id = match node.change {
126 Some(hash) if hash.is_none() => {
127 // Hash::NONE represents the ROOT span
128 NodeId::ROOT
129 }
130 Some(hash) => txn
131 .get_internal(&hash)
132 .map_err(|e| LocalApplyError::Internal {
133 message: format!("Failed to resolve node: {}", e),
134 })?
135 .ok_or(LocalApplyError::DependencyMissing { hash })?,
136 None => current_change,
137 };
138
139 Ok(GraphNode {
140 change: change_id,
141 start: node.start,
142 end: node.end,
143 })
144}
145
146/// Resolve an inode position to an actual Inode value.
147///

Callers

nothing calls this directly

Calls 2

is_noneMethod · 0.80
get_internalMethod · 0.45

Tested by

no test coverage detected