[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1341031 - /subversion/trunk/subversion/svn/props.c

From: Hyrum K Wright <hyrum.wright_at_wandisco.com>
Date: Mon, 21 May 2012 10:05:49 -0500

On Mon, May 21, 2012 at 9:03 AM, <stsp_at_apache.org> wrote:
> Author: stsp
> Date: Mon May 21 14:03:46 2012
> New Revision: 1341031
>
> URL: http://svn.apache.org/viewvc?rev=1341031&view=rev
> Log:
> Make 'svn proplist' print property lists in sorted order.
> Avoids random output ordering with APR-1.4.6.

If we do this on a regular basis, it might be useful to implement a
wrapper which takes a baton and handler function and then calls the
handler with the hash key/value in sorted order. It might add some
overhead, but it also consolidates the sorting into one location,
rather than sprinkled everywhere. It doesn't matter much to me; just
a thought that arose upon review. :)

-Hyrum

> * subversion/svn/props.c
>  (svn_cl__print_prop_hash, svn_cl__print_xml_prop_hash): Iterate over a sorted
>   hash key array rather than iterating over the property hash table itself.
>
> Modified:
>    subversion/trunk/subversion/svn/props.c
>
> Modified: subversion/trunk/subversion/svn/props.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/props.c?rev=1341031&r1=1341030&r2=1341031&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/svn/props.c (original)
> +++ subversion/trunk/subversion/svn/props.c Mon May 21 14:03:46 2012
> @@ -31,6 +31,7 @@
>  #include "svn_cmdline.h"
>  #include "svn_string.h"
>  #include "svn_error.h"
> +#include "svn_sorts.h"
>  #include "svn_subst.h"
>  #include "svn_props.h"
>  #include "svn_string.h"
> @@ -87,12 +88,16 @@ svn_cl__print_prop_hash(svn_stream_t *ou
>                         svn_boolean_t names_only,
>                         apr_pool_t *pool)
>  {
> -  apr_hash_index_t *hi;
> +  apr_array_header_t *sorted_props;
> +  int i;
>
> -  for (hi = apr_hash_first(pool, prop_hash); hi; hi = apr_hash_next(hi))
> +  sorted_props = svn_sort__hash(prop_hash, svn_sort_compare_items_lexically,
> +                                pool);
> +  for (i = 0; i < sorted_props->nelts; i++)
>     {
> -      const char *pname = svn__apr_hash_index_key(hi);
> -      svn_string_t *propval = svn__apr_hash_index_val(hi);
> +      svn_sort__item_t item = APR_ARRAY_IDX(sorted_props, i, svn_sort__item_t);
> +      const char *pname = item.key;
> +      svn_string_t *propval = item.value;
>       const char *pname_stdout;
>
>       if (svn_prop_needs_translation(pname))
> @@ -150,15 +155,19 @@ svn_cl__print_xml_prop_hash(svn_stringbu
>                             svn_boolean_t names_only,
>                             apr_pool_t *pool)
>  {
> -  apr_hash_index_t *hi;
> +  apr_array_header_t *sorted_props;
> +  int i;
>
>   if (*outstr == NULL)
>     *outstr = svn_stringbuf_create_empty(pool);
>
> -  for (hi = apr_hash_first(pool, prop_hash); hi; hi = apr_hash_next(hi))
> +  sorted_props = svn_sort__hash(prop_hash, svn_sort_compare_items_lexically,
> +                                pool);
> +  for (i = 0; i < sorted_props->nelts; i++)
>     {
> -      const char *pname = svn__apr_hash_index_key(hi);
> -      svn_string_t *propval = svn__apr_hash_index_val(hi);
> +      svn_sort__item_t item = APR_ARRAY_IDX(sorted_props, i, svn_sort__item_t);
> +      const char *pname = item.key;
> +      svn_string_t *propval = item.value;
>
>       if (names_only)
>         {
>
>

-- 
uberSVN: Apache Subversion Made Easy
http://www.uberSVN.com/
Received on 2012-05-21 17:06:22 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.