Output graph content with semantic-merge resolution. This is the merge-aware counterpart of [`output_graph_content`]. For every SCC whose lead vertex appears in `resolved`, the merged bytes are written directly and the remaining vertices are silently skipped. All other SCCs are handled identically to `output_graph_content`. If `resolved` is empty this function behaves exactly like [`output_gra
(
changes: &C,
hash_fn: F,
graph: &AliveGraph,
order: &OrderResult,
buffer: &mut V,
resolved: &ResolvedConflicts,
)
| 550 | /// If `resolved` is empty this function behaves exactly like |
| 551 | /// [`output_graph_content`]. |
| 552 | pub fn output_graph_content_resolved<C, F, V>( |
| 553 | changes: &C, |
| 554 | hash_fn: F, |
| 555 | graph: &AliveGraph, |
| 556 | order: &OrderResult, |
| 557 | buffer: &mut V, |
| 558 | resolved: &ResolvedConflicts, |
| 559 | ) -> OutputResult<()> |
| 560 | where |
| 561 | C: ChangeStore, |
| 562 | F: Fn(NodeId) -> Result<Option<Hash>, PristineError>, |
| 563 | V: VertexBuffer, |
| 564 | { |
| 565 | validate_order_vertices(graph, order)?; |
| 566 | |
| 567 | // Fast path: nothing was resolved and no unresolved forks. |
| 568 | if resolved.is_empty() && resolved.unresolved_forks().is_empty() { |
| 569 | return output_graph_content(changes, hash_fn, graph, order, buffer); |
| 570 | } |
| 571 | |
| 572 | // Track conflict IDs |
| 573 | let mut conflict_id: usize = 0; |
| 574 | |
| 575 | // Track zombie state |
| 576 | let mut in_zombie: Option<usize> = None; |
| 577 | |
| 578 | // Track which fork-conflict vertices have already been emitted. |
| 579 | let mut fork_emitted: std::collections::HashSet<VertexId> = std::collections::HashSet::new(); |
| 580 | |
| 581 | // Debug-only guard: each vertex's content must be emitted at most once |
| 582 | // across the resolved/fork/normal paths. Emitting a vertex twice is the |
| 583 | // silent-duplication signature. Zero cost in release builds. |
| 584 | #[cfg(debug_assertions)] |
| 585 | let mut emitted_content: std::collections::HashSet<VertexId> = std::collections::HashSet::new(); |
| 586 | |
| 587 | for scc in order.sccs.iter().rev() { |
| 588 | if scc.is_empty() { |
| 589 | continue; |
| 590 | } |
| 591 | |
| 592 | let is_cyclic = scc.len() > 1; |
| 593 | |
| 594 | // ── Resolved SCC: emit merged bytes, no conflict markers ────── |
| 595 | if is_cyclic { |
| 596 | if let Some(merged) = resolved.get_merged(scc[0]) { |
| 597 | if !merged.is_empty() { |
| 598 | let synthetic = GraphNode::new( |
| 599 | NodeId::ROOT, |
| 600 | ChangePosition::new(0), |
| 601 | ChangePosition::new(merged.len() as u64), |
| 602 | ); |
| 603 | // Clone into a local so the closure can own it |
| 604 | // (`output_line` takes `FnOnce`). |
| 605 | let bytes = merged.to_vec(); |
| 606 | buffer |
| 607 | .output_line(synthetic, |buf: &mut [u8]| -> Result<(), std::io::Error> { |
| 608 | buf.copy_from_slice(&bytes); |
| 609 | Ok(()) |