Fix issue #4913 Assert on svn move [URL] [URL]/subdir.

* libsvn_client/copy.c:
  (try_copy): Always check if target is child of the source when performing
    a move.

* tests/cmdline/copy_tests.py
  (url_move_parent_into_child, wc_move_parent_into_child): New test cases,
    inspired by similarly named _copy_ test cases
  (test_list): Run the new test cases

See dev@ https://lists.apache.org/thread/s4byt3p2tot453smhhdlh0fhygy2bhb9



git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1909127 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/subversion/libsvn_client/copy.c b/subversion/libsvn_client/copy.c
index be8cf19..18bc240 100644
--- a/subversion/libsvn_client/copy.c
+++ b/subversion/libsvn_client/copy.c
@@ -3077,7 +3077,7 @@
       APR_ARRAY_PUSH(copy_pairs, svn_client__copy_pair_t *) = pair;
     }
 
-  if (!srcs_are_urls && !dst_is_url)
+  if (is_move || (!srcs_are_urls && !dst_is_url))
     {
       apr_pool_t *iterpool = svn_pool_create(pool);
 
@@ -3092,7 +3092,9 @@
                                   pair->dst_abspath_or_url, iterpool))
             return svn_error_createf
               (SVN_ERR_UNSUPPORTED_FEATURE, NULL,
-               _("Cannot copy path '%s' into its own child '%s'"),
+               is_move ?
+	         _("Cannot move path '%s' into its own child '%s'") :
+		 _("Cannot copy path '%s' into its own child '%s'"),
                svn_dirent_local_style(pair->src_abspath_or_url, pool),
                svn_dirent_local_style(pair->dst_abspath_or_url, pool));
         }
diff --git a/subversion/tests/cmdline/copy_tests.py b/subversion/tests/cmdline/copy_tests.py
index 99b2934..5659812 100755
--- a/subversion/tests/cmdline/copy_tests.py
+++ b/subversion/tests/cmdline/copy_tests.py
@@ -1252,6 +1252,57 @@
                                         expected_status)
 
 #----------------------------------------------------------------------
+@Issue(4913)
+def url_move_parent_into_child(sbox):
+  "move URL URL/subdir"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  B_url = sbox.repo_url + "/A/B"
+  F_url = sbox.repo_url + "/A/B/F"
+  print(B_url)
+  print(F_url)
+
+  expected_error = "svn: E200007: Cannot move path '.*%s' into its own " \
+                   "child '.*%s'" % (re.escape(B_url),
+                                     re.escape(F_url))
+  svntest.actions.run_and_verify_svn(None, expected_error,
+                                     'mv',
+                                     '-m', 'a can of worms',
+                                     B_url, F_url)
+
+#----------------------------------------------------------------------
+@Issue(4913)
+def wc_move_parent_into_child(sbox):
+  "move WC WC/subdir"
+
+  sbox.build(create_wc = False)
+  wc_dir = sbox.wc_dir
+
+  B_url = sbox.repo_url + "/A/B"
+  F_B_url = sbox.repo_url + "/A/B/F/B"
+
+  # Want a smaller WC
+  svntest.main.safe_rmtree(wc_dir)
+  svntest.actions.run_and_verify_svn(None, [],
+                                     'checkout',
+                                     B_url, wc_dir)
+
+  was_cwd = os.getcwd()
+  from_path = os.path.abspath(sbox.ospath(''))
+  to_path = os.path.abspath(sbox.ospath('F/B'))
+  os.chdir(wc_dir)
+  
+  expected_error = "svn: E200007: Cannot move path '%s' into its own " \
+                   "child '%s'" % (from_path, to_path)
+  svntest.actions.run_and_verify_svn(None, expected_error,
+                                     'mv',
+                                     '.', 'F/B')
+
+  os.chdir(was_cwd)
+
+#----------------------------------------------------------------------
 # Issue 1419: at one point ra_neon->get_uuid() was failing on a
 # non-existent public URL, which prevented us from resurrecting files
 # (svn cp -rOLD URL wc).
@@ -5991,6 +6042,8 @@
               copy_to_root,
               url_copy_parent_into_child,
               wc_copy_parent_into_child,
+              url_move_parent_into_child,
+              wc_move_parent_into_child,
               resurrect_deleted_file,
               diff_repos_to_wc_copy,
               repos_to_wc_copy_eol_keywords,