pub fn reverse_apply_hunks(
current: &str,
hunks: &[DiffHunk],
) -> Result<String, ReverseApplyError>Expand description
Reverses structured hunks against current content, returning the pre-image.
Each hunk’s new-side block must occur exactly once in current, and the
matches must run in hunk order without overlap. Edits outside the matched
spans are preserved; edits inside them refuse the whole file.
§Requires
hunkscomes fromsplit_unified_files(strict fidelity).
§Ensures
Ok(pre)replaces exactly the recorded new-side blocks with their old-side counterparts;Errcomputes nothing partial (pure).- Total (terminating): bounded scans over
currentandhunks.