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

Function import_graph_first_source

atomic-repository/src/repository/insert.rs:428–473  ·  view source on GitHub ↗
(
    txn: &T,
    pos: &Position<Option<Hash>>,
    inode_pos: &Position<Option<Hash>>,
    resolved_inode: Option<Inode>,
    old_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
    current_b

Source from the content-addressed store, hash-verified

426
427#[allow(clippy::too_many_arguments)]
428fn import_graph_first_source<T>(
429 txn: &T,
430 pos: &Position<Option<Hash>>,
431 inode_pos: &Position<Option<Hash>>,
432 resolved_inode: Option<Inode>,
433 old_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
434 current_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
435 vertex_cache: &mut ImportGraphFirstVertexCache,
436 change_id: NodeId,
437) -> Result<GraphNode<NodeId>, RepositoryError>
438where
439 T: GraphTxnT + TreeTxnT + InodeGraphOps,
440{
441 let resolved = import_graph_first_position(txn, pos, change_id)?;
442
443 if resolved.change == change_id {
444 if let Some(node) = current_by_end.get(&resolved) {
445 return Ok(*node);
446 }
447 }
448
449 if let Some(node) = old_by_end.get(&resolved) {
450 return Ok(*node);
451 }
452
453 let resolved_inode_pos = import_graph_first_position(txn, inode_pos, change_id)?;
454 if resolved == resolved_inode_pos {
455 return Ok(GraphNode {
456 change: resolved.change,
457 start: resolved.pos,
458 end: resolved.pos,
459 });
460 }
461
462 if let Some(inode) = resolved_inode {
463 if let Some(node) = vertex_cache.find_end(txn, inode, resolved)? {
464 return Ok(node);
465 }
466 if let Some(node) = vertex_cache.load(txn, inode)?.by_end.get(&resolved) {
467 return Ok(*node);
468 }
469 }
470
471 txn.find_block_end(resolved)
472 .map_err(|e| RepositoryError::Apply(e.to_string()))
473}
474
475fn import_graph_first_successor<T>(
476 txn: &T,

Callers 1

Calls 5

find_endMethod · 0.80
getMethod · 0.65
loadMethod · 0.45
find_block_endMethod · 0.45

Tested by

no test coverage detected