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/03 17:10:46 UTC
svn commit: r1706598 - in /subversion/trunk/subversion:
libsvn_client/patch.c tests/cmdline/patch_tests.py
Author: rhuijben
Date: Sat Oct 3 15:10:45 2015
New Revision: 1706598
URL: http://svn.apache.org/viewvc?rev=1706598&view=rev
Log:
In 'svn patch' only handle property changes as a file addition if all the
property changes on the node are property additions.
When there is a combination of adds and modifications we shouldn't just
create a 0 byte file.
* subversion/libsvn_client/patch.c
(apply_one_patch): Only handle a set of property adds as a trigger to
potentially mark a file as added.
* subversion/tests/cmdline/patch_tests.py
(patch_with_properties): 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=1706598&r1=1706597&r2=1706598&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Sat Oct 3 15:10:45 2015
@@ -2869,16 +2869,46 @@ apply_one_patch(patch_target_t **patch_t
&& !target->skipped
&& target->has_prop_changes)
{
+ svn_boolean_t has_adds = FALSE;
+ svn_boolean_t has_deletes = FALSE;
+ svn_boolean_t has_mods = FALSE;
+
for (hash_index = apr_hash_first(scratch_pool, target->prop_targets);
hash_index;
hash_index = apr_hash_next(hash_index))
{
prop_patch_target_t *prop_target = apr_hash_this_val(hash_index);
- if (prop_target->operation != svn_diff_op_deleted)
- {
- ensure_exists = TRUE;
- }
+ switch (prop_target->operation)
+ {
+ case svn_diff_op_added:
+ has_adds = TRUE;
+ break;
+ case svn_diff_op_deleted:
+ has_deletes = TRUE;
+ break;
+ case svn_diff_op_modified:
+ default:
+ has_mods = TRUE;
+ break;
+ }
+ }
+
+ if (has_adds && !has_mods && !has_deletes)
+ ensure_exists = TRUE;
+ else if (has_mods && target->locally_deleted
+ || target->kind_on_disk == svn_node_none)
+ {
+ target->had_prop_rejects = TRUE;
+ for (hash_index = apr_hash_first(scratch_pool, target->prop_targets);
+ hash_index;
+ hash_index = apr_hash_next(hash_index))
+ {
+ prop_patch_target_t *prop_target = apr_hash_this_val(hash_index);
+
+ if (prop_target->operation != svn_diff_op_deleted)
+ prop_target->skipped = TRUE;
+ }
}
}
Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1706598&r1=1706597&r2=1706598&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Sat Oct 3 15:10:45 2015
@@ -2247,9 +2247,62 @@ def patch_with_properties(sbox):
expected_disk,
expected_status,
expected_skip,
- None, # expected err
- 1, # check-props
- 1) # dry-run
+ [], True, True)
+ # And repeat
+ expected_output = svntest.wc.State(wc_dir, {
+ 'iota' : Item(status=' G')
+ })
+ svntest.actions.run_and_verify_patch(wc_dir, patch_file_path,
+ expected_output,
+ expected_disk,
+ expected_status,
+ expected_skip,
+ [], True, True)
+
+ # Reverse
+ expected_output.tweak('iota', status=' U')
+ expected_disk.tweak('iota',
+ props={'deleted': "This is the property 'deleted'.\n",
+ 'modified': "This is the property 'modified'.\n"})
+ svntest.actions.run_and_verify_patch(wc_dir, patch_file_path,
+ expected_output,
+ expected_disk,
+ expected_status,
+ expected_skip,
+ [], True, True,
+ '--reverse-diff')
+
+ # Repeat
+ expected_output.tweak('iota', status=' G')
+ svntest.actions.run_and_verify_patch(wc_dir, patch_file_path,
+ expected_output,
+ expected_disk,
+ expected_status,
+ expected_skip,
+ [], True, True,
+ '--reverse-diff')
+
+ # And now try against a not existing target
+ svntest.actions.run_and_verify_svn(None, [],
+ 'rm', '--force', sbox.ospath('iota'))
+ expected_output.tweak('iota', status=' C')
+ expected_disk.remove('iota')
+ expected_status.tweak('iota', status='D ')
+ expected_disk.add({
+ 'iota.svnpatch.rej' : Item(contents="--- iota\n"
+ "+++ iota\n"
+ "Property: modified\n"
+ "## -1,1 +1,1 ##\n"
+ "-This is the property 'modified'.\n"
+ "+The property 'modified' has changed.\n")
+ })
+ svntest.actions.run_and_verify_patch(wc_dir, patch_file_path,
+ expected_output,
+ expected_disk,
+ expected_status,
+ expected_skip,
+ [], True, True)
+
def patch_same_twice(sbox):
"apply the same patch twice"