MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / emit_ours_region

Function emit_ours_region

atomic-core/src/diff/mod.rs:678–704  ·  view source on GitHub ↗

Emit how `ours` renders base lines `[from, to)` (plus the insertions parked at `to`), failing when the region mixes an ours change with a theirs change.

(
        mapping: &OursRender,
        _base_lines: &[Line],
        ours_lines: &[Line],
        output: &mut Vec<u8>,
        from: usize,
        to: usize,
        parked_until: &mut usize,
    )

Source from the content-addressed store, hash-verified

676 /// parked at `to`), failing when the region mixes an ours change with a
677 /// theirs change.
678 fn emit_ours_region(
679 mapping: &OursRender,
680 _base_lines: &[Line],
681 ours_lines: &[Line],
682 output: &mut Vec<u8>,
683 from: usize,
684 to: usize,
685 parked_until: &mut usize,
686 ) {
687 // Lines ours inserted at base positions the walk now passes come
688 // first, each exactly once.
689 while *parked_until <= from {
690 for ours_index in &mapping.inserted[*parked_until] {
691 output.extend_from_slice(ours_lines[*ours_index].content());
692 }
693 *parked_until += 1;
694 }
695 for index in from..to {
696 if let Some(ours_index) = mapping.kept[index] {
697 output.extend_from_slice(ours_lines[ours_index].content());
698 } else if let Some((start, len)) = mapping.changed[index] {
699 for i in 0..len {
700 output.extend_from_slice(ours_lines[start + i].content());
701 }
702 }
703 }
704 }
705
706 let mut output: Vec<u8> = Vec::new();
707 let mut base_cursor = 0usize;

Callers 1

merge_textFunction · 0.85

Calls 1

contentMethod · 0.45

Tested by

no test coverage detected