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

Function write_new_edge

atomic-core/src/apply/edge.rs:172–271  ·  view source on GitHub ↗
(
    txn: &mut CachedWriteGraphTxn<'_, '_>,
    workspace: &mut Workspace,
    change_id: NodeId,
    inode: &Position<Option<Hash>>,
    edge: &NewEdge<Option<Hash>>,
    change: &Change,
    verifi

Source from the content-addressed store, hash-verified

170/// * `change` - Full change for dependency checking
171#[allow(clippy::too_many_arguments)]
172fn write_new_edge(
173 txn: &mut CachedWriteGraphTxn<'_, '_>,
174 workspace: &mut Workspace,
175 change_id: NodeId,
176 inode: &Position<Option<Hash>>,
177 edge: &NewEdge<Option<Hash>>,
178 change: &Change,
179 verified_frontier: &VerifiedCausalFrontier,
180 detect_conflicts: bool,
181) -> Result<(), LocalApplyError> {
182 log::debug!(
183 "write_new_edge: flag={:?} from={:?} to={:?}",
184 edge.flag,
185 edge.from,
186 edge.to
187 );
188
189 // Resolve the change that introduced the edge state being superseded.
190 // `previous` and `introduced_by` are part of the integrity contract: a
191 // position alone is ambiguous when a name vertex and empty inode marker
192 // share an endpoint.
193 let previous_introducer = resolve_introduced_by(txn, &edge.introduced_by, change_id)?;
194
195 // Prefer the exact serialized target span when it already exists.
196 // Structural updates like FileMove name deletions refer to a concrete
197 // vertex span, and reducing them to start_pos loses that precision.
198 let exact_target = resolve_exact_vertex(txn, &edge.to, change_id)?;
199 let mut target = if txn
200 .has_vertex(exact_target)
201 .map_err(|e| LocalApplyError::Internal {
202 message: format!("Failed to check target vertex: {}", e),
203 })? {
204 exact_target
205 } else {
206 let target_pos = resolve_position(txn, &edge.to.start_pos(), change_id)?;
207 resolve_vertex(txn, target_pos, false)?
208 };
209
210 // Resolve inode for indexing and for inode-scoped source resolution
211 let resolved_inode = resolve_inode(txn, inode, change_id)?;
212
213 let source_pos = resolve_position(txn, &edge.from, change_id)?;
214 let source = resolve_exact_source_edge(
215 txn,
216 resolved_inode,
217 source_pos,
218 target,
219 edge.previous,
220 previous_introducer,
221 )?;
222
223 // Parse the edge kind for semantic dispatch.
224 // `edge.flag` is still `EdgeFlags` (wire format from the change), so we
225 // parse it into a typed `EdgeKind` for cleaner branching below.
226 let kind = EdgeKind::from_flags(edge.flag);
227
228 // Track folder files for conflict detection
229 if kind.is_some_and(|k| k.is_folder()) {

Callers 1

Calls 13

resolve_introduced_byFunction · 0.85
resolve_positionFunction · 0.85
resolve_inodeFunction · 0.85
add_edge_with_reverseFunction · 0.85
collect_zombie_contextFunction · 0.85
mark_rootedMethod · 0.80
resolve_vertexFunction · 0.70
has_vertexMethod · 0.45
start_posMethod · 0.45
is_folderMethod · 0.45
end_posMethod · 0.45

Tested by

no test coverage detected