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>,
)
| 369 | /// |
| 370 | /// - `BranchNotFound` - The branch doesn't exist. |
| 371 | fn 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 |
no test coverage detected