Skip to main content

Module textdiff

Module textdiff 

Source
Expand description

A small line diff for rendered config files (Phase 35).

Exists once, in Rust: the CLI, the server and the app all ask for a diff instead of each carrying one, so the three cannot disagree about what changed.

Strategy: strip the common head and tail, then a longest-common-subsequence table over what is left. Rendered configs are tens to a few thousand lines and differ in a few places, so the middle is small. When it is not (MAX_CELLS), the middle is reported as one deletion and one insertion rather than spending quadratic memory; the output stays correct, only less minimal. // ponytail: LCS table, switch to Myers O(ND) if a real config ever hits the cell ceiling.

Enums§

Op

Constants§

MAX_CELLS
Largest n * m the LCS table may reach (16 MB of u32).

Functions§

diff_ops
The edit script turning a into b, line by line.
stat
Counts of changed lines: (added, removed).
unified
A unified diff with context lines around each change. Empty string when the two sides are identical.