subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1589360 - in /subversion/trunk/subversion: include/private/svn_diff_private.h libsvn_diff/util.c
Date Wed, 23 Apr 2014 09:46:25 GMT
Author: rhuijben
Date: Wed Apr 23 09:46:25 2014
New Revision: 1589360

URL: http://svn.apache.org/r1589360
Log:
Make 'svn diff' sort property change output on a specific targets by their
property name. This makes the diff output more stable between runs, as
otherwise their order will depend on the hash ordering when calculating
the changes.

* subversion/include/private/svn_diff_private.h
  (svn_diff__display_prop_diffs): Rename argument.

* subversion/libsvn_diff/util.c
  (includes): Add private/svn_sorts_private.h.
  (propchange_sort): New function.
  (svn_diff__display_prop_diffs): Rename pool argument. Sort properties before
    printing them.

Modified:
    subversion/trunk/subversion/include/private/svn_diff_private.h
    subversion/trunk/subversion/libsvn_diff/util.c

Modified: subversion/trunk/subversion/include/private/svn_diff_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_diff_private.h?rev=1589360&r1=1589359&r2=1589360&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_diff_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_diff_private.h Wed Apr 23 09:46:25 2014
@@ -97,7 +97,7 @@ svn_diff__unidiff_write_header(svn_strea
  * merged or reverse merged; otherwise (or if the mergeinfo property values
  * don't parse correctly) display them just like any other property.
  *
- * Use @a pool for temporary allocations.
+ * Use @a scratch_pool for temporary allocations.
  */
 svn_error_t *
 svn_diff__display_prop_diffs(svn_stream_t *outstream,
@@ -105,7 +105,7 @@ svn_diff__display_prop_diffs(svn_stream_
                              const apr_array_header_t *propchanges,
                              apr_hash_t *original_props,
                              svn_boolean_t pretty_print_mergeinfo,
-                             apr_pool_t *pool);
+                             apr_pool_t *scratch_pool);
 
 
 #ifdef __cplusplus

Modified: subversion/trunk/subversion/libsvn_diff/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/util.c?rev=1589360&r1=1589359&r2=1589360&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/util.c (original)
+++ subversion/trunk/subversion/libsvn_diff/util.c Wed Apr 23 09:46:25 2014
@@ -38,6 +38,7 @@
 #include "svn_version.h"
 
 #include "private/svn_diff_private.h"
+#include "private/svn_sorts_private.h"
 #include "diff.h"
 
 #include "svn_private_config.h"
@@ -491,23 +492,37 @@ display_mergeinfo_diff(const char *old_m
   return SVN_NO_ERROR;
 }
 
+/* svn_sort__array callback handling svn_prop_t by name */
+static int
+propchange_sort(const void *k1, const void *k2)
+{
+  const svn_prop_t *propchange1 = k1;
+  const svn_prop_t *propchange2 = k2;
+
+  return strcmp(propchange1->name, propchange2->name);
+}
+
 svn_error_t *
 svn_diff__display_prop_diffs(svn_stream_t *outstream,
                              const char *encoding,
                              const apr_array_header_t *propchanges,
                              apr_hash_t *original_props,
                              svn_boolean_t pretty_print_mergeinfo,
-                             apr_pool_t *pool)
+                             apr_pool_t *scratch_pool)
 {
+  apr_pool_t *pool = scratch_pool;
   apr_pool_t *iterpool = svn_pool_create(pool);
+  apr_array_header_t *changes = apr_array_copy(scratch_pool, propchanges);
   int i;
 
-  for (i = 0; i < propchanges->nelts; i++)
+  svn_sort__array(changes, propchange_sort);
+
+  for (i = 0; i < changes->nelts; i++)
     {
       const char *action;
       const svn_string_t *original_value;
       const svn_prop_t *propchange
-        = &APR_ARRAY_IDX(propchanges, i, svn_prop_t);
+        = &APR_ARRAY_IDX(changes, i, svn_prop_t);
 
       if (original_props)
         original_value = svn_hash_gets(original_props, propchange->name);



Mime
View raw message