Author: stsp
Date: Sun Nov 27 13:35:14 2011
New Revision: 1206718
URL: http://svn.apache.org/viewvc?rev=1206718&view=rev
Log:
Fix issue #3814 "patch doesn't append newline to properties".
This fix depends on the change made to 'svn diff' output in r1206576.
* subversion/libsvn_diff/parse-diff.c
(parse_next_hunk): Recognize "\ No newline at end of..." type comments
and snip off trailing EOLs from hunk texts terminated with such comments.
* subversion/libsvn_client/patch.c
(apply_hunk): Properly write the last line of hunk text to the patched
result even if EOF was hit before EOL while reading the line.
* subversion/tests/cmdline/patch_tests.py
(patch_set_prop_no_eol): Remove XFail marker.
Modified:
subversion/trunk/subversion/libsvn_client/patch.c
subversion/trunk/subversion/libsvn_diff/parse-diff.c
subversion/trunk/subversion/tests/cmdline/patch_tests.py
Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=1206718&r1=1206717&r2=1206718&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Sun Nov 27 13:35:14 2011
@@ -1699,7 +1699,7 @@ apply_hunk(patch_target_t *target, targe
&eol_str, &eof,
iterpool, iterpool));
lines_read++;
- if (! eof && lines_read > hi->fuzz &&
+ if (lines_read > hi->fuzz &&
lines_read <= svn_diff_hunk_get_modified_length(hi->hunk) - hi->fuzz)
{
apr_size_t len;
Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=1206718&r1=1206717&r2=1206718&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Sun Nov 27 13:35:14
2011
@@ -642,7 +642,38 @@ parse_next_hunk(svn_diff_hunk_t **hunk,
/* Lines starting with a backslash are comments, such as
* "\ No newline at end of file". */
if (line->data[0] == '\\')
- continue;
+ {
+ if (in_hunk &&
+ ((!is_property &&
+ strcmp(line->data, "\\ No newline at end of file") == 0) ||
+ (is_property &&
+ strcmp(line->data, "\\ No newline at end of property") == 0)))
+ {
+ char eolbuf[2];
+ apr_size_t len;
+ apr_off_t off;
+
+ /* Comment terminates the hunk text and says the hunk text
+ * has no trailing EOL. Snip off trailing EOL which is part
+ * of the patch file but not part of the hunk text. */
+ off = last_line - 2;
+ SVN_ERR(svn_io_file_seek(apr_file, APR_SET, &off, iterpool));
+ len = sizeof(eolbuf);
+ SVN_ERR(svn_io_file_read_full2(apr_file, eolbuf, len, &len,
+ &eof, iterpool));
+ if (eolbuf[0] == '\r' && eolbuf[1] == '\n')
+ end = last_line - 2;
+ else if (eolbuf[1] == '\n')
+ end = last_line - 1;
+ else if (eolbuf[1] == '\r')
+ end = last_line - 1;
+ else
+ end = last_line;
+ break;
+ }
+
+ continue;
+ }
if (in_hunk)
{
Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1206718&r1=1206717&r2=1206718&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Sun Nov 27
13:35:14 2011
@@ -3427,7 +3427,6 @@ def patch_strip_cwd(sbox):
"patch --strip propchanges cwd"
return patch_one_property(sbox, True)
-@XFail()
@Issue(3814)
def patch_set_prop_no_eol(sbox):
"patch doesn't append newline to properties"