Skip to main content

Module apply_patch

Module apply_patch 

Source
Expand description

apply_patch: add, delete, move and edit several files in one call.

The patch uses the plain-text envelope coding models are trained on:

*** Begin Patch
*** Add File: src/new.rs
+fn main() {}
*** Update File: src/lib.rs
*** Move to: src/core.rs
@@ fn parse
 context line
-removed line
+added line
*** Delete File: old.txt
*** End Patch

Every operation is checked (paths, the stale-read guard, hunk matching) before anything is written, so a patch applies completely or not at all. Hunks are located after the previous hunk of the same file, first by exact lines, then ignoring trailing whitespace, then ignoring surrounding whitespace; an @@ <text> header first moves past the line containing <text>.

Structsยง

ApplyPatchTool