You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2015/09/24 17:29:12 UTC
svn commit: r1705080 - in /subversion/trunk/subversion:
libsvn_diff/parse-diff.c tests/cmdline/patch_tests.py
Author: rhuijben
Date: Thu Sep 24 15:29:11 2015
New Revision: 1705080
URL: http://svn.apache.org/viewvc?rev=1705080&view=rev
Log:
Following up on r1705038, also report missing final EOLs if the caller is not
interested in EOL details.
* subversion/libsvn_diff/parse-diff.c
(hunk_readline_original_or_modified): Always fetch eols. Only add an eol if
there is an actual line.
* subversion/tests/cmdline/patch_tests.py
(patch_delete_missing_eol): New test.
(test_list): Add test.
Modified:
subversion/trunk/subversion/libsvn_diff/parse-diff.c
subversion/trunk/subversion/tests/cmdline/patch_tests.py
Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=1705080&r1=1705079&r2=1705080&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Thu Sep 24 15:29:11 2015
@@ -536,13 +536,16 @@ hunk_readline_original_or_modified(apr_f
svn_boolean_t filtered;
apr_off_t pos;
svn_stringbuf_t *str;
+ const char *eol_p;
+
+ if (!eol)
+ eol = &eol_p;
if (range->current >= range->end)
{
/* We're past the range. Indicate that no bytes can be read. */
*eof = TRUE;
- if (eol)
- *eol = NULL;
+ *eol = NULL;
*stringbuf = svn_stringbuf_create_empty(result_pool);
return SVN_NO_ERROR;
}
@@ -565,6 +568,7 @@ hunk_readline_original_or_modified(apr_f
{
/* EOF, return an empty string. */
*stringbuf = svn_stringbuf_create_ensure(0, result_pool);
+ *eol = NULL;
}
else if (str->data[0] == '+' || str->data[0] == '-' || str->data[0] == ' ')
{
@@ -579,7 +583,7 @@ hunk_readline_original_or_modified(apr_f
if (!filtered)
{
- if (eol && *eof && !*eol && !no_final_eol)
+ if (*eof && !*eol && !no_final_eol && *str->data)
{
/* Ok, we miss a final EOL in the patch file, but didn't see a
no eol marker line.
@@ -598,8 +602,9 @@ hunk_readline_original_or_modified(apr_f
/* Every patch file that has hunks has at least one EOL*/
SVN_ERR_ASSERT(*eol != NULL);
*eol = apr_pstrdup(result_pool, *eol);
+ *eof = FALSE;
- /* Fall through to seek to the right location */
+ /* Fall through to seek back to the right location */
}
}
SVN_ERR(svn_io_file_seek(file, APR_SET, &pos, scratch_pool));
Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1705080&r1=1705079&r2=1705080&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Thu Sep 24 15:29:11 2015
@@ -5759,11 +5759,82 @@ def patch_delete_nodes(sbox):
status='A ', wc_rev='-',
entry_status='R ', entry_rev='2')
+
svntest.actions.run_and_verify_patch(wc_dir, patch,
expected_output, original_disk,
original_status, expected_skip,
[], True, True, '--reverse-diff')
+def patch_delete_missing_eol(sbox):
+ "apply a delete missing an eol"
+
+ sbox.build(read_only = True)
+ wc_dir = sbox.wc_dir
+
+ delete_patch = [
+ "Index: A/B/E/beta\n",
+ "===================================================================\n",
+ "--- A/B/E/beta (revision 1)\n",
+ "+++ /dev/null\n",
+ "@@ -1 +0,0 @@\n",
+ "-This is the file 'beta'." # No final EOL
+ ]
+
+ patch = sbox.get_tempname('patch')
+ svntest.main.file_write(patch, ''.join(delete_patch))
+
+ expected_output = wc.State(wc_dir, {
+ 'A/B/E/beta' : Item(status='D '),
+ })
+ expected_skip = wc.State(wc_dir, {
+ })
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+ expected_status.tweak('A/B/E/beta', status='D ')
+ expected_disk = svntest.main.greek_state.copy()
+ expected_disk.remove('A/B/E/beta')
+
+ svntest.actions.run_and_verify_patch(wc_dir, patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], False, True)
+
+ # Try again? -> Skip... Why not some already applied notification?
+ # -> There is nothing to compare to
+ expected_output = wc.State(wc_dir, {
+ })
+ expected_skip = wc.State(wc_dir, {
+ 'A/B/E/beta' : Item(verb='Skipped'),
+ })
+ svntest.actions.run_and_verify_patch(wc_dir, patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], False, True)
+
+ # Reverse
+ expected_output = wc.State(wc_dir, {
+ 'A/B/E/beta' : Item(status='A '),
+ })
+ expected_skip = wc.State(wc_dir, {
+ })
+ expected_disk = svntest.main.greek_state.copy()
+ expected_status.tweak('A/B/E/beta', status='R ')
+ svntest.actions.run_and_verify_patch(wc_dir, patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], False, True, '--reverse-diff')
+
+ # Try again? -> Already applied
+ expected_output = wc.State(wc_dir, {
+ 'A/B/E/beta' : Item(status='G '),
+ })
+ expected_skip = wc.State(wc_dir, {
+ })
+ svntest.actions.run_and_verify_patch(wc_dir, patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], False, True, '--reverse-diff')
+
+
########################################################################
#Run the tests
@@ -5827,6 +5898,7 @@ test_list = [ None,
patch_obstructing_symlink_traversal,
patch_binary_file,
patch_delete_nodes,
+ patch_delete_missing_eol,
]
if __name__ == '__main__':