Author: dsahlberg
Date: Thu Apr 13 21:06:47 2023
New Revision: 1909127
URL: http://svn.apache.org/viewvc?rev=1909127&view=rev
Log:
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
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=1909127&r1=1909126&r2=1909127&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Thu Apr 13 21:06:47 2023
@@ -3077,7 +3077,7 @@ try_copy(svn_boolean_t *timestamp_sleep,
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 @@ try_copy(svn_boolean_t *timestamp_sleep,
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));
}
Modified: subversion/trunk/subversion/tests/cmdline/copy_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/copy_tests.py?rev=1909127&r1=1909126&r2=1909127&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/copy_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/copy_tests.py Thu Apr 13 21:06:47
2023
@@ -1252,6 +1252,57 @@ def wc_copy_parent_into_child(sbox):
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 @@ test_list = [ None,
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,