2
* proplist-cmd.c -- List properties of 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"
32
#include "svn_private_config.h"
37
/* This implements the `svn_opt_subcommand_t' interface. */
39
svn_cl__proplist (apr_getopt_t *os,
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;
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));
52
/* Add "." if user passed 0 arguments */
53
svn_opt_push_implicit_dot_target (targets, pool);
55
if (opt_state->revprop) /* operate on revprops */
58
const char *URL, *target;
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);
66
/* Else some revision was specified, so proceed. */
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));
76
return svn_error_create
77
(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
78
_("Either a URL or versioned item is required"));
80
/* Let libsvn_client do the real work. */
81
SVN_ERR (svn_client_revprop_list (&proplist,
82
URL, &(opt_state->start_revision),
86
(svn_cmdline_printf (pool,
87
_("Unversioned properties on revision %ld:\n"),
90
SVN_ERR (svn_cl__print_prop_hash
91
(proplist, (! opt_state->verbose), pool));
93
else /* operate on normal, versioned properties (not revprops) */
95
apr_pool_t *subpool = svn_pool_create (pool);
97
for (i = 0; i < targets->nelts; i++)
99
const char *target = ((const char **) (targets->elts))[i];
100
apr_array_header_t *props;
103
svn_boolean_t is_url = svn_path_is_url (target);
104
const char *truepath;
105
svn_opt_revision_t peg_revision;
107
svn_pool_clear (subpool);
108
SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
110
/* Check for a peg revision. */
111
SVN_ERR (svn_opt_parse_path (&peg_revision, &truepath, target,
114
err = svn_client_proplist2 (&props, truepath, &peg_revision,
115
&(opt_state->start_revision),
116
opt_state->recursive, ctx, subpool);
119
if (err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
121
if (!opt_state->quiet)
123
svn_handle_warning (stderr, err);
125
svn_error_clear (err);
132
for (j = 0; j < props->nelts; ++j)
134
svn_client_proplist_item_t *item
135
= ((svn_client_proplist_item_t **)props->elts)[j];
136
const char *name_local;
139
name_local = svn_path_local_style (item->node_name->data,
142
name_local = item->node_name->data;
144
SVN_ERR (svn_cmdline_printf(subpool, "Properties on '%s':\n",
146
SVN_ERR (svn_cl__print_prop_hash
147
(item->prop_hash, (! opt_state->verbose), subpool));
150
svn_pool_destroy (subpool);