In the command-line client, forbid
[svn.git] / subversion / svn / mkdir-cmd.c
blob7d343dd24682094f0f319e5518cbd1d9aa99f49c
1 /*
2 * mkdir-cmd.c -- Subversion mkdir command
4 * ====================================================================
5 * Copyright (c) 2000-2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 /* ==================================================================== */
23 /*** Includes. ***/
25 #include "svn_pools.h"
26 #include "svn_client.h"
27 #include "svn_error.h"
28 #include "svn_path.h"
29 #include "cl.h"
31 #include "svn_private_config.h"
34 /*** Code. ***/
36 /* This implements the `svn_opt_subcommand_t' interface. */
37 svn_error_t *
38 svn_cl__mkdir(apr_getopt_t *os,
39 void *baton,
40 apr_pool_t *pool)
42 svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
43 svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
44 apr_array_header_t *targets;
45 svn_commit_info_t *commit_info = NULL;
46 svn_error_t *err;
48 SVN_ERR(svn_opt_args_to_target_array2(&targets, os,
49 opt_state->targets, pool));
51 if (! targets->nelts)
52 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
54 if (! opt_state->quiet)
55 svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2, FALSE,
56 FALSE, FALSE, pool);
58 if (! svn_path_is_url(APR_ARRAY_IDX(targets, 0, const char *)))
60 ctx->log_msg_func3 = NULL;
61 if (opt_state->message || opt_state->filedata || opt_state->revprop_table)
63 return svn_error_create
64 (SVN_ERR_CL_UNNECESSARY_LOG_MESSAGE, NULL,
65 _("Local, non-commit operations do not take a log message "
66 "or revision properties"));
69 else
71 SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
72 NULL, ctx->config, pool));
75 ctx->revprop_table = opt_state->revprop_table;
77 err = svn_client_mkdir3(&commit_info, targets, opt_state->parents,
78 ctx, pool);
80 if (ctx->log_msg_func3)
81 err = svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err);
83 if (err)
85 if (err->apr_err == APR_EEXIST)
86 return svn_error_quick_wrap
87 (err, _("Try 'svn add' or 'svn add --non-recursive' instead?"));
88 else if (!(opt_state->parents) &&
89 (APR_STATUS_IS_ENOENT(err->apr_err) || /* in wc */
90 err->apr_err == SVN_ERR_FS_NOT_FOUND || /* ra_local and ra_svn */
91 err->apr_err == SVN_ERR_RA_DAV_PATH_NOT_FOUND /* ra_neon */))
92 return svn_error_quick_wrap
93 (err, _("Try 'svn mkdir --parents' instead?"));
94 else
95 return err;
98 if (commit_info && ! opt_state->quiet)
99 SVN_ERR(svn_cl__print_commit_info(commit_info, pool));
101 return SVN_NO_ERROR;