You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/01/26 18:17:53 UTC

svn commit: r903325 - in /subversion/trunk/subversion: libsvn_client/patch.c svn/notify.c tests/cmdline/patch_tests.py

Author: stsp
Date: Tue Jan 26 17:17:53 2010
New Revision: 903325

URL: http://svn.apache.org/viewvc?rev=903325&view=rev
Log:
Fix regressions in svn patch's handling of rejected hunks and
of notifications. Also add a regression test for hunk rejection.

* subversion/libsvn_client/patch.c
  (apply_one_patch): Really push all hunks onto TARGET->HUNKS,
   even if they will be rejected. Also, don't create reject
   files during a dry run.

* subversion/svn/notify.c
  (notify): Show the same status letters for svn_wc_notify_patch
   as we do for svn_wc_notify_update_update, not just 'U'.
   Also, count text conflicts again.

* subversion/tests/cmdline/patch_tests.py
  (patch_unidiff_reject): New test.
  (test_list): Add new test.

Modified:
    subversion/trunk/subversion/libsvn_client/patch.c
    subversion/trunk/subversion/svn/notify.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=903325&r1=903324&r2=903325&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Tue Jan 26 17:17:53 2010
@@ -973,8 +973,7 @@
           /* The hunk does not apply, reject it. */
           SVN_ERR(reject_hunk(target, hi, iterpool));
         }
-      else
-        APR_ARRAY_PUSH(target->hunks, hunk_info_t *) = hi;
+      APR_ARRAY_PUSH(target->hunks, hunk_info_t *) = hi;
     }
 
   /* Apply hunks. */
@@ -1214,8 +1213,9 @@
         }
 
     }
+
   /* Write out rejected hunks, if any. */
-  if (! target->skipped && target->had_rejects)
+  if (! dry_run && ! target->skipped && target->had_rejects)
     {
       SVN_ERR(svn_io_copy_file(target->reject_path,
                                apr_psprintf(pool, "%s.svnpatch.rej",

Modified: subversion/trunk/subversion/svn/notify.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/notify.c?rev=903325&r1=903324&r2=903325&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/notify.c (original)
+++ subversion/trunk/subversion/svn/notify.c Tue Jan 26 17:17:53 2010
@@ -282,10 +282,29 @@
       break;
 
     case svn_wc_notify_patch:
-      nb->received_some_change = TRUE;
-      if ((err = svn_cmdline_printf(pool, "U         %s\n",
-                                    path_local)))
-        goto print_error;
+      {
+        nb->received_some_change = TRUE;
+        if (n->content_state == svn_wc_notify_state_conflicted)
+          {
+            nb->in_external ? nb->ext_text_conflicts++
+                            : nb->text_conflicts++;
+            statchar_buf[0] = 'C';
+          }
+        else if (n->kind == svn_node_file)
+          {
+            if (n->content_state == svn_wc_notify_state_merged)
+              statchar_buf[0] = 'G';
+            else if (n->content_state == svn_wc_notify_state_changed)
+              statchar_buf[0] = 'U';
+          }
+
+        if (statchar_buf[0] != ' ')
+          {
+            if ((err = svn_cmdline_printf(pool, "%s      %s\n",
+                                          statchar_buf, path_local)))
+              goto print_error;
+          }
+      }
       break;
 
     case svn_wc_notify_patch_applied_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=903325&r1=903324&r2=903325&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Tue Jan 26 17:17:53 2010
@@ -898,6 +898,76 @@
                                        1, # check-props
                                        1) # dry-run
 
+def patch_unidiff_reject(sbox):
+  "apply a unidiff patch which is rejected"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  # Set gamma contents
+  gamma_contents = "Hello there! I'm the file 'gamma'.\n"
+  gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
+  svntest.main.file_write(gamma_path, gamma_contents)
+  expected_output = svntest.wc.State(wc_dir, {
+    'A/D/gamma'       : Item(verb='Sending'),
+    })
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.tweak('A/D/gamma', wc_rev=2)
+  svntest.actions.run_and_verify_commit(wc_dir, expected_output,
+                                        expected_status, None, wc_dir)
+
+  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+
+  # Apply patch
+
+  unidiff_patch = [
+    "Index: A/D/gamma\n",
+    "===================================================================\n",
+    "--- A/D/gamma\t(revision 1)\n",
+    "+++ A/D/gamma\t(working copy)\n",
+    "@@ -1 +1 @@\n",
+    "-This is really the file 'gamma'.\n",
+    "+It is really the file 'gamma'.\n",
+  ]
+
+  svntest.main.file_write(patch_file_path, ''.join(unidiff_patch))
+
+  expected_output = [
+    'C         %s\n' % os.path.join(wc_dir, 'A', 'D', 'gamma'),
+    '>         rejected hunk @@ -1,1 +1,1 @@\n',
+    'Summary of conflicts:\n',
+    '  Text conflicts: 1\n',
+  ]
+
+  expected_disk = svntest.main.greek_state.copy()
+  expected_disk.tweak('A/D/gamma', contents=gamma_contents)
+
+  reject_file_contents = [
+    "--- A/D/gamma\n",
+    "+++ A/D/gamma\n",
+    "@@ -1,1 +1,1 @@\n",
+    "-This is really the file 'gamma'.\n",
+    "+It is really the file 'gamma'.\n",
+  ]
+  expected_disk.add({'A/D/gamma.svnpatch.rej' :
+                     Item(contents=''.join(reject_file_contents))})
+
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.tweak('A/D/gamma', wc_rev=2)
+  # ### not yet
+  #expected_status.tweak('A/D/gamma', status='C ')
+
+  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
@@ -910,6 +980,7 @@
               patch_chopped_leading_spaces,
               patch_unidiff_strip1,
               patch_add_new_dir,
+              patch_unidiff_reject,
             ]
 
 if __name__ == '__main__':