I’m looking for a diff library that is portable ( No Pear, no php non-widely supported extensions — like xdiff ) that allow me to do file patch for an update mechanism. The diff file I use are using the unified format.
I’ve found class.simplediff.php witch is really nice, ( even if it doesn’t support file out of the box, it’s just a matter of loading a file in a string )
But the problem is that I can’t find a way to validate if all replacement are able to be processed successfully or not.
Do you know a library that allow to validate the diff patching prior to applying it, or do you have a clue on how to do it ?
I’ve translated the patch.c code to PHP:
https://gist.github.com/1707075
The patch.c code itself is kind of messy, so is the PHP code. The hunk validation works, but it’s not as “safe” as I would need — that’s why it’s not the answer I’m looking for, but maybe it will help someone else.
Edit:
I’ve coded something. I’m not yet sure if it’s 100% reliable, but the results so far are really good in term of “validating in read only to ensure that the patch will be applied with success”: https://github.com/idealtech/UnifiedDiffPatcher
Hope it will help someone 🙂