Applies a Delete operation to mark a line as deleted. # Behavior 1. Verifies the branch exists 2. Verifies the branch is not already deleted 3. Updates the branch's state to Deleted Note: The branch entry remains in the database (tombstone). Associated leaves are not automatically deleted. # Errors - `BranchNotFound` - The branch doesn't exist - `InvalidBranchState` - The branch is already de
(
txn: &mut T,
context: &mut ApplyContext,
branch_id: BranchId,
)
| 280 | /// - `BranchNotFound` - The branch doesn't exist |
| 281 | /// - `InvalidBranchState` - The branch is already deleted |
| 282 | fn apply_delete<T: MutCrdtTxnT>( |
| 283 | txn: &mut T, |
| 284 | context: &mut ApplyContext, |
| 285 | branch_id: BranchId, |
| 286 | ) -> ApplyResult<()> { |
| 287 | // Verify branch exists |
| 288 | let branch = txn |
| 289 | .get_branch(branch_id) |
| 290 | .map_err(|e| storage_err(e, "getting branch"))? |
| 291 | .ok_or_else(|| ApplyError::branch_not_found(branch_id))?; |
| 292 | |
| 293 | // Check current state |
| 294 | if branch.state().is_deleted() { |
| 295 | if context.options().allow_duplicate_ids() { |
| 296 | context.record_skipped(); |
| 297 | return Ok(()); |
| 298 | } |
| 299 | return Err(ApplyError::invalid_branch_state( |
| 300 | branch_id, "deleted", "delete", |
| 301 | )); |
| 302 | } |
| 303 | |
| 304 | // Update state to deleted |
| 305 | txn.update_branch_state(branch_id, BranchState::Deleted) |
| 306 | .map_err(|e| storage_err(e, "updating branch state"))?; |
| 307 | |
| 308 | context.record_branch_deleted(); |
| 309 | Ok(()) |
| 310 | } |
| 311 | |
| 312 | // Restore Operation |
| 313 |
no test coverage detected