1/* 2 * propdel-cmd.c -- Remove property from files/dirs 3 * 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 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 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 20 * under the License. 21 * ==================================================================== 22 */ 23 24/* ==================================================================== */ 25 26 27 28/*** Includes. ***/ 29 30#include "svn_cmdline.h" 31#include "svn_pools.h" 32#include "svn_client.h" 33#include "svn_error_codes.h" 34#include "svn_error.h" 35#include "svn_utf.h" 36#include "svn_path.h" 37#include "cl.h" 38 39#include "svn_private_config.h" 40 41 42/*** Code. ***/ 43 44/* This implements the `svn_opt_subcommand_t' interface. */ 45svn_error_t * 46svn_cl__propdel(apr_getopt_t *os, 47 void *baton, 48 apr_pool_t *pool) 49{ 50 svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state; 51 svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx; 52 const char *pname, *pname_utf8; 53 apr_array_header_t *args, *targets; 54 55 /* Get the property's name (and a UTF-8 version of that name). */ 56 SVN_ERR(svn_opt_parse_num_args(&args, os, 1, pool)); 57 pname = APR_ARRAY_IDX(args, 0, const char *); 58 SVN_ERR(svn_utf_cstring_to_utf8(&pname_utf8, pname, pool)); 59 /* No need to check svn_prop_name_is_valid for *deleting* 60 properties, and it may even be useful to allow, in case invalid 61 properties sneaked through somehow. */ 62 63 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os, 64 opt_state->targets, 65 ctx, FALSE, pool)); 66 67 68 /* Add "." if user passed 0 file arguments */ 69 svn_opt_push_implicit_dot_target(targets, pool); 70 SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool)); 71 72 if (opt_state->revprop) /* operate on a revprop */ 73 { 74 svn_revnum_t rev; 75 const char *URL; 76 77 SVN_ERR(svn_cl__revprop_prepare(&opt_state->start_revision, targets, 78 &URL, ctx, pool)); 79 80 /* Let libsvn_client do the real work. */ 81 SVN_ERR(svn_client_revprop_set2(pname_utf8, NULL, NULL, 82 URL, &(opt_state->start_revision), 83 &rev, FALSE, ctx, pool)); 84 } 85 else if (opt_state->start_revision.kind != svn_opt_revision_unspecified) 86 { 87 return svn_error_createf(SVN_ERR_CLIENT_PROPERTY_NAME, NULL, 88 _("Cannot specify revision for deleting versioned property '%s'"), 89 pname); 90 } 91 else /* operate on a normal, versioned property (not a revprop) */ 92 { 93 if (opt_state->depth == svn_depth_unknown) 94 opt_state->depth = svn_depth_empty; 95 96 /* For each target, remove the property PNAME. */ 97 SVN_ERR(svn_client_propset_local(pname_utf8, NULL, targets, 98 opt_state->depth, FALSE, 99 opt_state->changelists, ctx, pool)); 100 } 101 102 return SVN_NO_ERROR; 103} 104