Offsetted (relatively to sources) patches apply to wrong lines
KOLANICH opened this issue · comments
KOLANICH commented
patch -p 1 < patchFile.patch
(GNU patch) works fine.
def applyPatch(fileText: str, patchFile: Path):
with patchFile.open("rb") as psf:
ps = patch.PatchSet(psf)
ps.parse(psf)
p = ps.items[0]
with BytesIO(fileText.encode("utf-8")) as sF:
return b"".join(ps.patch_stream(sF, p.hunks)).decode("utf-8")
produces the wrong results.