14.10.2018, 17:17, "Branko Čibej" <br...@apache.org>:

Hey. Thanks for the nudge.

I have just one comment: The two new test scenarios you should be split
into their own test cases. Not only is it bad practice to make a test
case test more than one scenario, it also defeats parallel test execution.

Fixed version (the patch is also attached):
 
[[[
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_existing_unversioned_dst,
   copy_make_parents_wc_wc_existing_unversioned_dst): 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 1843859)
+++ 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 1843859)
+++ subversion/tests/cmdline/copy_tests.py	(working copy)
@@ -3504,7 +3504,51 @@ 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
 
 def copy_make_parents_repo_wc(sbox):
@@ -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):
@@ -5955,6 +6042,8 @@ test_list = [ None,
               ext_wc_copy_deleted,
               copy_subtree_deleted,
               resurrect_at_root,
+              copy_make_parents_wc_wc_existing_unversioned_dst,
+              copy_make_parents_repo_wc_existing_unversioned_dst,
              ]
 
 if __name__ == '__main__':

Reply via email to