python-patch
python-patch copied to clipboard
Crash on SVN-created patch with only one binary file changed
What steps will reproduce the problem?
1. Add new or change existing binary file in svn repository.
2. Create svn diff.
3. Try to parse/apply patch with patch.py
What is the expected output? What do you see instead?
I would expect binary file to be copied over; at the very least - some warning
that this case cannot be processed.
I actually get AttributeError: 'NoneType' object has no attribute 'hunks'" in
either line 440 or 444, depending on debugmode setting value.
What version of the product are you using? On what operating system?
@146, python 2.6, Win and Mac.
Please provide any additional information below.
The issue is due to incorrect processing of header in this case - code after
line 220 ("if headscan:") doesn't stop and treats this whole thing as a header
without any additional parsing:
Index: bin.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: bin.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Original issue reported on code.google.com by [email protected] on 31 Mar 2011 at 8:07
Right, it doesn't process header, because it is SVN header - not the header of
unified diff format.
You can not apply such 'svn diff' for binary file, because there is no unified
diff data at all - if you execute `svn diff > somefile.diff.txt` - you'll see
that somefile.diff doesn't contain any binary data to be copied over either.
What can be done is detection for this specific SVN case and complain message
that 'svn diff' for binary files can not be applied, because, well, this binary
data is missing from svn diffs.
Original comment by [email protected] on 31 Mar 2011 at 9:29
Additional parsing for specific cases (like detection of Mercurial and Git
patches) is made at the end of parse() function. I'll try release an updated
python-patch with these changes soon.
Thanks for report, btw.
Original comment by [email protected] on 31 Mar 2011 at 9:32