~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/clients/cmdline/proplist-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
 * proplist-cmd.c -- List properties of 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_path.h"
 
30
#include "cl.h"
 
31
 
 
32
#include "svn_private_config.h"
 
33
 
 
34
 
 
35
/*** Code. ***/
 
36
 
 
37
/* This implements the `svn_opt_subcommand_t' interface. */
 
38
svn_error_t *
 
39
svn_cl__proplist (apr_getopt_t *os,
 
40
                  void *baton,
 
41
                  apr_pool_t *pool)
 
42
{
 
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
  int i;
 
47
 
 
48
  /* Suck up all remaining args in the target array. */
 
49
  SVN_ERR (svn_opt_args_to_target_array2 (&targets, os, 
 
50
                                          opt_state->targets, pool));
 
51
 
 
52
  /* Add "." if user passed 0 arguments */
 
53
  svn_opt_push_implicit_dot_target (targets, pool);
 
54
 
 
55
  if (opt_state->revprop)  /* operate on revprops */
 
56
    {
 
57
      svn_revnum_t rev;
 
58
      const char *URL, *target;
 
59
      apr_hash_t *proplist;
 
60
 
 
61
      /* All property commands insist on a specific revision when
 
62
         operating on revprops. */
 
63
      if (opt_state->start_revision.kind == svn_opt_revision_unspecified)
 
64
        return svn_cl__revprop_no_rev_error (pool);
 
65
 
 
66
      /* Else some revision was specified, so proceed. */
 
67
 
 
68
      /* Either we have a URL target, or an implicit wc-path ('.')
 
69
         which needs to be converted to a URL. */
 
70
      if (targets->nelts <= 0)
 
71
        return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,
 
72
                                _("No URL target available"));
 
73
      target = ((const char **) (targets->elts))[0];
 
74
      SVN_ERR (svn_client_url_from_path (&URL, target, pool));
 
75
      if (URL == NULL)
 
76
        return svn_error_create
 
77
          (SVN_ERR_UNVERSIONED_RESOURCE, NULL,
 
78
           _("Either a URL or versioned item is required"));
 
79
 
 
80
      /* Let libsvn_client do the real work. */
 
81
      SVN_ERR (svn_client_revprop_list (&proplist, 
 
82
                                        URL, &(opt_state->start_revision),
 
83
                                        &rev, ctx, pool));
 
84
      
 
85
      SVN_ERR
 
86
        (svn_cmdline_printf (pool,
 
87
                             _("Unversioned properties on revision %ld:\n"),
 
88
                             rev));
 
89
 
 
90
      SVN_ERR (svn_cl__print_prop_hash
 
91
               (proplist, (! opt_state->verbose), pool));
 
92
    }
 
93
  else  /* operate on normal, versioned properties (not revprops) */
 
94
    {
 
95
      apr_pool_t *subpool = svn_pool_create (pool);
 
96
 
 
97
      for (i = 0; i < targets->nelts; i++)
 
98
        {
 
99
          const char *target = ((const char **) (targets->elts))[i];
 
100
          apr_array_header_t *props;
 
101
          int j;
 
102
          svn_error_t *err;
 
103
          svn_boolean_t is_url = svn_path_is_url (target);
 
104
          const char *truepath;
 
105
          svn_opt_revision_t peg_revision;
 
106
 
 
107
          svn_pool_clear (subpool);
 
108
          SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
 
109
 
 
110
          /* Check for a peg revision. */
 
111
          SVN_ERR (svn_opt_parse_path (&peg_revision, &truepath, target,
 
112
                                       subpool));
 
113
          
 
114
          err = svn_client_proplist2 (&props, truepath, &peg_revision,
 
115
                                      &(opt_state->start_revision),
 
116
                                      opt_state->recursive, ctx, subpool);
 
117
          if (err)
 
118
            {
 
119
              if (err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
 
120
                {
 
121
                  if (!opt_state->quiet)
 
122
                    {
 
123
                      svn_handle_warning (stderr, err);
 
124
                    }
 
125
                  svn_error_clear (err);
 
126
                  continue;
 
127
                }
 
128
              else
 
129
                return err;
 
130
            }
 
131
 
 
132
          for (j = 0; j < props->nelts; ++j)
 
133
            {
 
134
              svn_client_proplist_item_t *item 
 
135
                = ((svn_client_proplist_item_t **)props->elts)[j];
 
136
              const char *name_local;
 
137
 
 
138
              if (! is_url)
 
139
                name_local = svn_path_local_style (item->node_name->data,
 
140
                                                   subpool);
 
141
              else
 
142
                name_local = item->node_name->data;
 
143
 
 
144
              SVN_ERR (svn_cmdline_printf(subpool, "Properties on '%s':\n",
 
145
                                          name_local));
 
146
              SVN_ERR (svn_cl__print_prop_hash
 
147
                       (item->prop_hash, (! opt_state->verbose), subpool));
 
148
            }
 
149
        }
 
150
      svn_pool_destroy (subpool);
 
151
    }
 
152
 
 
153
  return SVN_NO_ERROR;
 
154
}