2 * changelist-cmd.c -- Associate (or deassociate) a wc path with a changelist.
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
24 #include "svn_client.h"
25 #include "svn_error_codes.h"
26 #include "svn_error.h"
32 #include "svn_private_config.h"
37 /* This implements the `svn_opt_subcommand_t' interface. */
39 svn_cl__changelist(apr_getopt_t *os,
43 const char *changelist_name = NULL;
44 svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
45 svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
46 apr_array_header_t *targets;
47 svn_depth_t depth = opt_state->depth;
48 apr_array_header_t *errors = apr_array_make(pool, 0, sizeof(apr_status_t));
50 /* If we're not removing changelists, then our first argument should
51 be the name of a changelist. */
53 if (! opt_state->remove)
55 apr_array_header_t *args;
56 SVN_ERR(svn_opt_parse_num_args(&args, os, 1, pool));
57 changelist_name = APR_ARRAY_IDX(args, 0, const char *);
58 SVN_ERR(svn_utf_cstring_to_utf8(&changelist_name,
59 changelist_name, pool));
62 /* Parse the remaining arguments as paths. */
63 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
67 /* Changelist has no implicit dot-target `.', so don't you put that
70 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
72 SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
75 ctx->notify_func2 = NULL; /* Easy out: avoid unneeded work */
77 if (depth == svn_depth_unknown)
78 depth = svn_depth_empty;
80 SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
85 svn_client_add_to_changelist(targets, changelist_name,
86 depth, opt_state->changelists,
88 errors, opt_state->quiet,
89 SVN_ERR_UNVERSIONED_RESOURCE,
90 SVN_ERR_WC_PATH_NOT_FOUND,
96 svn_client_remove_from_changelists(targets, depth,
97 opt_state->changelists,
99 errors, opt_state->quiet,
100 SVN_ERR_UNVERSIONED_RESOURCE,
101 SVN_ERR_WC_PATH_NOT_FOUND,
105 if (errors->nelts > 0)
110 err = svn_error_create(SVN_ERR_ILLEGAL_TARGET, NULL, NULL);
111 for (i = 0; i < errors->nelts; i++)
113 apr_status_t status = APR_ARRAY_IDX(errors, i, apr_status_t);
115 if (status == SVN_ERR_WC_PATH_NOT_FOUND)
116 err = svn_error_quick_wrap(err,
117 _("Could not set changelists on "
118 "all targets because some targets "
120 else if (status == SVN_ERR_UNVERSIONED_RESOURCE)
121 err = svn_error_quick_wrap(err,
122 _("Could not set changelists on "
123 "all targets because some targets "
124 "are not versioned"));
127 return svn_error_trace(err);