[MERGE] Fix for bug 303569: shelving a patch with no new line at end of file fails

Benoît PIERRE benoit.pierre at gmail.com
Tue Feb 24 01:14:31 GMT 2009


The code in partches.parse_patch doesn't correctly handle a
patch with the marker '\ No newline at end of file' to indicate
a line doesn't end with a newline: the hunk doesn't account for
the extra line so the loop that parses the patch will stop short
of one line and parsing the next hunk will raise a "malformed
hunk header" exception.

This does not happen when using parse_patches since
iter_lines_handle_nl is first called to fix all lines that must
not end with a newline.

This patch basically just move the call to iter_lines_handle_nl
from parse_patches to parse_patch, so using the later directly
will work. I also added a new test in test_patches.py to exerce
both cases (patching from/to a file with no terminating
newline).

-- 
A: Because it destroys the flow of conversation.
Q: Why is top posting dumb?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shelve_patch_no_newline_at_end-3882.patch
Type: text/x-diff
Size: 11628 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090224/69a444a0/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090224/69a444a0/attachment.pgp 


More information about the bazaar mailing list