MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / CreatePatch

Function CreatePatch

internal/diff/diff.go:23–27  ·  view source on GitHub ↗

CreatePatch computes a compact patch that transforms oldText into newText. The patch can be applied with ApplyPatch to recover newText from oldText. Both texts must be valid UTF-8 (BUG-3839; see ReversePatch).

(oldText, newText string)

Source from the content-addressed store, hash-verified

21// The patch can be applied with ApplyPatch to recover newText from oldText.
22// Both texts must be valid UTF-8 (BUG-3839; see ReversePatch).
23func CreatePatch(oldText, newText string) string {
24 diffs := dmp.DiffMain(oldText, newText, true)
25 patches := dmp.PatchMake(oldText, diffs)
26 return dmp.PatchToText(patches)
27}
28
29// ApplyPatch applies a patch to baseText to produce the target text.
30// Returns an error if the patch cannot be applied cleanly, or if the base or

Calls

no outgoing calls