Author: stsp Date: Mon Nov 28 22:39:59 2011 New Revision: 1207668 URL: http://svn.apache.org/viewvc?rev=1207668&view=rev Log: On the 1.7.x-svn-patch-eol-fixes branch, merge r1207656 and r1207663 from trunk.
Modified: subversion/branches/1.7.x-svn-patch-eol-fixes/ (props changed) subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/libsvn_diff/parse-diff.c subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/tests/cmdline/patch_tests.py Propchange: subversion/branches/1.7.x-svn-patch-eol-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Nov 28 22:39:59 2011 @@ -69,4 +69,4 @@ /subversion/branches/tree-conflicts:868291-873154 /subversion/branches/tree-conflicts-notify:873926-874008 /subversion/branches/uris-as-urls:1060426-1064427 -/subversion/trunk:1146013,1146121,1146219,1146222,1146274,1146492,1146555,1146606,1146620,1146684,1146781,1146832,1146834,1146870,1146899,1146904,1147293,1147299,1147309,1147882,1148071,1148083,1148094,1148131,1148374,1148424,1148566,1148588,1148652,1148662,1148699,1148853,1148877,1148882,1148936,1149103,1149105,1149135,1149141,1149160,1149228,1149240,1149343,1149371-1149372,1149377,1149398,1149401,1149539,1149572,1149627,1149675,1149701,1149713,1150242,1150254,1150260-1150261,1150266,1150302,1150327,1150344,1150368,1150372,1150441,1150506,1150812,1150853,1151036,1151177,1151610,1151854,1151906,1151911,1152129,1152140,1152189-1152190,1152267,1152282,1152286,1152726,1152809,1153138,1153141,1153416,1153540,1153566,1153799,1153807,1153968,1154009,1154023,1154115,1154119,1154121,1154144,1154155,1154159,1154165,1154215,1154225,1154273,1154278,1154379,1154382,1154461,1154717-1154718,1154733,1154908,1154982,1155015,1155044,1155124,1155131,1155160,1155313,1155334,1155391,1155404,115 6085,1156098,1156216,1156218,1156312,1156527,1156717,1156721,1156750,1156827,1156838,1157416,1158187,1158193-1158194,1158196,1158201,1158207,1158209-1158210,1158217,1158285,1158288,1158303,1158309,1158407,1158419,1158421,1158436,1158455,1158616-1158617,1158634,1158854,1158875,1158886,1158893,1158896,1158919,1158923-1158924,1158929,1158963,1159093,1159098,1159101,1159132,1159136,1159148,1159230,1159275,1159400,1159686,1159760,1159772,1160605,1160671,1160682,1160704-1160705,1160756,1161063,1161080,1161185,1161210,1161683,1161721,1162024,1162033,1162201,1162516,1162880,1162974,1162995,1163243,1163383,1163557,1163792,1163953,1164027,1164386,1164426,1164517,1164535,1164554,1164580,1164614,1164645,1164760,1164765,1166267,1166500,1166555,1166678,1167062,1167173,1167209,1167269,1167503,1167659,1167681,1169524,1169531,1169650,1171708,1173111,1173425,1173639,1174051,1174060,1174652,1174761,1174797-1174798,1174806,1175888,1176915,1176949,1177001,1177492,1177732,1178280,1178282,1178942, 1179680,1179767,1180154,1181090,1181110,1181155,1181215,1181609,1181666,1182115,1182527,1182771,1182904,1182909,1183054,1183263,1183347,1185222,1185242,1185280,1185282,1185730,1185738,1185746,1185763,1185768,1185886,1185911,1185918,1186059,1186092,1186101,1186107,1186109,1186121,1186231,1186240,1186422,1186434,1186732,1186755,1186784,1186815,1186928,1186944,1186981,1186983,1187311,1187676,1187695,1188609,1188774,1189190,1189261,1189395,1189580,1189665,1197135,1197998,1199876,1199950,1200837,1201002,1201824,1202135,1202187,1202630,1202807,1203546,1203651,1203653,1204167,1204478,1204610,1204673,1205193,1205726,1206523,1206533,1206576,1206718-1206719,1206724,1206741,1206748 +/subversion/trunk:1146013,1146121,1146219,1146222,1146274,1146492,1146555,1146606,1146620,1146684,1146781,1146832,1146834,1146870,1146899,1146904,1147293,1147299,1147309,1147882,1148071,1148083,1148094,1148131,1148374,1148424,1148566,1148588,1148652,1148662,1148699,1148853,1148877,1148882,1148936,1149103,1149105,1149135,1149141,1149160,1149228,1149240,1149343,1149371-1149372,1149377,1149398,1149401,1149539,1149572,1149627,1149675,1149701,1149713,1150242,1150254,1150260-1150261,1150266,1150302,1150327,1150344,1150368,1150372,1150441,1150506,1150812,1150853,1151036,1151177,1151610,1151854,1151906,1151911,1152129,1152140,1152189-1152190,1152267,1152282,1152286,1152726,1152809,1153138,1153141,1153416,1153540,1153566,1153799,1153807,1153968,1154009,1154023,1154115,1154119,1154121,1154144,1154155,1154159,1154165,1154215,1154225,1154273,1154278,1154379,1154382,1154461,1154717-1154718,1154733,1154908,1154982,1155015,1155044,1155124,1155131,1155160,1155313,1155334,1155391,1155404,115 6085,1156098,1156216,1156218,1156312,1156527,1156717,1156721,1156750,1156827,1156838,1157416,1158187,1158193-1158194,1158196,1158201,1158207,1158209-1158210,1158217,1158285,1158288,1158303,1158309,1158407,1158419,1158421,1158436,1158455,1158616-1158617,1158634,1158854,1158875,1158886,1158893,1158896,1158919,1158923-1158924,1158929,1158963,1159093,1159098,1159101,1159132,1159136,1159148,1159230,1159275,1159400,1159686,1159760,1159772,1160605,1160671,1160682,1160704-1160705,1160756,1161063,1161080,1161185,1161210,1161683,1161721,1162024,1162033,1162201,1162516,1162880,1162974,1162995,1163243,1163383,1163557,1163792,1163953,1164027,1164386,1164426,1164517,1164535,1164554,1164580,1164614,1164645,1164760,1164765,1166267,1166500,1166555,1166678,1167062,1167173,1167209,1167269,1167503,1167659,1167681,1169524,1169531,1169650,1171708,1173111,1173425,1173639,1174051,1174060,1174652,1174761,1174797-1174798,1174806,1175888,1176915,1176949,1177001,1177492,1177732,1178280,1178282,1178942, 1179680,1179767,1180154,1181090,1181110,1181155,1181215,1181609,1181666,1182115,1182527,1182771,1182904,1182909,1183054,1183263,1183347,1185222,1185242,1185280,1185282,1185730,1185738,1185746,1185763,1185768,1185886,1185911,1185918,1186059,1186092,1186101,1186107,1186109,1186121,1186231,1186240,1186422,1186434,1186732,1186755,1186784,1186815,1186928,1186944,1186981,1186983,1187311,1187676,1187695,1188609,1188774,1189190,1189261,1189395,1189580,1189665,1197135,1197998,1199876,1199950,1200837,1201002,1201824,1202135,1202187,1202630,1202807,1203546,1203651,1203653,1204167,1204478,1204610,1204673,1205193,1205726,1206523,1206533,1206576,1206718-1206719,1206724,1206741,1206748,1207656,1207663 Modified: subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/libsvn_diff/parse-diff.c URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/libsvn_diff/parse-diff.c?rev=1207668&r1=1207667&r2=1207668&view=diff ============================================================================== --- subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/libsvn_diff/parse-diff.c (original) +++ subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/libsvn_diff/parse-diff.c Mon Nov 28 22:39:59 2011 @@ -589,11 +589,19 @@ parse_next_hunk(svn_diff_hunk_t **hunk, svn_boolean_t eof, in_hunk, hunk_seen; apr_off_t pos, last_line; apr_off_t start, end; + apr_off_t original_end; + apr_off_t modified_end; svn_linenum_t original_lines; svn_linenum_t modified_lines; svn_linenum_t leading_context; svn_linenum_t trailing_context; svn_boolean_t changed_line_seen; + enum { + noise_line, + original_line, + modified_line, + context_line + } last_line_type; apr_pool_t *iterpool; *prop_operation = svn_diff_op_unchanged; @@ -614,12 +622,17 @@ parse_next_hunk(svn_diff_hunk_t **hunk, leading_context = 0; trailing_context = 0; changed_line_seen = FALSE; + original_end = 0; + modified_end = 0; *hunk = apr_pcalloc(result_pool, sizeof(**hunk)); /* Get current seek position -- APR has no ftell() :( */ pos = 0; SVN_ERR(svn_io_file_seek(apr_file, APR_CUR, &pos, scratch_pool)); + /* Start out assuming noise. */ + last_line_type = noise_line; + iterpool = svn_pool_create(scratch_pool); do { @@ -640,14 +653,15 @@ parse_next_hunk(svn_diff_hunk_t **hunk, if (line->data[0] == '\\') { if (in_hunk && - ((!is_property && + ((!*is_property && strcmp(line->data, "\\ No newline at end of file") == 0) || - (is_property && + (*is_property && strcmp(line->data, "\\ No newline at end of property") == 0))) { char eolbuf[2]; apr_size_t len; apr_off_t off; + apr_off_t hunk_text_end; /* Comment terminates the hunk text and says the hunk text * has no trailing EOL. Snip off trailing EOL which is part @@ -658,14 +672,26 @@ parse_next_hunk(svn_diff_hunk_t **hunk, 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; + hunk_text_end = last_line - 2; + else if (eolbuf[1] == '\n' || eolbuf[1] == '\r') + hunk_text_end = last_line - 1; else - end = last_line; - break; + hunk_text_end = last_line; + + if (last_line_type == original_line && original_end == 0) + original_end = hunk_text_end; + else if (last_line_type == modified_line && modified_end == 0) + modified_end = hunk_text_end; + else if (last_line_type == context_line) + { + if (original_end == 0) + original_end = hunk_text_end; + if (modified_end == 0) + modified_end = hunk_text_end; + break; + } + + SVN_ERR(svn_io_file_seek(apr_file, APR_SET, &pos, iterpool)); } continue; @@ -700,6 +726,7 @@ parse_next_hunk(svn_diff_hunk_t **hunk, trailing_context++; else leading_context++; + last_line_type = context_line; } else if (original_lines > 0 && c == del) { @@ -713,6 +740,7 @@ parse_next_hunk(svn_diff_hunk_t **hunk, trailing_context = 0; original_lines--; + last_line_type = original_line; } else if (modified_lines > 0 && c == add) { @@ -726,6 +754,7 @@ parse_next_hunk(svn_diff_hunk_t **hunk, trailing_context = 0; modified_lines--; + last_line_type = modified_line; } else { @@ -741,6 +770,10 @@ parse_next_hunk(svn_diff_hunk_t **hunk, end = last_line; } + if (original_end == 0) + original_end = end; + if (modified_end == 0) + modified_end = end; break; /* Hunk was empty or has been read. */ } } @@ -820,10 +853,10 @@ parse_next_hunk(svn_diff_hunk_t **hunk, (*hunk)->diff_text_range.end = end; (*hunk)->original_text_range.start = start; (*hunk)->original_text_range.current = start; - (*hunk)->original_text_range.end = end; + (*hunk)->original_text_range.end = original_end; (*hunk)->modified_text_range.start = start; (*hunk)->modified_text_range.current = start; - (*hunk)->modified_text_range.end = end; + (*hunk)->modified_text_range.end = modified_end; } else /* Something went wrong, just discard the result. */ Modified: subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/tests/cmdline/patch_tests.py URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/tests/cmdline/patch_tests.py?rev=1207668&r1=1207667&r2=1207668&view=diff ============================================================================== --- subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/tests/cmdline/patch_tests.py (original) +++ subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/tests/cmdline/patch_tests.py Mon Nov 28 22:39:59 2011 @@ -3857,6 +3857,63 @@ def patch_lacking_trailing_eol(sbox): 1, # check-props 1) # dry-run +def patch_target_no_eol_at_eof(sbox): + "patch target with no eol at eof" + + sbox.build() + wc_dir = sbox.wc_dir + + patch_file_path = make_patch_path(sbox) + iota_path = os.path.join(wc_dir, 'iota') + + iota_contents = [ + "This is the file iota." + ] + + svntest.main.file_write(iota_path, ''.join(iota_contents)) + expected_output = svntest.wc.State(wc_dir, { + 'iota' : Item(verb='Sending'), + }) + expected_status = svntest.actions.get_virginal_state(wc_dir, 1) + expected_status.tweak('iota', wc_rev=2) + svntest.actions.run_and_verify_commit(wc_dir, expected_output, + expected_status, None, wc_dir) + unidiff_patch = [ + "--- iota\t(revision 1)\n", + "+++ iota\t(working copy)\n", + "@@ -1,7 +1,7 @@\n", + "-This is the file iota.\n" + "\\ No newline at end of file\n", + "+It is the file 'iota'.\n", + "\\ No newline at end of file\n", + ] + + svntest.main.file_write(patch_file_path, ''.join(unidiff_patch)) + + iota_contents = [ + "It is the file 'iota'." + ] + expected_output = [ + 'U %s\n' % os.path.join(wc_dir, 'iota'), + ] + + expected_disk = svntest.main.greek_state.copy() + expected_disk.tweak('iota', contents=''.join(iota_contents)) + + expected_status = svntest.actions.get_virginal_state(wc_dir, 1) + expected_status.tweak('iota', status='M ', wc_rev=2) + + expected_skip = wc.State('', { }) + + svntest.actions.run_and_verify_patch(wc_dir, os.path.abspath(patch_file_path), + expected_output, + expected_disk, + expected_status, + expected_skip, + None, # expected err + 1, # check-props + 1) # dry-run + ######################################################################## #Run the tests @@ -3898,6 +3955,7 @@ test_list = [ None, patch_dev_null, patch_delete_and_skip, patch_lacking_trailing_eol, + patch_target_no_eol_at_eof, ] if __name__ == '__main__':