~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/clients/cmdline/propdel-cmd.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * propdel-cmd.c -- Remove property from files/dirs
 
3
 *
 
4
 * ====================================================================
 
5
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 
6
 *
 
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.
 
12
 *
 
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
 * ====================================================================
 
17
 */
 
18
 
 
19
/* ==================================================================== */
 
20
 
 
21
 
 
22
 
 
23
/*** Includes. ***/
 
24
 
 
25
#include "svn_cmdline.h"
 
26
#include "svn_pools.h"
 
27
#include "svn_client.h"
 
28
#include "svn_error.h"
 
29
#include "svn_utf.h"
 
30
#include "svn_path.h"
 
31
#include "cl.h"
 
32
 
 
33
#include "svn_private_config.h"
 
34
 
 
35
 
 
36
/*** Code. ***/
 
37
 
 
38
/* This implements the `svn_opt_subcommand_t' interface. */
 
39
svn_error_t *
 
40
svn_cl__propdel (apr_getopt_t *os,
 
41
                 void *baton,
 
42
                 apr_pool_t *pool)
 
43
{
 
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;
 
48
  int i;
 
49
 
 
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));
 
54
 
 
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));
 
58
 
 
59
  /* Add "." if user passed 0 file arguments */
 
60
  svn_opt_push_implicit_dot_target (targets, pool);
 
61
 
 
62
  if (opt_state->revprop)  /* operate on a revprop */
 
63
    {
 
64
      svn_revnum_t rev;
 
65
      const char *URL, *target;
 
66
 
 
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);
 
71
 
 
72
      /* Else some revision was specified, so proceed. */
 
73
 
 
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));  
 
81
      if (URL == NULL)
 
82
        return svn_error_create
 
83
          (SVN_ERR_UNVERSIONED_RESOURCE, NULL,
 
84
           _("Either a URL or versioned item is required"));
 
85
 
 
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) 
 
91
        {
 
92
          SVN_ERR (svn_cmdline_printf (pool,
 
93
                                       _("property '%s' deleted from"
 
94
                                         " repository revision %ld\n"),
 
95
                                       pname_utf8, rev));
 
96
        }      
 
97
    }
 
98
  else if (opt_state->start_revision.kind != svn_opt_revision_unspecified)
 
99
    {
 
100
      return svn_error_createf
 
101
        (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
 
102
         _("Cannot specify revision for deleting versioned property '%s'"),
 
103
         pname);
 
104
    }
 
105
  else  /* operate on a normal, versioned property (not a revprop) */
 
106
    {
 
107
      apr_pool_t *subpool = svn_pool_create (pool);
 
108
 
 
109
      /* For each target, remove the property PNAME. */
 
110
      for (i = 0; i < targets->nelts; i++)
 
111
        {
 
112
          const char *target = ((const char **) (targets->elts))[i];
 
113
          svn_boolean_t success;
 
114
 
 
115
          svn_pool_clear (subpool);
 
116
          SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
 
117
 
 
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),
 
123
                       success);
 
124
          
 
125
          if (success && (! opt_state->quiet))
 
126
            {
 
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)));
 
132
            }
 
133
        }
 
134
      svn_pool_destroy (subpool);
 
135
    }
 
136
 
 
137
  return SVN_NO_ERROR;
 
138
}