2 * propdel-cmd.c -- Remove property from files/dirs
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 /* ==================================================================== */
25 #include "svn_cmdline.h"
26 #include "svn_pools.h"
27 #include "svn_client.h"
28 #include "svn_error_codes.h"
29 #include "svn_error.h"
34 #include "svn_private_config.h"
39 /* This implements the `svn_opt_subcommand_t' interface. */
41 svn_cl__propdel(apr_getopt_t
*os
,
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 const char *pname
, *pname_utf8
;
48 apr_array_header_t
*args
, *targets
;
51 /* Get the property's name (and a UTF-8 version of that name). */
52 SVN_ERR(svn_opt_parse_num_args(&args
, os
, 1, pool
));
53 pname
= APR_ARRAY_IDX(args
, 0, const char *);
54 SVN_ERR(svn_utf_cstring_to_utf8(&pname_utf8
, pname
, pool
));
55 /* No need to check svn_prop_name_is_valid for *deleting*
56 properties, and it may even be useful to allow, in case invalid
57 properties sneaked through somehow. */
59 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets
, os
,
64 /* Add "." if user passed 0 file arguments */
65 svn_opt_push_implicit_dot_target(targets
, pool
);
67 if (opt_state
->revprop
) /* operate on a revprop */
72 SVN_ERR(svn_cl__revprop_prepare(&opt_state
->start_revision
, targets
,
75 /* Let libsvn_client do the real work. */
76 SVN_ERR(svn_client_revprop_set(pname_utf8
, NULL
,
77 URL
, &(opt_state
->start_revision
),
78 &rev
, FALSE
, ctx
, pool
));
79 if (! opt_state
->quiet
)
81 SVN_ERR(svn_cmdline_printf(pool
,
82 _("property '%s' deleted from"
83 " repository revision %ld\n"),
87 else if (opt_state
->start_revision
.kind
!= svn_opt_revision_unspecified
)
89 return svn_error_createf
90 (SVN_ERR_CL_ARG_PARSING_ERROR
, NULL
,
91 _("Cannot specify revision for deleting versioned property '%s'"),
94 else /* operate on a normal, versioned property (not a revprop) */
96 apr_pool_t
*subpool
= svn_pool_create(pool
);
98 if (opt_state
->depth
== svn_depth_unknown
)
99 opt_state
->depth
= svn_depth_empty
;
101 /* For each target, remove the property PNAME. */
102 for (i
= 0; i
< targets
->nelts
; i
++)
104 const char *target
= APR_ARRAY_IDX(targets
, i
, const char *);
105 svn_commit_info_t
*commit_info
;
106 svn_boolean_t success
;
108 svn_pool_clear(subpool
);
109 SVN_ERR(svn_cl__check_cancel(ctx
->cancel_baton
));
111 /* Pass FALSE for 'skip_checks' because it doesn't matter here,
112 and opt_state->force doesn't apply to this command anyway. */
113 SVN_ERR(svn_cl__try(svn_client_propset3
114 (&commit_info
, pname_utf8
,
117 FALSE
, SVN_INVALID_REVNUM
,
118 opt_state
->changelists
, ctx
, subpool
),
119 &success
, opt_state
->quiet
,
120 SVN_ERR_UNVERSIONED_RESOURCE
,
121 SVN_ERR_ENTRY_NOT_FOUND
,
124 if (success
&& (! opt_state
->quiet
))
126 SVN_ERR(svn_cmdline_printf
128 SVN_DEPTH_IS_RECURSIVE(opt_state
->depth
)
129 ? _("property '%s' deleted (recursively) from '%s'.\n")
130 : _("property '%s' deleted from '%s'.\n"),
131 pname_utf8
, svn_path_local_style(target
, subpool
)));
134 svn_pool_destroy(subpool
);