Followup to r29625: fix getopt tests.
[svn.git] / subversion / svn / commit-cmd.c
bloba0778fe290fe041f20ea5f5bc2e21d2c51fbb05f
1 /*
2 * commit-cmd.c -- Check changes into the repository.
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 <apr_general.h>
27 #include "svn_error.h"
28 #include "svn_error_codes.h"
29 #include "svn_wc.h"
30 #include "svn_client.h"
31 #include "svn_path.h"
32 #include "svn_error.h"
33 #include "svn_config.h"
34 #include "cl.h"
38 /* This implements the `svn_opt_subcommand_t' interface. */
39 svn_error_t *
40 svn_cl__commit(apr_getopt_t *os,
41 void *baton,
42 apr_pool_t *pool)
44 svn_error_t *err;
45 svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
46 svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
47 apr_array_header_t *targets;
48 apr_array_header_t *condensed_targets;
49 const char *base_dir;
50 svn_config_t *cfg;
51 svn_boolean_t no_unlock = FALSE;
52 svn_commit_info_t *commit_info = NULL;
54 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
55 opt_state->targets,
56 pool));
58 /* Add "." if user passed 0 arguments. */
59 svn_opt_push_implicit_dot_target(targets, pool);
61 /* Condense the targets (like commit does)... */
62 SVN_ERR(svn_path_condense_targets(&base_dir,
63 &condensed_targets,
64 targets,
65 TRUE,
66 pool));
68 if ((! condensed_targets) || (! condensed_targets->nelts))
70 const char *parent_dir, *base_name;
72 SVN_ERR(svn_wc_get_actual_target(base_dir, &parent_dir,
73 &base_name, pool));
74 if (*base_name)
75 base_dir = apr_pstrdup(pool, parent_dir);
78 if (! opt_state->quiet)
79 svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2, FALSE,
80 FALSE, FALSE, pool);
82 if (opt_state->depth == svn_depth_unknown)
83 opt_state->depth = svn_depth_infinity;
85 cfg = apr_hash_get(ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
86 APR_HASH_KEY_STRING);
87 if (cfg)
88 SVN_ERR(svn_config_get_bool(cfg, &no_unlock,
89 SVN_CONFIG_SECTION_MISCELLANY,
90 SVN_CONFIG_OPTION_NO_UNLOCK, FALSE));
92 /* We're creating a new log message baton because we can use our base_dir
93 to store the temp file, instead of the current working directory. The
94 client might not have write access to their working directory, but they
95 better have write access to the directory they're committing. */
96 SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3),
97 opt_state, base_dir,
98 ctx->config, pool));
100 ctx->revprop_table = opt_state->revprop_table;
102 /* Commit. */
103 err = svn_client_commit4(&commit_info,
104 targets,
105 opt_state->depth,
106 no_unlock,
107 opt_state->keep_changelists,
108 opt_state->changelists,
109 ctx,
110 pool);
111 if (err)
113 svn_error_t *root_err = svn_error_root_cause(err);
114 if (root_err->apr_err == SVN_ERR_UNKNOWN_CHANGELIST)
116 /* Strip any errors wrapped around this root cause. Note
117 that this handling differs from that of any other
118 commands, because of the way 'commit' internally harvests
119 its list of committables. */
120 root_err = svn_error_dup(root_err);
121 svn_error_clear(err);
122 err = root_err;
125 SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err));
126 if (! err && ! opt_state->quiet)
127 SVN_ERR(svn_cl__print_commit_info(commit_info, pool));
129 return SVN_NO_ERROR;