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 16:49:26 UTC

svn commit: r1706049 - in /subversion/trunk/subversion: libsvn_diff/parse-diff.c tests/cmdline/patch_tests.py

Author: rhuijben
Date: Wed Sep 30 14:49:25 2015
New Revision: 1706049

URL: http://svn.apache.org/viewvc?rev=1706049&view=rev
Log:
Make it possible to possible to apply git style mode changes and binary file
patches at the same time.

The patch to parse-diff.c was provided by danielsh.

* subversion/libsvn_diff/parse-diff.c
  (transitions): Add transition to combine patch types.

* subversion/tests/cmdline/patch_tests.py
  (patch_add_remove_executable): New testcase for this (and another) issue.

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=1706049&r1=1706048&r2=1706049&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Wed Sep 30 14:49:25 2015
@@ -2043,6 +2043,7 @@ static struct transition transitions[] =
 
   {"GIT binary patch",  state_git_diff_seen,    binary_patch_start},
   {"GIT binary patch",  state_git_tree_seen,    binary_patch_start},
+  {"GIT binary patch",  state_git_mode_seen,    binary_patch_start},
 };
 
 svn_error_t *

Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1706049&r1=1706048&r2=1706049&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Wed Sep 30 14:49:25 2015
@@ -6572,6 +6572,107 @@ def patch_empty_vs_delete(sbox):
                                        [], True, True,
                                        '--reverse-diff')
 
+def patch_add_remove_executable(sbox):
+  "add and remove executable file"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  eicar_data = 'X5O!P%@AP[4\PZX54(P^)7CC)7}$' \
+               'EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*\0'
+  other_data = 'X5O!P%@AP[4\PZX54(P^)7CC)7}$' \
+               'SOME-LESS-INTERESTING-OTHER-TEXT!!!$H+H*\0'
+
+  # Write out an actual MS-DOS program
+  sbox.simple_add_text(eicar_data, 'eicar.com')
+  sbox.simple_propset('svn:executable', 'x', 'eicar.com')
+
+  _, diff_add, _ = svntest.actions.run_and_verify_svn(None, [],
+                                                      'diff', '--git', wc_dir)
+
+  sbox.simple_commit()
+
+  sbox.simple_append('eicar.com', other_data, truncate=True)
+  sbox.simple_propdel('svn:executable', 'eicar.com')
+
+  _, diff_edit, _ = svntest.actions.run_and_verify_svn(None, [],
+                                                       'diff', '--git', wc_dir)
+
+  sbox.simple_commit()
+  sbox.simple_rm('eicar.com')
+
+  _, diff_rm, _ = svntest.actions.run_and_verify_svn(None, [],
+                                                     'diff', '--git', wc_dir)
+
+  add_patch = sbox.get_tempname('add.patch')
+  svntest.main.file_write(add_patch, ''.join(diff_add), mode='wb')
+
+  edit_patch = sbox.get_tempname('edit.patch')
+  svntest.main.file_write(edit_patch, ''.join(diff_edit), mode='wb')
+
+  rm_patch = sbox.get_tempname('rm.patch')
+  svntest.main.file_write(rm_patch, ''.join(diff_rm), mode='wb')
+
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.add({
+    'eicar.com' : Item(status='RM', wc_rev=3)
+  })
+  expected_output = svntest.wc.State(wc_dir, {
+    'eicar.com' : Item(status='A ')
+  })
+  expected_disk = svntest.main.greek_state.copy()
+  expected_disk.add({
+    'eicar.com' : Item(contents=eicar_data,
+                       props={'svn:mime-type': 'application/octet-stream',
+                              'svn:executable': '*'}),
+  })
+  expected_skip = svntest.wc.State(wc_dir, {})
+  svntest.actions.run_and_verify_patch(wc_dir, add_patch,
+                                       expected_output, expected_disk,
+                                       expected_status, expected_skip,
+                                       [], True, True)
+
+  # And repeat
+  expected_output.tweak('eicar.com', status='GG')
+  #svntest.actions.run_and_verify_patch(wc_dir, add_patch,
+  #                                     expected_output, expected_disk,
+  #                                     expected_status, expected_skip,
+  #                                     [], True, True)
+
+  # Now apply the edit
+  expected_output.tweak('eicar.com', status='GU')
+  expected_disk.tweak('eicar.com',
+                      props={'svn:mime-type': 'application/octet-stream'},
+                      contents=other_data)
+  svntest.actions.run_and_verify_patch(wc_dir, edit_patch,
+                                       expected_output, expected_disk,
+                                       expected_status, expected_skip,
+                                       [], True, True)
+
+  # And repeat
+  expected_output.tweak('eicar.com', status='GG')
+  #svntest.actions.run_and_verify_patch(wc_dir, edit_patch,
+  #                                     expected_output, expected_disk,
+  #                                     expected_status, expected_skip,
+  #                                     [], True, True)
+
+  # Now apply the edit
+  expected_output.tweak('eicar.com', status='D ')
+  expected_disk.remove('eicar.com')
+  expected_status.tweak('eicar.com', status='D ')
+  svntest.actions.run_and_verify_patch(wc_dir, rm_patch,
+                                       expected_output, expected_disk,
+                                       expected_status, expected_skip,
+                                       [], True, True)
+
+  # And repeat
+  expected_output.tweak('eicar.com', status='G ')
+  #svntest.actions.run_and_verify_patch(wc_dir, rm_patch,
+  #                                     expected_output, expected_disk,
+  #                                     expected_status, expected_skip,
+  #                                     [], True, True)
+
+
 ########################################################################
 #Run the tests
 
@@ -6645,6 +6746,7 @@ test_list = [ None,
               patch_ambiguous_executability_consistent,
               patch_prop_madness,
               patch_empty_vs_delete,
+              patch_add_remove_executable,
             ]
 
 if __name__ == '__main__':



Re: svn commit: r1706049 - in /subversion/trunk/subversion: libsvn_diff/parse-diff.c tests/cmdline/patch_tests.py

Posted by Ivan Zhakov <iv...@visualsvn.com>.
On 30 September 2015 at 17:49,  <rh...@apache.org> wrote:
> Author: rhuijben
> Date: Wed Sep 30 14:49:25 2015
> New Revision: 1706049
>
> URL: http://svn.apache.org/viewvc?rev=1706049&view=rev
> Log:
> Make it possible to possible to apply git style mode changes and binary file
> patches at the same time.
>
[...]
>
> Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1706049&r1=1706048&r2=1706049&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
> +++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Wed Sep 30 14:49:25 2015
> @@ -6572,6 +6572,107 @@ def patch_empty_vs_delete(sbox):
>                                         [], True, True,
>                                         '--reverse-diff')
>
> +def patch_add_remove_executable(sbox):
> +  "add and remove executable file"
> +
> +  sbox.build()
> +  wc_dir = sbox.wc_dir
> +
> +  eicar_data = 'X5O!P%@AP[4\PZX54(P^)7CC)7}$' \
> +               'EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*\0'
> +  other_data = 'X5O!P%@AP[4\PZX54(P^)7CC)7}$' \
> +               'SOME-LESS-INTERESTING-OTHER-TEXT!!!$H+H*\0'
> +
Hi Bert,

This test fails for me on Windows 10 with Windows defender enabled
with error like this:
[[[
W: svn: E720225: Can't open file
'C:\Users\ivan.OSTYSERVER\AppData\Local\Temp\svn-test-trunk-http\subversion\tests\cmdline\svn-test-work\working_copies\patch_tests-69\eicar.com':
Operation did not complete successfully because the file contains a
virus or potentially unwanted software.
]]]

The file is recognized as virus since it's special test file for
antivirus testing and blocks access to it. Do we really need using
eicar.com in this test case?

-- 
Ivan Zhakov