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

Function write_hunk

atomic-repository/src/apply/mod.rs:392–462  ·  view source on GitHub ↗
(
    txn: &mut CachedWriteGraphTxn<'_, '_>,
    workspace: &mut Workspace,
    conflict_tracker: &mut ConflictTracker,
    change_id: NodeId,
    graph_op: &GraphOp<Option<Hash>>,
    change: &Change

Source from the content-addressed store, hash-verified

390/// `cached`, so the GRAPH/INODE_GRAPH tables are never reopened mid-hunk.
391#[allow(clippy::too_many_arguments)]
392fn write_hunk(
393 txn: &mut CachedWriteGraphTxn<'_, '_>,
394 workspace: &mut Workspace,
395 conflict_tracker: &mut ConflictTracker,
396 change_id: NodeId,
397 graph_op: &GraphOp<Option<Hash>>,
398 change: &Change,
399 options: &InsertOptions,
400 stats: &mut InsertStats,
401) -> InsertResult<()> {
402 // Conflict detection (zombie / deleted-context scanning) is only meaningful
403 // when applying a change that may race with content the change doesn't know
404 // about — i.e. cross-view insert. A freshly-recorded change applied to its
405 // own view (write_recorded sets `track_conflicts = false`) has a complete
406 // dependency closure by construction and cannot conflict, so we skip the
407 // scans. They only populate the conflict report; the graph written is
408 // identical either way.
409 let detect_conflicts = options.track_conflicts;
410 for atom_ref in graph_op.atoms() {
411 match atom_ref {
412 AtomRef::Insertion(insertion) => {
413 write_new_vertex(
414 txn,
415 workspace,
416 change_id,
417 insertion,
418 change,
419 detect_conflicts,
420 )?;
421 stats.atoms_processed += 1;
422 }
423 AtomRef::EdgeUpdate(edge_update) => {
424 write_edge_map(
425 txn,
426 workspace,
427 change_id,
428 edge_update,
429 change,
430 detect_conflicts,
431 )?;
432 stats.atoms_processed += 1;
433 }
434 AtomRef::Atom(atom) => match atom {
435 Atom::Insertion(nv) => {
436 write_new_vertex(txn, workspace, change_id, nv, change, detect_conflicts)?;
437 stats.atoms_processed += 1;
438 }
439 Atom::EdgeUpdate(em) => {
440 write_edge_map(txn, workspace, change_id, em, change, detect_conflicts)?;
441 stats.atoms_processed += 1;
442 }
443 },
444 }
445
446 if workspace.has_conflicts() {
447 for missing_ctx in workspace.missing_contexts() {
448 let conflict = if missing_ctx.is_predecessor {
449 MissingContextConflict::predecessors(missing_ctx.position, change_id)

Callers 1

write_change_to_graphFunction · 0.85

Calls 8

write_new_vertexFunction · 0.85
write_edge_mapFunction · 0.85
atomsMethod · 0.80
has_conflictsMethod · 0.45
missing_contextsMethod · 0.45
add_missing_contextMethod · 0.45
zombiesMethod · 0.45
add_zombieMethod · 0.45

Tested by

no test coverage detected