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/22 15:10:52 UTC

svn commit: r1704616 - /subversion/trunk/subversion/libsvn_diff/parse-diff.c

Author: rhuijben
Date: Tue Sep 22 13:10:49 2015
New Revision: 1704616

URL: http://svn.apache.org/viewvc?rev=1704616&view=rev
Log:
In the diff parser: apply the reverse flag even for binary diffs.

* subversion/libsvn_diff/parse-diff.c
  (parse_binary_patch): Add reverse argument and use it to reverse
    offsets when requested.
  (svn_diff_parse_next_patch): Update caller.

Modified:
    subversion/trunk/subversion/libsvn_diff/parse-diff.c

Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=1704616&r1=1704615&r2=1704616&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Tue Sep 22 13:10:49 2015
@@ -1594,6 +1594,7 @@ parse_hunks(svn_patch_t *patch, apr_file
 
 static svn_error_t *
 parse_binary_patch(svn_patch_t *patch, apr_file_t *apr_file,
+                   svn_boolean_t reverse,
                    apr_pool_t *result_pool, apr_pool_t *scratch_pool)
 {
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
@@ -1694,6 +1695,22 @@ parse_binary_patch(svn_patch_t *patch, a
       patch->binary_patch = bpatch; /* SUCCESS */
     }
 
+  /* Reverse patch if requested */
+  if (reverse && patch->binary_patch)
+    {
+      apr_off_t tmp_start = bpatch->src_start;
+      apr_off_t tmp_end = bpatch->src_end;
+      svn_filesize_t tmp_filesize = bpatch->src_filesize;
+
+      bpatch->src_start = bpatch->dst_start;
+      bpatch->src_end = bpatch->dst_end;
+      bpatch->src_filesize = bpatch->dst_filesize;
+
+      bpatch->dst_start = tmp_start;
+      bpatch->dst_end = tmp_end;
+      bpatch->dst_filesize = tmp_filesize;
+    }
+
   return SVN_NO_ERROR;
 }
 
@@ -1845,7 +1862,7 @@ svn_diff_parse_next_patch(svn_patch_t **
     {
       if (state == state_binary_patch_found)
         {
-          SVN_ERR(parse_binary_patch(patch, patch_file->apr_file,
+          SVN_ERR(parse_binary_patch(patch, patch_file->apr_file, reverse,
                                      result_pool, iterpool));
           /* And fall through in property parsing */
         }