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,
)
| 198 | /// |
| 199 | /// The NodeId of the introducing change. |
| 200 | pub 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 | /// |
no test coverage detected