#include "svn_pools.h"
#include "svn_client.h"
#include "svn_path.h"
#include "svn_error_codes.h"
#include "svn_error.h"
#include "cl.h"
#include "svn_private_config.h"
static svn_error_t *
print_update_summary(apr_array_header_t *targets,
apr_array_header_t *result_revs,
apr_pool_t *scratch_pool)
{
int i;
const char *path_prefix;
apr_pool_t *iterpool;
if (targets->nelts < 2)
return SVN_NO_ERROR;
SVN_ERR(svn_dirent_get_absolute(&path_prefix, "", scratch_pool));
SVN_ERR(svn_cmdline_printf(scratch_pool, _("Summary of updates:\n")));
iterpool = svn_pool_create(scratch_pool);
for (i = 0; i < targets->nelts; i++)
{
const char *path = APR_ARRAY_IDX(targets, i, const char *);
svn_revnum_t rev = SVN_INVALID_REVNUM;
svn_pool_clear(iterpool);
SVN_ERR_ASSERT(! svn_path_is_url(path));
if (i < result_revs->nelts)
rev = APR_ARRAY_IDX(result_revs, i, svn_revnum_t);
if (! SVN_IS_VALID_REVNUM(rev))
continue;
if (! svn_dirent_is_absolute(path))
SVN_ERR(svn_dirent_get_absolute(&path, path, iterpool));
SVN_ERR(svn_cmdline_printf(iterpool, _(" Updated '%s' to r%ld.\n"),
svn_cl__local_style_skip_ancestor(
path_prefix, path, iterpool),
rev));
}
svn_pool_destroy(iterpool);
return SVN_NO_ERROR;
}
svn_error_t *
svn_cl__update(apr_getopt_t *os,
void *baton,
apr_pool_t *scratch_pool)
{
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;
svn_depth_t depth;
svn_boolean_t depth_is_sticky;
struct svn_cl__check_externals_failed_notify_baton nwb;
apr_array_header_t *result_revs;
SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
opt_state->targets,
ctx, FALSE,
scratch_pool));
svn_opt_push_implicit_dot_target(targets, scratch_pool);
SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
if (opt_state->changelists)
{
svn_depth_t cl_depth = opt_state->depth;
if (cl_depth == svn_depth_unknown)
cl_depth = svn_depth_infinity;
SVN_ERR(svn_cl__changelist_paths(&targets,
opt_state->changelists, targets,
cl_depth, ctx, scratch_pool,
scratch_pool));
}
if (opt_state->set_depth != svn_depth_unknown)
{
depth = opt_state->set_depth;
depth_is_sticky = TRUE;
}
else
{
depth = opt_state->depth;
depth_is_sticky = FALSE;
}
nwb.wrapped_func = ctx->notify_func2;
nwb.wrapped_baton = ctx->notify_baton2;
nwb.had_externals_error = FALSE;
ctx->notify_func2 = svn_cl__check_externals_failed_notify_wrapper;
ctx->notify_baton2 = &nwb;
SVN_ERR(svn_client_update4(&result_revs, targets,
&(opt_state->start_revision),
depth, depth_is_sticky,
opt_state->ignore_externals,
opt_state->force, TRUE ,
opt_state->parents,
ctx, scratch_pool));
if (! opt_state->quiet)
{
SVN_ERR(print_update_summary(targets, result_revs, scratch_pool));
SVN_ERR(svn_cl__print_conflict_stats(nwb.wrapped_baton, scratch_pool));
}
if (nwb.had_externals_error)
return svn_error_create(SVN_ERR_CL_ERROR_PROCESSING_EXTERNALS, NULL,
_("Failure occurred processing one or more "
"externals definitions"));
return SVN_NO_ERROR;
}