You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2010/12/03 17:31:43 UTC
svn commit: r1041900 - in /subversion/trunk/subversion: libsvn_client/add.c
svn/mkdir-cmd.c tests/cmdline/input_validation_tests.py
Author: julianfoad
Date: Fri Dec 3 16:31:43 2010
New Revision: 1041900
URL: http://svn.apache.org/viewvc?rev=1041900&view=rev
Log:
Make 'svn mkdir' verify that both working copy paths and URLs are not passed.
* subversion/svn/mkdir-cmd.c,
subversion/libsvn_client/add.c
(svn_cl__mkdir, svn_client_mkdir4): Raise an error if both working
copy paths and URLs are passed.
(mkdir_urls): Remove redundant code.
* subversion/tests/cmdline/input_validation_tests.py
(invalid_mkdir_targets, test_list): New test
Patch by: Noorul Islam K M <noorul{_AT_}collab.net>
Modified:
subversion/trunk/subversion/libsvn_client/add.c
subversion/trunk/subversion/svn/mkdir-cmd.c
subversion/trunk/subversion/tests/cmdline/input_validation_tests.py
Modified: subversion/trunk/subversion/libsvn_client/add.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/add.c?rev=1041900&r1=1041899&r2=1041900&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/add.c (original)
+++ subversion/trunk/subversion/libsvn_client/add.c Fri Dec 3 16:31:43 2010
@@ -673,16 +673,6 @@ mkdir_urls(const apr_array_header_t *url
const char *common;
int i;
- /* Early exit when there is a mix of URLs and local paths. */
- for (i = 0; i < urls->nelts; i++)
- {
- const char *url = APR_ARRAY_IDX(urls, i, const char *);
- if (! svn_path_is_url(url))
- return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
- _("Illegal repository URL '%s'"),
- url);
- }
-
/* Find any non-existent parent directories */
if (make_parents)
{
@@ -875,9 +865,28 @@ svn_client_mkdir4(const apr_array_header
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
+ svn_boolean_t wc_present = FALSE, url_present = FALSE;
+ int i;
+
if (! paths->nelts)
return SVN_NO_ERROR;
+ /* Check to see if at least one of our paths is a working copy
+ path or a repository url. */
+ for (i = 0; i < paths->nelts; ++i)
+ {
+ const char *path = APR_ARRAY_IDX(paths, i, const char *);
+ if (! svn_path_is_url(path))
+ wc_present = TRUE;
+ else
+ url_present = TRUE;
+ }
+
+ if (url_present && wc_present)
+ return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+ _("Cannot mix repository and working copy "
+ "targets"));
+
if (svn_path_is_url(APR_ARRAY_IDX(paths, 0, const char *)))
{
SVN_ERR(mkdir_urls(paths, make_parents, revprop_table, commit_callback,
@@ -887,7 +896,6 @@ svn_client_mkdir4(const apr_array_header
{
/* This is a regular "mkdir" + "svn add" */
apr_pool_t *subpool = svn_pool_create(pool);
- int i;
for (i = 0; i < paths->nelts; i++)
{
Modified: subversion/trunk/subversion/svn/mkdir-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/mkdir-cmd.c?rev=1041900&r1=1041899&r2=1041900&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/mkdir-cmd.c (original)
+++ subversion/trunk/subversion/svn/mkdir-cmd.c Fri Dec 3 16:31:43 2010
@@ -48,6 +48,8 @@ svn_cl__mkdir(apr_getopt_t *os,
svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
apr_array_header_t *targets;
svn_error_t *err;
+ svn_boolean_t wc_present = FALSE, url_present = FALSE;
+ int i;
SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
opt_state->targets,
@@ -56,6 +58,22 @@ svn_cl__mkdir(apr_getopt_t *os,
if (! targets->nelts)
return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
+ /* Check to see if at least one of our paths is a working copy
+ path or a repository url. */
+ for (i = 0; i < targets->nelts; ++i)
+ {
+ const char *target = APR_ARRAY_IDX(targets, i, const char *);
+ if (! svn_path_is_url(target))
+ wc_present = TRUE;
+ else
+ url_present = TRUE;
+ }
+
+ if (url_present && wc_present)
+ return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Cannot mix repository and working copy "
+ "targets"));
+
if (! svn_path_is_url(APR_ARRAY_IDX(targets, 0, const char *)))
{
ctx->log_msg_func3 = NULL;
Modified: subversion/trunk/subversion/tests/cmdline/input_validation_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/input_validation_tests.py?rev=1041900&r1=1041899&r2=1041900&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/input_validation_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/input_validation_tests.py Fri Dec 3 16:31:43 2010
@@ -234,6 +234,12 @@ def invalid_relocate_targets(sbox):
run_and_verify_svn_in_wc(sbox, "svn:.*is not a local path", 'relocate',
"^/", "^/", "^/")
+def invalid_mkdir_targets(sbox):
+ "invalid targets for 'mkdir'"
+ sbox.build(read_only=True)
+ run_and_verify_svn_in_wc(sbox, "svn: Cannot mix repository and working "
+ "copy targets", 'mkdir', "folder", "^/folder")
+
########################################################################
# Run the tests
@@ -261,6 +267,7 @@ test_list = [ None,
invalid_patch_targets,
invalid_switch_targets,
invalid_relocate_targets,
+ invalid_mkdir_targets,
]
if __name__ == '__main__':