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/10/02 20:20:56 UTC
svn commit: r1706460 - in /subversion/trunk/subversion:
libsvn_client/patch.c tests/cmdline/patch_tests.py
Author: rhuijben
Date: Fri Oct 2 18:20:55 2015
New Revision: 1706460
URL: http://svn.apache.org/viewvc?rev=1706460&view=rev
Log:
Following up on r1706446, improve calculation on when a symlink was
transformed into a file.
* subversion/libsvn_client/patch.c
(apply_one_patch): Don't assume that the presence of a SVN_PROP_SPECIAL
hunk implies that the resulting node is a symlink.
(install_patched_target): Just check for is_special, to allow changing type.
* subversion/tests/cmdline/patch_tests.py
(patch_symlink_madness): New test.
(test_list): Add patch_symlink_madness.
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=1706460&r1=1706459&r2=1706460&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Fri Oct 2 18:20:55 2015
@@ -2597,6 +2597,9 @@ apply_one_patch(patch_target_t **patch_t
}
}
+ /* Assume nothing changed. Will be updated via property hunks */
+ target->is_special = target->is_symlink;
+
/* Match property hunks. */
for (hash_index = apr_hash_first(scratch_pool, patch->prop_patches);
hash_index;
@@ -2609,8 +2612,8 @@ apply_one_patch(patch_target_t **patch_t
prop_name = apr_hash_this_key(hash_index);
prop_patch = apr_hash_this_val(hash_index);
- if (! strcmp(prop_name, SVN_PROP_SPECIAL))
- target->is_special = TRUE;
+ if (!strcmp(prop_name, SVN_PROP_SPECIAL))
+ target->is_special = (prop_patch->operation != svn_diff_op_deleted);
/* We'll store matched hunks in prop_content. */
prop_target = svn_hash_gets(target->prop_targets, prop_name);
@@ -2704,12 +2707,15 @@ apply_one_patch(patch_target_t **patch_t
target->is_special = TRUE;
}
else
- SVN_ERR(svn_diff_hunk__create_deletes_single_line(
+ {
+ SVN_ERR(svn_diff_hunk__create_deletes_single_line(
&hunk,
SVN_PROP_SPECIAL_VALUE,
patch,
result_pool,
iterpool));
+ target->is_special = FALSE;
+ }
/* Derive a hunk_info from hunk. */
SVN_ERR(get_hunk_info(&hi, target, prop_target->content,
@@ -3133,8 +3139,7 @@ install_patched_target(patch_target_t *t
if (! dry_run && ! target->skipped)
{
- /* ### Are these properly reset? */
- if (target->is_special || target->is_symlink)
+ if (target->is_special)
{
svn_stream_t *stream;
svn_stream_t *patched_stream;
Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1706460&r1=1706459&r2=1706460&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Fri Oct 2 18:20:55 2015
@@ -6938,7 +6938,6 @@ def patch_like_git_symlink(sbox):
to_file_patch = sbox.get_tempname('to_file.patch')
svntest.main.file_write(to_file_patch, ''.join(patch_to_file), mode='wb')
-
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
'link-to-iota' : Item(status='A ', wc_rev='-'),
@@ -7000,6 +6999,127 @@ def patch_like_git_symlink(sbox):
expected_status, expected_skip,
[], True, True)
+def patch_symlink_madness(sbox):
+ "patch symlink madness"
+
+ sbox.build()
+ wc_dir = sbox.wc_dir
+ strip_count = wc_dir.count(os.path.sep)+1
+
+ os.remove(sbox.ospath('iota'))
+ sbox.simple_symlink('A/B/E/beta', 'iota')
+ sbox.simple_propset('svn:special', 'X', 'iota')
+
+ _, diff_tolink, _ = svntest.actions.run_and_verify_svn(None, [],
+ 'diff', wc_dir)
+
+ _, git_tolink, _ = svntest.actions.run_and_verify_svn(None, [],
+ 'diff', wc_dir, '--git')
+
+ sbox.simple_commit()
+
+ #os.remove(sbox.ospath('iota'))
+ #sbox.simple_symlink('A/B/E/alpha', 'iota')
+ #
+ #_, diff_changelink, _ = svntest.actions.run_and_verify_svn(None, [],
+ # 'diff', wc_dir)
+ #
+ #_, git_changelink, _ = svntest.actions.run_and_verify_svn(None, [],
+ # 'diff', wc_dir, '--git')
+ #
+ #sbox.simple_commit()
+ #sbox.simple_propdel('svn:special', 'iota')
+ #
+ #_, diff_nolink, _ = svntest.actions.run_and_verify_svn(None, [],
+ # 'diff', wc_dir)
+ #
+ #_, git_nolink, _ = svntest.actions.run_and_verify_svn(None, [],
+ # 'diff', wc_dir, '--git')
+
+ tolink_patch = sbox.get_tempname('tolink.patch')
+ svntest.main.file_write(tolink_patch, ''.join(diff_tolink), mode='wb')
+
+ git_tolink_patch = sbox.get_tempname('git_tolink.patch')
+ svntest.main.file_write(git_tolink_patch, ''.join(git_tolink), mode='wb')
+
+ #changelink_patch = sbox.get_tempname('changelink.patch')
+ #svntest.main.file_write(changelink_patch, ''.join(diff_changelink), mode='wb')
+ #
+ #git_changelink_patch = sbox.get_tempname('git_changelink.patch')
+ #svntest.main.file_write(git_changelink_patch, ''.join(git_changelink), mode='wb')
+ #
+ #nolink_patch = sbox.get_tempname('nolink.patch')
+ #svntest.main.file_write(nolink_patch, ''.join(diff_nolink), mode='wb')
+ #
+ #git_nolink_patch = sbox.get_tempname('git_nolink.patch')
+ #svntest.main.file_write(git_nolink_patch, ''.join(git_nolink), mode='wb')
+
+ sbox.simple_revert('iota')
+ sbox.simple_update('', 1)
+
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+ expected_status.tweak('iota', status='MM')
+ expected_output = svntest.wc.State(wc_dir, {
+ 'iota' : Item(status='UU'),
+ })
+ expected_disk = svntest.main.greek_state.copy()
+ expected_disk.tweak('iota', props={'svn:special': '*'})
+ expected_skip = svntest.wc.State(wc_dir, {})
+
+ if svntest.main.is_posix_os():
+ expected_disk.tweak('iota', contents="This is the file 'beta'.\n")
+ else:
+ expected_disk.tweak('iota', contents="link A/B/E/beta")
+
+ # Turn into link
+ svntest.actions.run_and_verify_patch(wc_dir, tolink_patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], True, True,
+ '--strip', strip_count)
+
+ # And in git style
+ sbox.simple_revert('iota')
+ svntest.actions.run_and_verify_patch(wc_dir, git_tolink_patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], True, True)
+
+ # Retry
+ expected_output.tweak('iota', status='GG')
+ svntest.actions.run_and_verify_patch(wc_dir, tolink_patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], True, True,
+ '--strip', strip_count)
+ svntest.actions.run_and_verify_patch(wc_dir, git_tolink_patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], True, True)
+
+ sbox.simple_update('', 2) # Go to r2.
+ sbox.simple_revert('iota')
+ expected_status.tweak(wc_rev=2)
+
+ # Turn back into files
+ expected_output.tweak('iota', status='UU')
+ expected_disk.tweak('iota', props={}, contents="This is the file 'iota'.\n")
+ svntest.actions.run_and_verify_patch(wc_dir, tolink_patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], True, True,
+ '--strip', strip_count,
+ '--reverse-diff')
+
+ # And in git style
+ sbox.simple_revert('iota')
+ svntest.actions.run_and_verify_patch(wc_dir, git_tolink_patch,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], True, True,
+ '--reverse-diff')
+
+
########################################################################
#Run the tests
@@ -7076,6 +7196,7 @@ test_list = [ None,
patch_add_remove_executable,
patch_git_symlink,
patch_like_git_symlink,
+ patch_symlink_madness,
]
if __name__ == '__main__':