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

Function resolve_context_vertex_in_inode

atomic-core/src/apply/insertion.rs:338–363  ·  view source on GitHub ↗

Resolve a context position through the file's own vertex index first. A zero-length vertex (an empty file, or a file truncated to nothing) shares its position with the end of the content serialized before it and with the start of what follows. The position-only lookups preferred that empty marker, so appending to a file whose last line was recorded in the same change as another file's truncation

(
    txn: &CachedWriteGraphTxn<'_, '_>,
    inode: Option<Inode>,
    pos: Position<NodeId>,
    is_predecessor: bool,
)

Source from the content-addressed store, hash-verified

336/// the chain's terminal rows separately, so every applied vertex is
337/// indexed under its inode).
338fn resolve_context_vertex_in_inode(
339 txn: &CachedWriteGraphTxn<'_, '_>,
340 inode: Option<Inode>,
341 pos: Position<NodeId>,
342 is_predecessor: bool,
343) -> Result<GraphNode<NodeId>, LocalApplyError> {
344 if let Some(inode) = inode.filter(|_| !pos.change.is_root()) {
345 let found = if is_predecessor {
346 txn.find_block_end_in_inode(inode, pos)
347 } else {
348 txn.find_block_in_inode(inode, pos)
349 }
350 .map_err(|error| LocalApplyError::Internal {
351 message: format!(
352 "failed to resolve context {} in inode {}: {}",
353 pos,
354 inode.get(),
355 error
356 ),
357 })?;
358 if let Some(vertex) = found {
359 return Ok(adjust_for_mid_span(vertex, pos, is_predecessor));
360 }
361 }
362 resolve_context_vertex(txn, pos, is_predecessor)
363}
364
365#[cfg(test)]
366mod tests {

Callers 1

context_vertexFunction · 0.85

Calls 5

adjust_for_mid_spanFunction · 0.85
resolve_context_vertexFunction · 0.85
is_rootMethod · 0.45
find_block_in_inodeMethod · 0.45

Tested by

no test coverage detected