Author: stsp
Date: Wed Oct 17 10:54:32 2012
New Revision: 1399174

URL: http://svn.apache.org/viewvc?rev=1399174&view=rev
Log:
Fix a diff parser bug where hunks are ignored if a context line is followed
by a "\ No newline at end of file." message.

Reported by: Christian Zangl

* subversion/libsvn_diff/parse-diff.c
  (parse_next_hunk): Don't exit parsing loop early upon seeing a
   "\ No newline at end of file" message after a hunk context line.
   We must treat this situation the same as when an original or modified
   line precedes the "\ No newline at end of file" message.

* subversion/tests/cmdline/patch_tests.py
  (patch_target_no_eol_at_eof): Extend this test to cover the case where a
   "\ No newline at end of file" message appears after a context line.
   This bug slipped through because we only tested the cases where an
   original or modified line precedes "\ No newline at end of file".

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=1399174&r1=1399173&r2=1399174&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Wed Oct 17 10:54:32 
2012
@@ -595,7 +595,6 @@ parse_next_hunk(svn_diff_hunk_t **hunk,
                     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));

Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1399174&r1=1399173&r2=1399174&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Wed Oct 17 
10:54:32 2012
@@ -3997,24 +3997,57 @@ def patch_target_no_eol_at_eof(sbox):
 
   patch_file_path = make_patch_path(sbox)
   iota_path = sbox.ospath('iota')
+  mu_path = sbox.ospath('A/mu')
 
   iota_contents = [
     "This is the file iota."
   ]
 
+  mu_contents = [
+    "context\n",
+    "context\n",
+    "context\n",
+    "context\n",
+    "This is the file mu.\n",
+    "context\n",
+    "context\n",
+    "context\n",
+    "context", # no newline at end of file
+  ]
+
   svntest.main.file_write(iota_path, ''.join(iota_contents))
+  svntest.main.file_write(mu_path, ''.join(mu_contents))
   expected_output = svntest.wc.State(wc_dir, {
     'iota'  : Item(verb='Sending'),
+    'A/mu'  : Item(verb='Sending'),
     })
   expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.tweak('iota', wc_rev=2)
+  expected_status.tweak('A/mu', 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",
+    "Index: A/mu\n",
+    "===================================================================\n",
+    "--- A/mu\t(revision 2)\n",
+    "+++ A/mu\t(working copy)\n",
+    "@@ -2,8 +2,8 @@ context\n",
+    " context\n",
+    " context\n",
+    " context\n",
+    "-This is the file mu.\n",
+    "+It is really the file mu.\n",
+    " context\n",
+    " context\n",
+    " context\n",
+    " context\n",
+    "\\ No newline at end of file\n",
+    "Index: iota\n",
+    "===================================================================\n",
+    "--- iota\t(revision 2)\n",
     "+++ iota\t(working copy)\n",
-    "@@ -1,7 +1,7 @@\n",
-    "-This is the file iota.\n"
+    "@@ -1 +1 @@\n",
+    "-This is the file iota.\n",
     "\\ No newline at end of file\n",
     "+It is really the file 'iota'.\n",
     "\\ No newline at end of file\n",
@@ -4025,15 +4058,29 @@ def patch_target_no_eol_at_eof(sbox):
   iota_contents = [
     "It is really the file 'iota'."
   ]
+  mu_contents = [
+    "context\n",
+    "context\n",
+    "context\n",
+    "context\n",
+    "It is really the file mu.\n",
+    "context\n",
+    "context\n",
+    "context\n",
+    "context", # no newline at end of file
+  ]
   expected_output = [
+    'U         %s\n' % sbox.ospath('A/mu'),
     'U         %s\n' % sbox.ospath('iota'),
   ]
 
   expected_disk = svntest.main.greek_state.copy()
   expected_disk.tweak('iota', contents=''.join(iota_contents))
+  expected_disk.tweak('A/mu', contents=''.join(mu_contents))
 
   expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.tweak('iota', status='M ', wc_rev=2)
+  expected_status.tweak('A/mu', status='M ', wc_rev=2)
 
   expected_skip = wc.State('', { })
 


Reply via email to