Modified: subversion/branches/inheritable-props/subversion/svn/propget-cmd.c URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/svn/propget-cmd.c?rev=1301211&r1=1301210&r2=1301211&view=diff ============================================================================== --- subversion/branches/inheritable-props/subversion/svn/propget-cmd.c (original) +++ subversion/branches/inheritable-props/subversion/svn/propget-cmd.c Thu Mar 15 21:31:45 2012 @@ -95,21 +95,108 @@ print_properties_xml(const char *pname, return SVN_NO_ERROR; } +/* Print the property PNAME_UTF with the value PROPVAL set on ABSPATH_OR_URL + to the stream OUT. -/* Print the properties in PROPS to the stream OUT. PROPS is a hash mapping - * (const char *) path to (svn_string_t) property value. - * If IS_URL is true, all paths are URLs, else all paths are local paths. - * PNAME_UTF8 is the property name of all the properties. - * If PRINT_FILENAMES is true, print the item's path before each property. - * If OMIT_NEWLINE is true, don't add a newline at the end of each property. - * If LIKE_PROPLIST is true, print everything in a more verbose format - * like "svn proplist -v" does. - * */ + If INHERITED_PROPERTY is true then the property described is inherited, + otherwise it is explicit. + + WC_PATH_PREFIX is the absolute path of the current working directory (and + is ignored if ABSPATH_OR_URL is a URL). + + All other arguments are as per print_properties. */ +static svn_error_t * +print_single_prop(svn_string_t *propval, + const char *abspath_or_URL, + const char *wc_path_prefix, + svn_stream_t *out, + const char *pname_utf8, + svn_boolean_t print_filenames, + svn_boolean_t omit_newline, + svn_boolean_t like_proplist, + svn_boolean_t inherited_property, + apr_pool_t *scratch_pool) +{ + if (print_filenames) + { + const char *header; + + /* Print the file name. */ + + if (! svn_path_is_url(abspath_or_URL)) + abspath_or_URL = svn_cl__local_style_skip_ancestor(wc_path_prefix, + abspath_or_URL, + scratch_pool); + + /* In verbose mode, print exactly same as "proplist" does; + * otherwise, print a brief header. */ + if (inherited_property) + header = apr_psprintf(scratch_pool, like_proplist + ? _("Properties inherited from '%s':\n") + : "%s - ", abspath_or_URL); + else + header = apr_psprintf(scratch_pool, like_proplist + ? _("Properties on '%s':\n") + : "%s - ", abspath_or_URL); + SVN_ERR(svn_cmdline_cstring_from_utf8(&header, header, scratch_pool)); + SVN_ERR(svn_subst_translate_cstring2(header, &header, + APR_EOL_STR, /* 'native' eol */ + FALSE, /* no repair */ + NULL, /* no keywords */ + FALSE, /* no expansion */ + scratch_pool)); + SVN_ERR(stream_write(out, header, strlen(header))); + } + + if (like_proplist) + { + /* Print the property name and value just as "proplist -v" does */ + apr_hash_t *hash = apr_hash_make(scratch_pool); + + apr_hash_set(hash, pname_utf8, APR_HASH_KEY_STRING, propval); + SVN_ERR(svn_cl__print_prop_hash(out, hash, FALSE, scratch_pool)); + } + else + { + /* If this is a special Subversion property, it is stored as + UTF8, so convert to the native format. */ + if (svn_prop_needs_translation(pname_utf8)) + SVN_ERR(svn_subst_detranslate_string(&propval, propval, + TRUE, scratch_pool)); + + SVN_ERR(stream_write(out, propval->data, propval->len)); + + if (! omit_newline) + SVN_ERR(stream_write(out, APR_EOL_STR, + strlen(APR_EOL_STR))); + } + return SVN_NO_ERROR; +} + +/* Print the properties in PROPS and/or *INHERITED_PROPS to the stream OUT. + PROPS is a hash mapping (const char *) path to (svn_string_t) property + value. INHERITED_PROPS is a depth-first ordered array of + svn_prop_inherited_item_t * structures. + + PROPS may be an empty hash, but is never null. INHERITED_PROPS may be + null. + + If IS_URL is true, all paths in PROPS are URLs, else all paths are local + paths. + + PNAME_UTF8 is the property name of all the properties. + + If PRINT_FILENAMES is true, print the item's path before each property. + + If OMIT_NEWLINE is true, don't add a newline at the end of each property. + + If LIKE_PROPLIST is true, print everything in a more verbose format + like "svn proplist -v" does. */ static svn_error_t * print_properties(svn_stream_t *out, - svn_boolean_t is_url, const char *pname_utf8, apr_hash_t *props, + apr_array_header_t *inherited_props, svn_boolean_t print_filenames, svn_boolean_t omit_newline, svn_boolean_t like_proplist, @@ -121,60 +208,37 @@ print_properties(svn_stream_t *out, SVN_ERR(svn_dirent_get_absolute(&path_prefix, "", pool)); - for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi)) + if (inherited_props) { - const char *filename = svn__apr_hash_index_key(hi); - svn_string_t *propval = svn__apr_hash_index_val(hi); + int i; svn_pool_clear(iterpool); - if (print_filenames) + for (i = 0; i < inherited_props->nelts; i++) { - const char *header; - - /* Print the file name. */ - - if (! is_url) - filename = svn_cl__local_style_skip_ancestor(path_prefix, filename, - iterpool); - - /* In verbose mode, print exactly same as "proplist" does; - * otherwise, print a brief header. */ - header = apr_psprintf(iterpool, like_proplist - ? _("Properties on '%s':\n") - : "%s - ", filename); - SVN_ERR(svn_cmdline_cstring_from_utf8(&header, header, iterpool)); - SVN_ERR(svn_subst_translate_cstring2(header, &header, - APR_EOL_STR, /* 'native' eol */ - FALSE, /* no repair */ - NULL, /* no keywords */ - FALSE, /* no expansion */ - iterpool)); - SVN_ERR(stream_write(out, header, strlen(header))); + svn_prop_inherited_item_t *iprop = + APR_ARRAY_IDX(inherited_props, i, svn_prop_inherited_item_t *); + svn_string_t *propval = svn__apr_hash_index_val(apr_hash_first(pool, + iprop->prop_hash)); + SVN_ERR(print_single_prop(propval, + iprop->path_or_url, + path_prefix, out, pname_utf8, + print_filenames, omit_newline, + like_proplist, TRUE, iterpool)); } + } - if (like_proplist) - { - /* Print the property name and value just as "proplist -v" does */ - apr_hash_t *hash = apr_hash_make(iterpool); + for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi)) + { + const char *filename = svn__apr_hash_index_key(hi); + svn_string_t *propval = svn__apr_hash_index_val(hi); - apr_hash_set(hash, pname_utf8, APR_HASH_KEY_STRING, propval); - SVN_ERR(svn_cl__print_prop_hash(out, hash, FALSE, iterpool)); - } - else - { - /* If this is a special Subversion property, it is stored as - UTF8, so convert to the native format. */ - if (svn_prop_needs_translation(pname_utf8)) - SVN_ERR(svn_subst_detranslate_string(&propval, propval, - TRUE, iterpool)); - - SVN_ERR(stream_write(out, propval->data, propval->len)); - - if (! omit_newline) - SVN_ERR(stream_write(out, APR_EOL_STR, - strlen(APR_EOL_STR))); - } + svn_pool_clear(iterpool); + + SVN_ERR(print_single_prop(propval, filename, path_prefix, + out, pname_utf8, print_filenames, + omit_newline, like_proplist, FALSE, + iterpool)); } svn_pool_destroy(iterpool); @@ -227,6 +291,11 @@ svn_cl__propget(apr_getopt_t *os, const char *URL; svn_string_t *propval; + 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, pool)); @@ -303,6 +372,7 @@ svn_cl__propget(apr_getopt_t *os, svn_boolean_t like_proplist; const char *truepath; svn_opt_revision_t peg_revision; + apr_array_header_t *inherited_props; svn_pool_clear(subpool); SVN_ERR(svn_cl__check_cancel(ctx->cancel_baton)); @@ -314,12 +384,15 @@ svn_cl__propget(apr_getopt_t *os, if (!svn_path_is_url(truepath)) SVN_ERR(svn_dirent_get_absolute(&truepath, truepath, subpool)); - SVN_ERR(svn_client_propget4(&props, pname_utf8, truepath, - &peg_revision, - &(opt_state->start_revision), - NULL, opt_state->depth, - opt_state->changelists, ctx, subpool, - subpool)); + SVN_ERR(svn_client_propget5( + &props, + opt_state->show_inherited_props ? &inherited_props : NULL, + pname_utf8, truepath, + &peg_revision, + &(opt_state->start_revision), + NULL, opt_state->depth, + opt_state->changelists, ctx, subpool, + subpool)); /* Any time there is more than one thing to print, or where the path associated with a printed thing is not obvious, @@ -336,9 +409,12 @@ svn_cl__propget(apr_getopt_t *os, if (opt_state->xml) SVN_ERR(print_properties_xml(pname_utf8, props, subpool)); else - SVN_ERR(print_properties(out, svn_path_is_url(target), pname_utf8, - props, print_filenames, omit_newline, - like_proplist, subpool)); + SVN_ERR(print_properties( + out, pname_utf8, + props, + opt_state->show_inherited_props ? inherited_props : NULL, + print_filenames, + omit_newline, like_proplist, subpool)); } if (opt_state->xml)
Modified: subversion/branches/inheritable-props/subversion/svn/proplist-cmd.c URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/svn/proplist-cmd.c?rev=1301211&r1=1301210&r2=1301211&view=diff ============================================================================== --- subversion/branches/inheritable-props/subversion/svn/proplist-cmd.c (original) +++ subversion/branches/inheritable-props/subversion/svn/proplist-cmd.c Thu Mar 15 21:31:45 2012 @@ -35,6 +35,7 @@ #include "svn_dirent_uri.h" #include "svn_path.h" #include "svn_xml.h" +#include "svn_props.h" #include "cl.h" #include "svn_private_config.h" @@ -48,12 +49,13 @@ 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; @@ -80,11 +82,12 @@ proplist_receiver_xml(void *baton, } -/* 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 +99,33 @@ 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; + + 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 *); + if (!opt_state->quiet) + SVN_ERR(svn_cmdline_printf(pool, + _("Properties inherited from '%s':\n"), + iprop->path_or_url)); + SVN_ERR(svn_cl__print_prop_hash(NULL, iprop->prop_hash, + (! opt_state->verbose), pool)); + } + } + + 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_cl__print_prop_hash(NULL, prop_hash, (! opt_state->verbose), + pool)); + } + + return SVN_NO_ERROR; } @@ -129,6 +155,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)); @@ -169,7 +200,7 @@ svn_cl__proplist(apr_getopt_t *os, { int i; apr_pool_t *iterpool; - svn_proplist_receiver_t pl_receiver; + svn_proplist_receiver2_t pl_receiver; if (opt_state->xml) { @@ -203,12 +234,13 @@ 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), + ctx, iterpool, iterpool), errors, opt_state->quiet, SVN_ERR_UNVERSIONED_RESOURCE, SVN_ERR_ENTRY_NOT_FOUND,
