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:59:36 UTC
svn commit: r1704632 - in /subversion/trunk/subversion:
libsvn_client/patch.c tests/cmdline/patch_tests.py
Author: rhuijben
Date: Tue Sep 22 13:59:33 2015
New Revision: 1704632
URL: http://svn.apache.org/viewvc?rev=1704632&view=rev
Log:
Following up on r1704616, make the binary patch code work in case the
in-workingcopy is a 100% match of the expected file. This leaves the
case where the file is not a match for a future patch.
* subversion/libsvn_client/patch.c
(apply_one_patch): Compare file to expected file and create result file
if the files match.
* subversion/tests/cmdline/patch_tests.py
(patch_binary_file): Remove XFail. Extend test.
Modified:
subversion/trunk/subversion/libsvn_client/patch.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=1704632&r1=1704631&r2=1704632&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Tue Sep 22 13:59:33 2015
@@ -2368,32 +2368,49 @@ apply_one_patch(patch_target_t **patch_t
}
else if (patch->binary_patch)
{
-#ifdef SVN_DEBUG
- svn_stream_t *tmp;
+ svn_stream_t *orig_stream;
+ svn_boolean_t same;
- /* ### Dummy code that just reads the two streams in the patch file */
- tmp = svn_diff_get_binary_diff_result_stream(patch->binary_patch,
- iterpool);
-
- SVN_ERR(svn_stream_copy3(tmp, svn_stream_empty(iterpool),
- NULL, NULL,
- iterpool));
-
- tmp = svn_diff_get_binary_diff_original_stream(patch->binary_patch,
- iterpool);
-
- SVN_ERR(svn_stream_copy3(tmp, svn_stream_empty(iterpool),
- NULL, NULL,
- iterpool));
-
- /* ### TODO:
- - write the patched version and set has_text_changes = TRUE;
- - or: write+notify rejection
- - or: set skip (which also skips property changes)
-
- Doing nothing just ignores the patchset (<= 1.9.x behaviour)
- */
-#endif
+ if (target->file)
+ 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_original_stream(patch->binary_patch,
+ iterpool),
+ iterpool));
+ svn_pool_clear(iterpool);
+
+ if (same)
+ {
+ /* The file in the working copy is identical to the one expected by
+ the patch... So we can write the result stream; no fuzz,
+ just a 100% match */
+
+ SVN_ERR(svn_stream_copy3(
+ svn_diff_get_binary_diff_result_stream(patch->binary_patch,
+ iterpool),
+ svn_stream_from_aprfile2(target->patched_file, TRUE,
+ iterpool),
+ cancel_func, cancel_baton,
+ iterpool));
+
+ has_text_changes = TRUE;
+ target->has_text_changes = TRUE;
+ }
+ else
+ {
+ /* ### TODO: Implement a proper reject of a binary patch
+
+ This should at least setup things for a proper notification,
+ and perhaps install a normal text conflict. Unlike normal unified
+ diff based patches we have all the versions we would need for
+ that in a much easier format than can be obtained from the patch
+ file. */
+ target->skipped = TRUE;
+ }
}
else if (target->move_target_abspath)
{
Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1704632&r1=1704631&r2=1704632&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Tue Sep 22 13:59:33 2015
@@ -5620,7 +5620,6 @@ def patch_obstructing_symlink_traversal(
expected_output, expected_disk,
expected_status, expected_skip)
-@XFail()
def patch_binary_file(sbox):
"patch a binary file"
@@ -5664,14 +5663,29 @@ def patch_binary_file(sbox):
expected_output = wc.State(wc_dir, {
'iota' : Item(status='UU'),
})
- expected_disk = None
+ expected_disk = svntest.main.greek_state.copy()
+ expected_disk.tweak('iota',
+ props={'svn:mime-type':'application/binary'},
+ contents =
+ 'This is the file \'iota\'.\n'
+ '\0\202\203\204\205\206\207nsomething\nelse\xFF')
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('iota', status='MM')
expected_skip = wc.State('', { })
svntest.actions.run_and_verify_patch(wc_dir, tmp,
expected_output, expected_disk,
- expected_status, expected_skip)
+ expected_status, expected_skip,
+ [], True, True)
+
+ # Ok, now try applying it backwards
+ expected_output.tweak('iota', status='GU')
+ expected_disk = svntest.main.greek_state.copy()
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+ svntest.actions.run_and_verify_patch(wc_dir, tmp,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], False, True, '--reverse-diff')
########################################################################