Mark every content vertex for this file as deleted. Delete the specific line vertices identified by `built.deleted_lines`. Proper patch theory: only the targeted vertices are marked deleted. Unaffected lines stay alive as the original vertices. Falls back to whole-file deletion for legacy single-vertex files or when `deleted_lines` is empty (full-file Delete hunk).
(
ctx: &mut GlobalizeContext<'_, T>,
built: &BuiltHunk,
inode: Inode,
inode_pos: Position<NodeId>,
local: Local,
encoding: Option<Encoding>,
)
| 489 | /// Falls back to whole-file deletion for legacy single-vertex files or |
| 490 | /// when `deleted_lines` is empty (full-file Delete hunk). |
| 491 | fn globalize_delete<T>( |
| 492 | ctx: &mut GlobalizeContext<'_, T>, |
| 493 | built: &BuiltHunk, |
| 494 | inode: Inode, |
| 495 | inode_pos: Position<NodeId>, |
| 496 | local: Local, |
| 497 | encoding: Option<Encoding>, |
| 498 | ) -> GlobalizeResult<Vec<GraphOp<Option<Hash>>>> |
| 499 | where |
| 500 | T: GraphTxnT + TreeTxnT + InodeGraphOps, |
| 501 | { |
| 502 | if should_use_opaque_generated_vertices(&local.path) { |
| 503 | let content_vertices = find_content_vertices(ctx.txn(), inode, inode_pos)?; |
| 504 | let deletion_edges = build_deletion_edges(ctx, &content_vertices)?; |
| 505 | let deletion = EdgeUpdate { |
| 506 | edges: deletion_edges, |
| 507 | inode: position_to_option_hash_resolved(ctx.txn(), inode_pos, None), |
| 508 | }; |
| 509 | return Ok(vec![GraphOp::Edit { |
| 510 | change: Atom::EdgeUpdate(deletion), |
| 511 | local, |
| 512 | encoding, |
| 513 | }]); |
| 514 | } |
| 515 | |
| 516 | let sorted = collect_sorted_content_vertices_cached(ctx, inode, inode_pos)?; |
| 517 | |
| 518 | // Targeted deletion when we have per-line vertices and a specific |
| 519 | // deleted range. |
| 520 | if sorted.len() > 1 && !built.deleted_lines.is_empty() { |
| 521 | let first_deleted = *built.deleted_lines.first().unwrap(); |
| 522 | let last_deleted = *built.deleted_lines.last().unwrap(); |
| 523 | |
| 524 | if last_deleted < sorted.len() { |
| 525 | let to_delete: Vec<GraphNode<NodeId>> = |
| 526 | (first_deleted..=last_deleted).map(|i| sorted[i]).collect(); |
| 527 | let deletion_edges = build_deletion_edges(ctx, &to_delete)?; |
| 528 | |
| 529 | let deletion = EdgeUpdate { |
| 530 | edges: deletion_edges, |
| 531 | inode: position_to_option_hash_resolved(ctx.txn(), inode_pos, None), |
| 532 | }; |
| 533 | |
| 534 | return Ok(vec![GraphOp::Edit { |
| 535 | change: Atom::EdgeUpdate(deletion), |
| 536 | local, |
| 537 | encoding, |
| 538 | }]); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | // Fallback: whole-file deletion. `delete_all_content` already does the |
| 543 | // thorough SCC-aware search, so no further fallback is needed here. |
| 544 | let deletion = delete_all_content(ctx, inode_pos)?; |
| 545 | |
| 546 | Ok(vec![GraphOp::Edit { |
| 547 | change: Atom::EdgeUpdate(deletion), |
| 548 | local, |
no test coverage detected