2
* propdel-cmd.c -- Remove property from files/dirs
4
* ====================================================================
5
* Copyright (c) 2000-2004 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.h"
33
#include "svn_private_config.h"
38
/* This implements the `svn_opt_subcommand_t' interface. */
40
svn_cl__propdel (apr_getopt_t *os,
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
const char *pname, *pname_utf8;
47
apr_array_header_t *args, *targets;
50
/* Get the property's name (and a UTF-8 version of that name). */
51
SVN_ERR (svn_opt_parse_num_args (&args, os, 1, pool));
52
pname = ((const char **) (args->elts))[0];
53
SVN_ERR (svn_utf_cstring_to_utf8 (&pname_utf8, pname, pool));
55
/* Suck up all the remaining arguments into a targets array */
56
SVN_ERR (svn_opt_args_to_target_array2 (&targets, os,
57
opt_state->targets, pool));
59
/* Add "." if user passed 0 file arguments */
60
svn_opt_push_implicit_dot_target (targets, pool);
62
if (opt_state->revprop) /* operate on a revprop */
65
const char *URL, *target;
67
/* All property commands insist on a specific revision when
68
operating on a revprop. */
69
if (opt_state->start_revision.kind == svn_opt_revision_unspecified)
70
return svn_cl__revprop_no_rev_error (pool);
72
/* Else some revision was specified, so proceed. */
74
/* Either we have a URL target, or an implicit wc-path ('.')
75
which needs to be converted to a URL. */
76
if (targets->nelts <= 0)
77
return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,
78
_("No URL target available"));
79
target = ((const char **) (targets->elts))[0];
80
SVN_ERR (svn_client_url_from_path (&URL, target, pool));
82
return svn_error_create
83
(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
84
_("Either a URL or versioned item is required"));
86
/* Let libsvn_client do the real work. */
87
SVN_ERR (svn_client_revprop_set (pname_utf8, NULL,
88
URL, &(opt_state->start_revision),
89
&rev, FALSE, ctx, pool));
90
if (! opt_state->quiet)
92
SVN_ERR (svn_cmdline_printf (pool,
93
_("property '%s' deleted from"
94
" repository revision %ld\n"),
98
else if (opt_state->start_revision.kind != svn_opt_revision_unspecified)
100
return svn_error_createf
101
(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
102
_("Cannot specify revision for deleting versioned property '%s'"),
105
else /* operate on a normal, versioned property (not a revprop) */
107
apr_pool_t *subpool = svn_pool_create (pool);
109
/* For each target, remove the property PNAME. */
110
for (i = 0; i < targets->nelts; i++)
112
const char *target = ((const char **) (targets->elts))[i];
113
svn_boolean_t success;
115
svn_pool_clear (subpool);
116
SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
118
/* Pass 0 for 'force' because it doesn't matter here, and
119
opt_state->force doesn't apply to this command anyway. */
120
SVN_CL__TRY (svn_client_propset2 (pname_utf8, NULL, target,
121
opt_state->recursive,
122
FALSE, ctx, subpool),
125
if (success && (! opt_state->quiet))
127
SVN_ERR (svn_cmdline_printf
128
(subpool, opt_state->recursive
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);