(
ctx: &mut GlobalizeContext<'_, T>,
built: &BuiltHunk,
inode: Inode,
inode_pos: Position<NodeId>,
content: &[u8],
full_content: &[u8],
local: Local,
encoding: Option<E
| 311 | /// before per-line vertex creation), we fall back to whole-file Replace. |
| 312 | #[allow(clippy::too_many_arguments)] |
| 313 | fn globalize_replace<T>( |
| 314 | ctx: &mut GlobalizeContext<'_, T>, |
| 315 | built: &BuiltHunk, |
| 316 | inode: Inode, |
| 317 | inode_pos: Position<NodeId>, |
| 318 | content: &[u8], |
| 319 | full_content: &[u8], |
| 320 | local: Local, |
| 321 | encoding: Option<Encoding>, |
| 322 | ) -> GlobalizeResult<Vec<GraphOp<Option<Hash>>>> |
| 323 | where |
| 324 | T: GraphTxnT + TreeTxnT + InodeGraphOps, |
| 325 | { |
| 326 | // NOTE (review ::26 R1 follow-up, 2026-09-16): the historical |
| 327 | // `should_use_opaque_generated_vertices` early-return here routed EVERY |
| 328 | // Replace hunk of an opaque path (lockfiles/checksums) to whole-file |
| 329 | // replacement — using the hunk's SLICED content (just the modified |
| 330 | // lines). A lockfile-only modification of lines 2 and 6 therefore |
| 331 | // became two sequential whole-file replaces carrying one line each, |
| 332 | // destroying the other lines (12-of-67 bytes rendered — a real |
| 333 | // data-loss defect). Targeted per-line surgery is classification-blind: |
| 334 | // the deletion and insertion operate on graph vertices, so an |
| 335 | // opaque-classified file with per-line structure takes the SAME |
| 336 | // targeted path. The monolithic-vertex and empty-file shapes still |
| 337 | // fall back to whole-file replacement below (bounds-check + |
| 338 | // sorted.is_empty()), and whole-file lifecycle paths (add/delete/ |
| 339 | // globalize_replace_whole_file) keep their opaque insert shape. |
| 340 | |
| 341 | // Every whole-file fallback below rewrites the file from the FULL new |
| 342 | // content: the hunk slice holds only the replaced lines, and a replace |
| 343 | // built from it deleted every vertex and kept just those lines (a |
| 344 | // one-line tox.ini edit on a file whose vertices no longer matched its |
| 345 | // lines rendered 63 of 855 bytes and the import refused). |
| 346 | let sorted = collect_sorted_content_vertices_cached(ctx, inode, inode_pos)?; |
| 347 | |
| 348 | // Legacy: file has no visible content vertices in this view. Fall |
| 349 | // back to whole-file replace, which walks INODE_GRAPH unfiltered. |
| 350 | // |
| 351 | // NOTE: we use `== 0`, not `<= 1`. A single-line file produces |
| 352 | // exactly one per-line vertex, and the targeted path below handles |
| 353 | // that just fine (predecessor=inode, successor=None, delete that |
| 354 | // one vertex, insert the replacement lines). Falling back to |
| 355 | // whole-file replace for single-line files would have us re-read |
| 356 | // edges through the unfiltered INODE_GRAPH index, which picks up |
| 357 | // vertices from OTHER views and silently adds their changes as |
| 358 | // dependencies — producing a phantom supersession relationship |
| 359 | // between the just-recorded change and the other view's edits. |
| 360 | if sorted.is_empty() { |
| 361 | return globalize_replace_whole_file(ctx, inode, inode_pos, full_content, local, encoding); |
| 362 | } |
| 363 | |
| 364 | // Pure insertion (no lines deleted) — treat as a middle/append insert. |
| 365 | // This happens when the diff produces a Replace with old_len == 0 |
| 366 | // (an insertion that the algorithm classified as a replacement). |
| 367 | if built.deleted_lines.is_empty() { |
| 368 | let position = |
| 369 | match classify_insert(&sorted, inode_pos, built.old_start, Some(sorted.len())) { |
| 370 | Ok(p) => p, |
no test coverage detected