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

Function write_hunk

atomic-repository/src/apply/mod.rs:587–676  ·  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

585/// `cached`, so the GRAPH/INODE_GRAPH tables are never reopened mid-hunk.
586#[allow(clippy::too_many_arguments)]
587fn write_hunk(
588 txn: &mut CachedWriteGraphTxn<'_, '_>,
589 workspace: &mut Workspace,
590 conflict_tracker: &mut ConflictTracker,
591 change_id: NodeId,
592 graph_op: &GraphOp<Option<Hash>>,
593 change: &Change,
594 verified_frontier: &atomic_core::change::VerifiedCausalFrontier,
595 options: &InsertOptions,
596 stats: &mut InsertStats,
597) -> InsertResult<()> {
598 // Conflict detection (zombie / deleted-context scanning) is only meaningful
599 // when applying a change that may race with content the change doesn't know
600 // about — i.e. cross-view insert. A freshly-recorded change applied to its
601 // own view (write_recorded sets `track_conflicts = false`) has a complete
602 // dependency closure by construction and cannot conflict, so we skip the
603 // scans. They only populate the conflict report; the graph written is
604 // identical either way.
605 let detect_conflicts = options.track_conflicts;
606 for atom_ref in graph_op.atoms() {
607 match atom_ref {
608 AtomRef::Insertion(insertion) => {
609 write_new_vertex_with_frontier(
610 txn,
611 workspace,
612 change_id,
613 insertion,
614 change,
615 verified_frontier,
616 detect_conflicts,
617 )?;
618 stats.atoms_processed += 1;
619 }
620 AtomRef::EdgeUpdate(edge_update) => {
621 write_edge_map_with_frontier(
622 txn,
623 workspace,
624 change_id,
625 edge_update,
626 change,
627 verified_frontier,
628 detect_conflicts,
629 )?;
630 stats.atoms_processed += 1;
631 }
632 AtomRef::Atom(atom) => match atom {
633 Atom::Insertion(nv) => {
634 write_new_vertex_with_frontier(
635 txn,
636 workspace,
637 change_id,
638 nv,
639 change,
640 verified_frontier,
641 detect_conflicts,
642 )?;
643 stats.atoms_processed += 1;
644 }

Callers 1

Calls 8

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