Followup to r29625: fix getopt tests.
[svn.git] / subversion / svn / mkdir-cmd.c
blob5d382a112762dc75e4acc42a2962ac69b6210eaa
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_cl__args_to_target_array_print_reserved(&targets, os,
49 opt_state->targets,
50 pool));
52 if (! targets->nelts)
53 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
55 if (! opt_state->quiet)
56 svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2, FALSE,
57 FALSE, FALSE, pool);
59 if (! svn_path_is_url(APR_ARRAY_IDX(targets, 0, const char *)))
61 ctx->log_msg_func3 = NULL;
62 if (opt_state->message || opt_state->filedata || opt_state->revprop_table)
64 return svn_error_create
65 (SVN_ERR_CL_UNNECESSARY_LOG_MESSAGE, NULL,
66 _("Local, non-commit operations do not take a log message "
67 "or revision properties"));
70 else
72 SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3), opt_state,
73 NULL, ctx->config, pool));
76 ctx->revprop_table = opt_state->revprop_table;
78 err = svn_client_mkdir3(&commit_info, targets, opt_state->parents,
79 ctx, pool);
81 if (ctx->log_msg_func3)
82 err = svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err);
84 if (err)
86 if (err->apr_err == APR_EEXIST)
87 return svn_error_quick_wrap
88 (err, _("Try 'svn add' or 'svn add --non-recursive' instead?"));
89 else if (!(opt_state->parents) &&
90 (APR_STATUS_IS_ENOENT(err->apr_err) || /* in wc */
91 err->apr_err == SVN_ERR_FS_NOT_FOUND || /* ra_local and ra_svn */
92 err->apr_err == SVN_ERR_RA_DAV_PATH_NOT_FOUND /* ra_neon */))
93 return svn_error_quick_wrap
94 (err, _("Try 'svn mkdir --parents' instead?"));
95 else
96 return err;
99 if (commit_info && ! opt_state->quiet)
100 SVN_ERR(svn_cl__print_commit_info(commit_info, pool));
102 return SVN_NO_ERROR;