In the command-line client, forbid
[svn.git] / subversion / svn / commit-cmd.c
blob8dbb8cb4efee2fedf6de9985b7ac25c33a7ff735
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_opt_args_to_target_array2(&targets, os,
55 opt_state->targets, pool));
57 /* Add "." if user passed 0 arguments. */
58 svn_opt_push_implicit_dot_target(targets, pool);
60 /* Condense the targets (like commit does)... */
61 SVN_ERR(svn_path_condense_targets(&base_dir,
62 &condensed_targets,
63 targets,
64 TRUE,
65 pool));
67 if ((! condensed_targets) || (! condensed_targets->nelts))
69 const char *parent_dir, *base_name;
71 SVN_ERR(svn_wc_get_actual_target(base_dir, &parent_dir,
72 &base_name, pool));
73 if (*base_name)
74 base_dir = apr_pstrdup(pool, parent_dir);
77 if (! opt_state->quiet)
78 svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2, FALSE,
79 FALSE, FALSE, pool);
81 if (opt_state->depth == svn_depth_unknown)
82 opt_state->depth = svn_depth_infinity;
84 cfg = apr_hash_get(ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
85 APR_HASH_KEY_STRING);
86 if (cfg)
87 SVN_ERR(svn_config_get_bool(cfg, &no_unlock,
88 SVN_CONFIG_SECTION_MISCELLANY,
89 SVN_CONFIG_OPTION_NO_UNLOCK, FALSE));
91 /* We're creating a new log message baton because we can use our base_dir
92 to store the temp file, instead of the current working directory. The
93 client might not have write access to their working directory, but they
94 better have write access to the directory they're committing. */
95 SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3),
96 opt_state, base_dir,
97 ctx->config, pool));
99 ctx->revprop_table = opt_state->revprop_table;
101 /* Commit. */
102 err = svn_client_commit4(&commit_info,
103 targets,
104 opt_state->depth,
105 no_unlock,
106 opt_state->keep_changelist,
107 opt_state->changelist,
108 ctx,
109 pool);
110 if (err)
112 svn_error_t *root_err = svn_error_root_cause(err);
113 if (root_err->apr_err == SVN_ERR_UNKNOWN_CHANGELIST)
115 /* Strip any errors wrapped around this root cause. Note
116 that this handling differs from that of any other
117 commands, because of the way 'commit' internally harvests
118 its list of committables. */
119 root_err = svn_error_dup(root_err);
120 svn_error_clear(err);
121 err = root_err;
124 SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err));
125 if (! err && ! opt_state->quiet)
126 SVN_ERR(svn_cl__print_commit_info(commit_info, pool));
128 return SVN_NO_ERROR;