14.07.2018, 17:18, "Daniel Shahaf" <danie...@apache.org>:
> It would help to add a regression test to subversion/tests/cmdline/ or
> subversion/tests/libsvn_client/.

Thanks for your advice. I've added cmdline tests to the patch and fixed the log
message accordingly.

[[[
Correctly handle existing parent directories when performing repos-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 do.

* subversion/tests/cmdline/copy_tests.py
  (copy_make_parents_repo_wc,
   copy_make_parents_wc_wc): Check behaviour with dst directory pre-creation
  for both repo-to-wc and wc-to-wc test cases.
]]]

-- 
Nikita Slyusarev
Yandex
Index: subversion/libsvn_client/copy.c
===================================================================
--- subversion/libsvn_client/copy.c	(revision 1835910)
+++ subversion/libsvn_client/copy.c	(working copy)
@@ -2742,6 +2742,16 @@ repos_to_wc_copy(svn_boolean_t *timestamp_sleep,
           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,
Index: subversion/tests/cmdline/copy_tests.py
===================================================================
--- subversion/tests/cmdline/copy_tests.py	(revision 1835910)
+++ subversion/tests/cmdline/copy_tests.py	(working copy)
@@ -3477,10 +3477,19 @@ def copy_make_parents_wc_wc(sbox):
   iota_path = sbox.ospath('iota')
   new_iota_path = sbox.ospath('X/Y/Z/iota')
 
+  # Existing unversioned dst directory case
+  new_iota_path_eudst = sbox.ospath('X2/Y/Z/iota')
+  os.makedirs(os.path.dirname(new_iota_path_eudst))
+
   # Copy iota
   svntest.actions.run_and_verify_svn(None, [], 'cp', '--parents',
                                      iota_path, new_iota_path)
 
+  # Copy iota to pre-created dst directory
+  svntest.actions.run_and_verify_svn(None, [],
+                                     'cp', '--parents',
+                                     iota_path, new_iota_path_eudst)
+
   # Create expected output
   expected_output = svntest.wc.State(wc_dir, {
     'X'           : Item(verb='Adding'),
@@ -3487,6 +3496,10 @@ def copy_make_parents_wc_wc(sbox):
     'X/Y'         : Item(verb='Adding'),
     'X/Y/Z'       : Item(verb='Adding'),
     'X/Y/Z/iota'  : Item(verb='Adding'),
+    'X2'          : Item(verb='Adding'),
+    'X2/Y'        : Item(verb='Adding'),
+    'X2/Y/Z'      : Item(verb='Adding'),
+    'X2/Y/Z/iota' : Item(verb='Adding'),
     })
 
   # Create expected status tree
@@ -3498,6 +3511,10 @@ def copy_make_parents_wc_wc(sbox):
     'X/Y'         : Item(status='  ', wc_rev=2),
     'X/Y/Z'       : Item(status='  ', wc_rev=2),
     'X/Y/Z/iota'  : Item(status='  ', wc_rev=2),
+    'X2'          : Item(status='  ', wc_rev=2),
+    'X2/Y'        : Item(status='  ', wc_rev=2),
+    'X2/Y/Z'      : Item(status='  ', wc_rev=2),
+    'X2/Y/Z/iota' : Item(status='  ', wc_rev=2),
     })
 
   svntest.actions.run_and_verify_commit(wc_dir,
@@ -3516,11 +3533,20 @@ def copy_make_parents_repo_wc(sbox):
   iota_url = sbox.repo_url + '/iota'
   new_iota_path = sbox.ospath('X/Y/Z/iota')
 
+  # Existing unversioned dst directory case
+  new_iota_path_eudst = sbox.ospath('X2/Y/Z/iota')
+  os.makedirs(os.path.dirname(new_iota_path_eudst))
+
   # Copy iota
   svntest.actions.run_and_verify_svn(None, [],
                                      'cp', '--parents',
                                      iota_url, new_iota_path)
 
+  # Copy iota to pre-created dst directory
+  svntest.actions.run_and_verify_svn(None, [],
+                                     'cp', '--parents',
+                                     iota_url, new_iota_path_eudst)
+
   # Create expected output
   expected_output = svntest.wc.State(wc_dir, {
     'X'           : Item(verb='Adding'),
@@ -3527,6 +3553,10 @@ def copy_make_parents_repo_wc(sbox):
     'X/Y'         : Item(verb='Adding'),
     'X/Y/Z'       : Item(verb='Adding'),
     'X/Y/Z/iota'  : Item(verb='Adding'),
+    'X2'          : Item(verb='Adding'),
+    'X2/Y'        : Item(verb='Adding'),
+    'X2/Y/Z'      : Item(verb='Adding'),
+    'X2/Y/Z/iota' : Item(verb='Adding'),
     })
 
   # Create expected status tree
@@ -3538,6 +3568,10 @@ def copy_make_parents_repo_wc(sbox):
     'X/Y'         : Item(status='  ', wc_rev=2),
     'X/Y/Z'       : Item(status='  ', wc_rev=2),
     'X/Y/Z/iota'  : Item(status='  ', wc_rev=2),
+    'X2'          : Item(status='  ', wc_rev=2),
+    'X2/Y'        : Item(status='  ', wc_rev=2),
+    'X2/Y/Z'      : Item(status='  ', wc_rev=2),
+    'X2/Y/Z/iota' : Item(status='  ', wc_rev=2),
     })
 
   svntest.actions.run_and_verify_commit(wc_dir,

Reply via email to