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/30 17:12:44 UTC

svn commit: r1706052 - /subversion/trunk/subversion/libsvn_client/patch.c

Author: rhuijben
Date: Wed Sep 30 15:12:44 2015
New Revision: 1706052

URL: http://svn.apache.org/viewvc?rev=1706052&view=rev
Log:
Following up on r1704632, r1705692 and r1706049 make svn patch properly
detect that a binary file patch has already been applied. This matches
the behavior of unified diff patches.

* subversion/libsvn_client/patch.c
  (apply_one_patch): If not equal to the original version, compare with
    the final version.

Modified:
    subversion/trunk/subversion/libsvn_client/patch.c

Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=1706052&r1=1706051&r2=1706052&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Wed Sep 30 15:12:44 2015
@@ -2490,6 +2490,37 @@ apply_one_patch(patch_target_t **patch_t
              the patch... So we can write the result stream; no fuzz,
              just a 100% match */
 
+          has_text_changes = TRUE;
+          target->has_text_changes = TRUE;
+        }
+      else
+        {
+          /* Perhaps the file is identical to the resulting version, implying
+             that the patch has already been applied */
+          if (target->file)
+            {
+              apr_off_t start = 0;
+
+              SVN_ERR(svn_io_file_seek(target->file, APR_SET, &start, iterpool));
+
+              orig_stream = svn_stream_from_aprfile2(target->file, TRUE, iterpool);
+            }
+          else
+            orig_stream = svn_stream_empty(iterpool);
+
+          SVN_ERR(svn_stream_contents_same2(
+                    &same, orig_stream,
+                    svn_diff_get_binary_diff_result_stream(patch->binary_patch,
+                                                           iterpool),
+                    iterpool));
+          svn_pool_clear(iterpool);
+
+          if (same)
+            target->had_already_applied = TRUE;
+        }
+
+      if (same)
+        {
           SVN_ERR(svn_stream_copy3(
                 svn_diff_get_binary_diff_result_stream(patch->binary_patch,
                                                        iterpool),
@@ -2497,9 +2528,6 @@ apply_one_patch(patch_target_t **patch_t
                                          iterpool),
                 cancel_func, cancel_baton,
                 iterpool));
-
-          has_text_changes = TRUE;
-          target->has_text_changes = TRUE;
         }
       else
         {