#include <apr_general.h>
#include "svn_error.h"
#include "svn_error_codes.h"
#include "svn_wc.h"
#include "svn_client.h"
#include "svn_path.h"
#include "svn_dirent_uri.h"
#include "svn_error.h"
#include "svn_config.h"
#include "cl.h"
#include "svn_private_config.h"
struct copy_warning_notify_baton
{
svn_wc_notify_func2_t wrapped_func;
void *wrapped_baton;
svn_depth_t depth;
svn_boolean_t warned;
};
static void
copy_warning_notify_func(void *baton,
const svn_wc_notify_t *notify,
apr_pool_t *pool)
{
struct copy_warning_notify_baton *b = baton;
if (b->wrapped_func)
b->wrapped_func(b->wrapped_baton, notify, pool);
if ((! b->warned)
&& (b->depth < svn_depth_infinity)
&& (notify->kind == svn_node_dir)
&& ((notify->action == svn_wc_notify_commit_copied) ||
(notify->action == svn_wc_notify_commit_copied_replaced)))
{
svn_error_t *err;
err = svn_cmdline_printf(pool,
_("svn: The depth of this commit is '%s', "
"but copies are always performed "
"recursively in the repository.\n"),
svn_depth_to_word(b->depth));
svn_error_clear(err);
b->warned = TRUE;
}
}
svn_error_t *
svn_cl__commit(apr_getopt_t *os,
void *baton,
apr_pool_t *pool)
{
svn_error_t *err;
svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
apr_array_header_t *targets;
apr_array_header_t *condensed_targets;
const char *base_dir;
svn_config_t *cfg;
svn_boolean_t no_unlock = FALSE;
struct copy_warning_notify_baton cwnb;
SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
opt_state->targets,
ctx, FALSE, pool));
SVN_ERR_W(svn_cl__check_targets_are_local_paths(targets),
_("Commit targets must be local paths"));
svn_opt_push_implicit_dot_target(targets, pool);
SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
SVN_ERR(svn_dirent_condense_targets(&base_dir, &condensed_targets, targets,
TRUE, pool, pool));
if ((! condensed_targets) || (! condensed_targets->nelts))
{
const char *parent_dir, *base_name;
SVN_ERR(svn_wc_get_actual_target2(&parent_dir, &base_name, ctx->wc_ctx,
base_dir, pool, pool));
if (*base_name)
base_dir = apr_pstrdup(pool, parent_dir);
}
if (opt_state->depth == svn_depth_unknown)
opt_state->depth = svn_depth_infinity;
cfg = apr_hash_get(ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
APR_HASH_KEY_STRING);
if (cfg)
SVN_ERR(svn_config_get_bool(cfg, &no_unlock,
SVN_CONFIG_SECTION_MISCELLANY,
SVN_CONFIG_OPTION_NO_UNLOCK, FALSE));
SVN_ERR(svn_cl__make_log_msg_baton(&(ctx->log_msg_baton3),
opt_state, base_dir,
ctx->config, pool));
if (opt_state->depth < svn_depth_infinity)
{
cwnb.wrapped_func = ctx->notify_func2;
cwnb.wrapped_baton = ctx->notify_baton2;
cwnb.depth = opt_state->depth;
cwnb.warned = FALSE;
ctx->notify_func2 = copy_warning_notify_func;
ctx->notify_baton2 = &cwnb;
}
err = svn_client_commit5(targets,
opt_state->depth,
no_unlock,
opt_state->keep_changelists,
TRUE ,
opt_state->changelists,
opt_state->revprop_table,
(opt_state->quiet
? NULL : svn_cl__print_commit_info),
NULL,
ctx,
pool);
SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3, err, pool));
return SVN_NO_ERROR;
}