You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2012/05/21 16:08:18 UTC

svn commit: r1341034 - /subversion/trunk/subversion/svn/propget-cmd.c

Author: stsp
Date: Mon May 21 14:08:17 2012
New Revision: 1341034

URL: http://svn.apache.org/viewvc?rev=1341034&view=rev
Log:
Make 'svn propget -R' sort by path when printing path:propval pairs.
Avoids random output ordering with APR-1.4.6.

* subversion/svn/propget-cmd.c
  (print_properties, print_properties_xml): Iterate over a sorted array of hash
   table keys instead of iterating over the hash table itself. The hash maps
   paths to prop values, so use svn_sort_compare_items_as_paths for sorting.

Modified:
    subversion/trunk/subversion/svn/propget-cmd.c

Modified: subversion/trunk/subversion/svn/propget-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/propget-cmd.c?rev=1341034&r1=1341033&r2=1341034&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/propget-cmd.c (original)
+++ subversion/trunk/subversion/svn/propget-cmd.c Mon May 21 14:08:17 2012
@@ -34,6 +34,7 @@
 #include "svn_error_codes.h"
 #include "svn_error.h"
 #include "svn_utf.h"
+#include "svn_sorts.h"
 #include "svn_subst.h"
 #include "svn_dirent_uri.h"
 #include "svn_path.h"
@@ -71,13 +72,16 @@ print_properties_xml(const char *pname,
                      apr_hash_t *props,
                      apr_pool_t *pool)
 {
-  apr_hash_index_t *hi;
+  apr_array_header_t *sorted_props;
+  int i;
   apr_pool_t *iterpool = svn_pool_create(pool);
 
-  for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi))
+  sorted_props = svn_sort__hash(props, svn_sort_compare_items_as_paths, pool);
+  for (i = 0; i < sorted_props->nelts; i++)
     {
-      const char *filename = 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 *filename = item.key;
+      svn_string_t *propval = item.value;
       svn_stringbuf_t *sb = NULL;
 
       svn_pool_clear(iterpool);
@@ -115,16 +119,19 @@ print_properties(svn_stream_t *out,
                  svn_boolean_t like_proplist,
                  apr_pool_t *pool)
 {
-  apr_hash_index_t *hi;
+  apr_array_header_t *sorted_props;
+  int i;
   apr_pool_t *iterpool = svn_pool_create(pool);
   const char *path_prefix;
 
   SVN_ERR(svn_dirent_get_absolute(&path_prefix, "", pool));
 
-  for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi))
+  sorted_props = svn_sort__hash(props, svn_sort_compare_items_as_paths, pool);
+  for (i = 0; i < sorted_props->nelts; i++)
     {
-      const char *filename = 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 *filename = item.key;
+      svn_string_t *propval = item.value;
 
       svn_pool_clear(iterpool);