Skip to main content

Module replay_patch

Module replay_patch 

Source
Expand description

Replay: the unified-diff parser of subsumption (replay_patch). What: The unified-diff parser that replay’s subsumption reads: git diff-tree -p output over single-level trees named by decimal index, split into hunks per entry name. Why: Subsumption decides from hunk lines and their markers; the parser keeps every byte exact, so a hunk line round-trips to the blob bytes it came from.

In TS you’d write (pseudocode):

parseIndexedPatch(text: string): ReadonlyMap<string, readonly PatchHunk[]>

Structs§

PatchHunk
What: One unified-diff hunk: its first old and new line and its lines in order. Why: A zero-based start is derived from oldStart by the callers that need it.
PatchLine
What: One patch line: its marker (b' ', b'-', b'+') and its bytes. Why: The reverse check and the containment check both read the markers.
ReplayPatchFormatError
What: Patch output that does not have the shape git diff-tree -p writes. Why: Callers fail the replay rather than guess at a truncated or foreign patch.

Functions§

parse_indexed_patch
What: Parse git diff-tree -p output over index-named single-level trees into hunks per entry name; an entry without a section has no change. Why: Subsumption reads each candidate’s landed and prepared hunks by its index name, so no patch header carries a user path.
split_keeping_newlines
What: Split bytes into lines, each keeping its newline; an unterminated last line stays as it is. Why: Hunk bodies and blob contents are compared line by line, newline included, the way Git’s xdiff compares them.