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

Function import_graph_first_source

atomic-repository/src/repository/insert.rs:1116–1161  ·  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

1114
1115#[allow(clippy::too_many_arguments)]
1116fn import_graph_first_source<T>(
1117 txn: &T,
1118 pos: &Position<Option<Hash>>,
1119 inode_pos: &Position<Option<Hash>>,
1120 resolved_inode: Option<Inode>,
1121 old_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
1122 current_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
1123 vertex_cache: &mut ImportGraphFirstVertexCache,
1124 change_id: NodeId,
1125) -> Result<GraphNode<NodeId>, RepositoryError>
1126where
1127 T: GraphTxnT + TreeTxnT + InodeGraphOps,
1128{
1129 let resolved = import_graph_first_position(txn, pos, change_id)?;
1130
1131 if resolved.change == change_id {
1132 if let Some(node) = current_by_end.get(&resolved) {
1133 return Ok(*node);
1134 }
1135 }
1136
1137 if let Some(node) = old_by_end.get(&resolved) {
1138 return Ok(*node);
1139 }
1140
1141 let resolved_inode_pos = import_graph_first_position(txn, inode_pos, change_id)?;
1142 if resolved == resolved_inode_pos {
1143 return Ok(GraphNode {
1144 change: resolved.change,
1145 start: resolved.pos,
1146 end: resolved.pos,
1147 });
1148 }
1149
1150 if let Some(inode) = resolved_inode {
1151 if let Some(node) = vertex_cache.find_end(txn, inode, resolved)? {
1152 return Ok(node);
1153 }
1154 if let Some(node) = vertex_cache.load(txn, inode)?.by_end.get(&resolved) {
1155 return Ok(*node);
1156 }
1157 }
1158
1159 txn.find_block_end(resolved)
1160 .map_err(|e| RepositoryError::Apply(e.to_string()))
1161}
1162
1163fn import_graph_first_successor<T>(
1164 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