2 * changelist-cmd.c -- Associate (or deassociate) a wc path with a changelist.
4 * ====================================================================
5 * Copyright (c) 2006-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 /* ==================================================================== */
25 #include "svn_client.h"
26 #include "svn_error_codes.h"
27 #include "svn_error.h"
30 #include "svn_private_config.h"
36 /* This implements the `svn_opt_subcommand_t' interface. */
38 svn_cl__changelist(apr_getopt_t
*os
,
42 const char *changelist_name
= NULL
;
43 svn_cl__opt_state_t
*opt_state
= ((svn_cl__cmd_baton_t
*) baton
)->opt_state
;
44 svn_client_ctx_t
*ctx
= ((svn_cl__cmd_baton_t
*) baton
)->ctx
;
45 apr_array_header_t
*targets
;
46 svn_depth_t depth
= opt_state
->depth
;
48 /* If we're not removing changelists, then our first argument should
49 be the name of a changelist. */
51 if (! opt_state
->remove
)
53 apr_array_header_t
*args
;
54 SVN_ERR(svn_opt_parse_num_args(&args
, os
, 1, pool
));
55 changelist_name
= APR_ARRAY_IDX(args
, 0, const char *);
56 SVN_ERR(svn_utf_cstring_to_utf8(&changelist_name
,
57 changelist_name
, pool
));
60 /* Parse the remaining arguments as paths. */
61 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets
, os
,
65 /* Changelist has no implicit dot-target `.', so don't you put that
68 return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS
, 0, NULL
);
70 if (! opt_state
->quiet
)
71 svn_cl__get_notifier(&ctx
->notify_func2
, &ctx
->notify_baton2
, FALSE
,
74 /* FIXME: This is required because svn_client_create_context()
75 always initializes ctx->notify_func2 to a wrapper function
76 which calls ctx->notify_func() if it isn't NULL. In other
77 words, typically, ctx->notify_func2 is never NULL. This isn't
78 usually a problem, but the changelist logic generates
79 svn_error_t's as part of its notification.
81 So, svn_wc_set_changelist() checks its notify_func (our
82 ctx->notify_func2) for NULL-ness, and seeing non-NULL-ness,
83 generates a notificaton object and svn_error_t to describe some
84 problem. It passes that off to its notify_func (our
85 ctx->notify_func2) which drops the notification on the floor
86 (because it wraps a NULL ctx->notify_func). But svn_error_t's
87 dropped on the floor cause SEGFAULTs at pool cleanup time --
88 they need instead to be cleared.
90 SOOOooo... we set our ctx->notify_func2 to NULL so the WC code
91 doesn't even generate the errors. */
92 ctx
->notify_func2
= NULL
;
94 if (depth
== svn_depth_unknown
)
95 depth
= svn_depth_empty
;
100 (svn_client_add_to_changelist(targets
, changelist_name
,
101 depth
, opt_state
->changelists
,
103 NULL
, opt_state
->quiet
,
104 SVN_ERR_UNVERSIONED_RESOURCE
,
105 SVN_ERR_WC_PATH_NOT_FOUND
,
111 (svn_client_remove_from_changelists(targets
, depth
,
112 opt_state
->changelists
,
114 NULL
, opt_state
->quiet
,
115 SVN_ERR_UNVERSIONED_RESOURCE
,
116 SVN_ERR_WC_PATH_NOT_FOUND
,