Open JonathanHolvey opened 7 years ago
@techtonik
I've spent a bit of time modifying your code so that files can still be patched, even if they don't match the original exactly. The main changes are as follows:
_match_file_hunks()
.Hunk
object has additional properties offset
, contextstart
and contextend
to allow this mechanism to work.I've only tested with a couple of files I'm particularly interested with so far, but my next step will be to validate the changes using your unit test script. Running it now results in 9 failures out of 44, compared with 7 for your master branch. I also need to check for Python 2 compatibility and speed optimisation.
You may find these changes too drastic to merge into you project, however please let me know if you are interested in including it. I don't imagine it will take me too long to have it in a state where it could be released.
Take a look at my branch here.
Cheers, Jon
After fixing a few errors in the unit tests, your master branch passes without issue. My modifications result in 4 errors for the same tests. These, I think, should be straightforward to correct.
I have a unified patch file which can be successfully applied using the GNU utility Patch. The line numbers of the source files do not match the patch, however there is enough context available around each hunk (three lines, as default) for the process to complete anyway.
When I try using the same patch file with python-patch, the
apply()
method fails with the debug logWhen looking through the source for
apply()
, I can't see any attempt to make corrections for non-matching line numbers.Is this useful feature of the unified diff format beyond the scope of the project, something that hasn't been implemented yet, or am I just using it wrong?