diff options
Diffstat (limited to 'subversion/svn/proplist-cmd.c')
-rw-r--r-- | subversion/svn/proplist-cmd.c | 133 |
1 files changed, 110 insertions, 23 deletions
diff --git a/subversion/svn/proplist-cmd.c b/subversion/svn/proplist-cmd.c index 64cb055..fe23a67 100644 --- a/subversion/svn/proplist-cmd.c +++ b/subversion/svn/proplist-cmd.c @@ -35,8 +35,11 @@ #include "svn_dirent_uri.h" #include "svn_path.h" #include "svn_xml.h" +#include "svn_props.h" #include "cl.h" +#include "private/svn_cmdline_private.h" + #include "svn_private_config.h" typedef struct proplist_baton_t @@ -48,43 +51,81 @@ typedef struct proplist_baton_t /*** Code. ***/ -/* This implements the svn_proplist_receiver_t interface, printing XML to +/* This implements the svn_proplist_receiver2_t interface, printing XML to stdout. */ static svn_error_t * proplist_receiver_xml(void *baton, const char *path, apr_hash_t *prop_hash, + apr_array_header_t *inherited_props, apr_pool_t *pool) { svn_cl__opt_state_t *opt_state = ((proplist_baton_t *)baton)->opt_state; svn_boolean_t is_url = ((proplist_baton_t *)baton)->is_url; - svn_stringbuf_t *sb = NULL; + svn_stringbuf_t *sb; const char *name_local; + if (inherited_props && inherited_props->nelts) + { + int i; + apr_pool_t *iterpool = svn_pool_create(pool); + + for (i = 0; i < inherited_props->nelts; i++) + { + svn_prop_inherited_item_t *iprop = + APR_ARRAY_IDX(inherited_props, i, svn_prop_inherited_item_t *); + + sb = NULL; + + if (svn_path_is_url(iprop->path_or_url)) + name_local = iprop->path_or_url; + else + name_local = svn_dirent_local_style(iprop->path_or_url, iterpool); + + svn_xml_make_open_tag(&sb, iterpool, svn_xml_normal, "target", + "path", name_local, NULL); + SVN_ERR(svn_cmdline__print_xml_prop_hash(&sb, iprop->prop_hash, + (! opt_state->verbose), + TRUE, iterpool)); + svn_xml_make_close_tag(&sb, iterpool, "target"); + SVN_ERR(svn_cl__error_checked_fputs(sb->data, stdout)); + } + svn_pool_destroy(iterpool); + } + if (! is_url) name_local = svn_dirent_local_style(path, pool); else name_local = path; - /* "<target ...>" */ - svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "target", - "path", name_local, NULL); + sb = NULL; + - SVN_ERR(svn_cl__print_xml_prop_hash(&sb, prop_hash, (! opt_state->verbose), - pool)); + if (prop_hash) + { + /* "<target ...>" */ + svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "target", + "path", name_local, NULL); - /* "</target>" */ - svn_xml_make_close_tag(&sb, pool, "target"); + SVN_ERR(svn_cmdline__print_xml_prop_hash(&sb, prop_hash, + (! opt_state->verbose), + FALSE, pool)); + + /* "</target>" */ + svn_xml_make_close_tag(&sb, pool, "target"); + SVN_ERR(svn_cl__error_checked_fputs(sb->data, stdout)); + } - return svn_cl__error_checked_fputs(sb->data, stdout); + return SVN_NO_ERROR; } -/* This implements the svn_proplist_receiver_t interface. */ +/* This implements the svn_proplist_receiver2_t interface. */ static svn_error_t * proplist_receiver(void *baton, const char *path, apr_hash_t *prop_hash, + apr_array_header_t *inherited_props, apr_pool_t *pool) { svn_cl__opt_state_t *opt_state = ((proplist_baton_t *)baton)->opt_state; @@ -96,10 +137,48 @@ proplist_receiver(void *baton, else name_local = path; - if (!opt_state->quiet) - SVN_ERR(svn_cmdline_printf(pool, _("Properties on '%s':\n"), name_local)); - return svn_cl__print_prop_hash(NULL, prop_hash, (! opt_state->verbose), - pool); + if (inherited_props) + { + int i; + apr_pool_t *iterpool = svn_pool_create(pool); + + for (i = 0; i < inherited_props->nelts; i++) + { + svn_prop_inherited_item_t *iprop = + APR_ARRAY_IDX(inherited_props, i, svn_prop_inherited_item_t *); + + svn_pool_clear(iterpool); + + if (!opt_state->quiet) + { + if (svn_path_is_url(iprop->path_or_url)) + SVN_ERR(svn_cmdline_printf( + iterpool, _("Inherited properties on '%s',\nfrom '%s':\n"), + name_local, iprop->path_or_url)); + else + SVN_ERR(svn_cmdline_printf( + iterpool, _("Inherited properties on '%s',\nfrom '%s':\n"), + name_local, svn_dirent_local_style(iprop->path_or_url, + iterpool))); + } + + SVN_ERR(svn_cmdline__print_prop_hash(NULL, iprop->prop_hash, + (! opt_state->verbose), + iterpool)); + } + svn_pool_destroy(iterpool); + } + + if (prop_hash && apr_hash_count(prop_hash)) + { + if (!opt_state->quiet) + SVN_ERR(svn_cmdline_printf(pool, _("Properties on '%s':\n"), + name_local)); + SVN_ERR(svn_cmdline__print_prop_hash(NULL, prop_hash, + (! opt_state->verbose), pool)); + } + + return SVN_NO_ERROR; } @@ -129,6 +208,11 @@ svn_cl__proplist(apr_getopt_t *os, const char *URL; apr_hash_t *proplist; + if (opt_state->show_inherited_props) + return svn_error_create( + SVN_ERR_CL_ARG_PARSING_ERROR, NULL, + _("--show-inherited-props can't be used with --revprop")); + SVN_ERR(svn_cl__revprop_prepare(&opt_state->start_revision, targets, &URL, ctx, scratch_pool)); @@ -147,8 +231,9 @@ svn_cl__proplist(apr_getopt_t *os, svn_xml_make_open_tag(&sb, scratch_pool, svn_xml_normal, "revprops", "rev", revstr, NULL); - SVN_ERR(svn_cl__print_xml_prop_hash - (&sb, proplist, (! opt_state->verbose), scratch_pool)); + SVN_ERR(svn_cmdline__print_xml_prop_hash(&sb, proplist, + (! opt_state->verbose), + FALSE, scratch_pool)); svn_xml_make_close_tag(&sb, scratch_pool, "revprops"); SVN_ERR(svn_cl__error_checked_fputs(sb->data, stdout)); @@ -161,15 +246,16 @@ svn_cl__proplist(apr_getopt_t *os, _("Unversioned properties on revision %ld:\n"), rev)); - SVN_ERR(svn_cl__print_prop_hash - (NULL, proplist, (! opt_state->verbose), scratch_pool)); + SVN_ERR(svn_cmdline__print_prop_hash(NULL, proplist, + (! opt_state->verbose), + scratch_pool)); } } else /* operate on normal, versioned properties (not revprops) */ { int i; apr_pool_t *iterpool; - svn_proplist_receiver_t pl_receiver; + svn_proplist_receiver2_t pl_receiver; if (opt_state->xml) { @@ -203,10 +289,11 @@ svn_cl__proplist(apr_getopt_t *os, iterpool)); SVN_ERR(svn_cl__try( - svn_client_proplist3(truepath, &peg_revision, + svn_client_proplist4(truepath, &peg_revision, &(opt_state->start_revision), opt_state->depth, opt_state->changelists, + opt_state->show_inherited_props, pl_receiver, &pl_baton, ctx, iterpool), errors, opt_state->quiet, @@ -223,12 +310,12 @@ svn_cl__proplist(apr_getopt_t *os, if (errors->nelts > 0) { svn_error_t *err; - + err = svn_error_create(SVN_ERR_ILLEGAL_TARGET, NULL, NULL); for (i = 0; i < errors->nelts; i++) { apr_status_t status = APR_ARRAY_IDX(errors, i, apr_status_t); - + if (status == SVN_ERR_ENTRY_NOT_FOUND) err = svn_error_quick_wrap(err, _("Could not display properties " |