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

Function apply_reparent

atomic-core/src/crdt/apply/branch.rs:371–392  ·  view source on GitHub ↗

Applies a Reparent operation to change a branch's chain position without touching its state or content. # Behavior 1. Verifies the branch exists. 2. Calls `update_branch_after` to rewrite the BRANCH_AFTER row. The walker reads BRANCH_AFTER directly, so this is the entire effect. # Errors - `BranchNotFound` - The branch doesn't exist.

(
    txn: &mut T,
    context: &mut ApplyContext,
    branch_id: BranchId,
    new_after: Option<BranchId>,
)

Source from the content-addressed store, hash-verified

369///
370/// - `BranchNotFound` - The branch doesn't exist.
371fn apply_reparent<T: MutCrdtTxnT>(
372 txn: &mut T,
373 context: &mut ApplyContext,
374 branch_id: BranchId,
375 new_after: Option<BranchId>,
376) -> ApplyResult<()> {
377 // Verify branch exists
378 if !txn
379 .has_branch(branch_id)
380 .map_err(|e| storage_err(e, "checking branch exists"))?
381 {
382 return Err(ApplyError::branch_not_found(branch_id));
383 }
384
385 txn.update_branch_after(branch_id, new_after)
386 .map_err(|e| storage_err(e, "updating branch after-ref"))?;
387
388 // No dedicated counter on ApplyContext for reparent yet — track as a
389 // skipped op for accounting until we add `record_branch_reparented`.
390 context.record_skipped();
391 Ok(())
392}
393
394// Validation Helpers
395

Callers 2

apply_branch_opFunction · 0.85
apply_branch_op_onlyFunction · 0.85

Calls 4

storage_errFunction · 0.85
update_branch_afterMethod · 0.80
has_branchMethod · 0.45
record_skippedMethod · 0.45

Tested by

no test coverage detected