Closed craigds closed 6 years ago
Currently bowler applies each hunk separately with the patch command, which is probably triggering your issue as the line numbers get further and further offset with each hunk applied. We should probably make Bowler instead track all of the accepted hunks for a given file, and apply them all at once. This will prevent the line numbers from getting out of sync with the state of the file as each patch gets applied, and also have the side benefit of reducing the number of times we shell out to the patch
command and touch files.
For anyone interested in working on this, the relevant code is here: https://github.com/facebookincubator/Bowler/blob/master/bowler/tool.py#L241
It should just be a matter of joining the hunks into a single patch, and then running the patch command at the end.
My current workaround for this issue is to just run my bowler script multiple times if there are .rej
files present.
This should be resolved by Lisa's PR.
Apologies for the size of this issue; I've reduced it as much as I can while still triggering the problem.
This file: https://gist.github.com/craigds/4bb86df3b3ead343c22be6c7c9c14a57 I've snipped it at 1750 lines, because that's just enough to reproduce the issue.
With this script:
output
causes?
Chopping much more out of the source file makes the error not occur. It doesn't seem to matter which parts you chop out.
My hunch is that if the diff gets too large, the
patch
can no longer match line numbers from old to new, so it rejects the patch.A workaround might be to pause running fixers when the diff gets bigger than a certain threshold and write the new file out, and then continue running fixers? ie patch in multiple stages.