Author: brane
Date: Mon Oct 15 08:55:55 2018
New Revision: 1843888
URL: http://svn.apache.org/viewvc?rev=1843888&view=rev
Log:
Correctly handle existing parent directories during repository-to-WC copy.
* subversion/libsvn_client/copy.c
(repos_to_wc_copy): If add_parents flag is set and destination parent
directory exists, but is unversioned, put it under version control.
WC-to-WC copy behaves this way, and so should repos-to-WC copy.
* subversion/tests/cmdline/copy_tests.py
(copy_make_parents_wc_wc_existing_unversioned_dst,
copy_make_parents_repo_wc_existing_unversioned_dst): Check behaviour
with existing. unversioned destination directory for both repos-to-WC
and WC-to-WC cases.
Patch by: Nikita Slyusarev
Fixes #4768
Modified:
subversion/trunk/subversion/libsvn_client/copy.c
subversion/trunk/subversion/tests/cmdline/copy_tests.py
Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=1843888&r1=1843887&r2=1843888&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Mon Oct 15 08:55:55 2018
@@ -2742,6 +2742,16 @@ repos_to_wc_copy(svn_boolean_t *timestam
SVN_ERR(svn_client__make_local_parents(dst_parent, TRUE, ctx,
iterpool));
}
+ else if (make_parents && dst_parent_kind == svn_node_dir)
+ {
+ SVN_ERR(svn_wc_read_kind2(&dst_parent_kind, ctx->wc_ctx, dst_parent,
+ FALSE, TRUE, iterpool));
+ if (dst_parent_kind == svn_node_none)
+ {
+ SVN_ERR(svn_client__make_local_parents(dst_parent, TRUE, ctx,
+ iterpool));
+ }
+ }
else if (dst_parent_kind != svn_node_dir)
{
return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
Modified: subversion/trunk/subversion/tests/cmdline/copy_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/copy_tests.py?rev=1843888&r1=1843887&r2=1843888&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/copy_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/copy_tests.py Mon Oct 15 08:55:55
2018
@@ -3504,6 +3504,50 @@ def copy_make_parents_wc_wc(sbox):
expected_output,
expected_status)
+
+#----------------------------------------------------------------------
+# Test copying and creating parents in the wc with dst directory being
+# precreated and unversioned
+
+def copy_make_parents_wc_wc_existing_unversioned_dst(sbox):
+ "svn cp --parents WC_PATH WC_PATH (ex. unver. dst)"
+
+ sbox.build()
+ wc_dir = sbox.wc_dir
+
+ iota_path = sbox.ospath('iota')
+ new_iota_path = sbox.ospath('X/Y/Z/iota')
+ os.makedirs(os.path.dirname(new_iota_path))
+
+ # Copy iota
+ svntest.actions.run_and_verify_svn(None, [],
+ 'cp', '--parents',
+ iota_path, new_iota_path)
+
+ # Create expected output
+ expected_output = svntest.wc.State(wc_dir, {
+ 'X' : Item(verb='Adding'),
+ 'X/Y' : Item(verb='Adding'),
+ 'X/Y/Z' : Item(verb='Adding'),
+ 'X/Y/Z/iota' : Item(verb='Adding'),
+ })
+
+ # Create expected status tree
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+
+ # Add the moved files
+ expected_status.add({
+ 'X' : Item(status=' ', wc_rev=2),
+ 'X/Y' : Item(status=' ', wc_rev=2),
+ 'X/Y/Z' : Item(status=' ', wc_rev=2),
+ 'X/Y/Z/iota' : Item(status=' ', wc_rev=2),
+ })
+
+ svntest.actions.run_and_verify_commit(wc_dir,
+ expected_output,
+ expected_status)
+
+
#----------------------------------------------------------------------
# Test copying and creating parents from the repo to the wc
@@ -3546,6 +3590,49 @@ def copy_make_parents_repo_wc(sbox):
#----------------------------------------------------------------------
+# Test copying and creating parents from the repo to the wc with dst
+# directory being precreated and unversioned
+
+def copy_make_parents_repo_wc_existing_unversioned_dst(sbox):
+ "svn cp --parents URL WC_PATH with (ex. unver. dst)"
+
+ sbox.build()
+ wc_dir = sbox.wc_dir
+
+ iota_url = sbox.repo_url + '/iota'
+ new_iota_path = sbox.ospath('X/Y/Z/iota')
+ os.makedirs(os.path.dirname(new_iota_path))
+
+ # Copy iota
+ svntest.actions.run_and_verify_svn(None, [],
+ 'cp', '--parents',
+ iota_url, new_iota_path)
+
+ # Create expected output
+ expected_output = svntest.wc.State(wc_dir, {
+ 'X' : Item(verb='Adding'),
+ 'X/Y' : Item(verb='Adding'),
+ 'X/Y/Z' : Item(verb='Adding'),
+ 'X/Y/Z/iota' : Item(verb='Adding'),
+ })
+
+ # Create expected status tree
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+
+ # Add the moved files
+ expected_status.add({
+ 'X' : Item(status=' ', wc_rev=2),
+ 'X/Y' : Item(status=' ', wc_rev=2),
+ 'X/Y/Z' : Item(status=' ', wc_rev=2),
+ 'X/Y/Z/iota' : Item(status=' ', wc_rev=2),
+ })
+
+ svntest.actions.run_and_verify_commit(wc_dir,
+ expected_output,
+ expected_status)
+
+
+#----------------------------------------------------------------------
# Test copying and creating parents from the wc to the repo
def copy_make_parents_wc_repo(sbox):
@@ -5904,7 +5991,9 @@ test_list = [ None,
copy_peg_rev_url,
old_dir_wc_to_wc,
copy_make_parents_wc_wc,
+ copy_make_parents_wc_wc_existing_unversioned_dst,
copy_make_parents_repo_wc,
+ copy_make_parents_repo_wc_existing_unversioned_dst,
copy_make_parents_wc_repo,
copy_make_parents_repo_repo,
URI_encoded_repos_to_wc,