You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by sv...@apache.org on 2012/08/02 06:03:02 UTC

svn commit: r1368348 - in /subversion/branches/1.7.x: ./ STATUS subversion/libsvn_fs_fs/fs_fs.c

Author: svn-role
Date: Thu Aug  2 04:03:02 2012
New Revision: 1368348

URL: http://svn.apache.org/viewvc?rev=1368348&view=rev
Log:
Merge r1367498 from trunk:

 * r1367498
   Make FSFS revision files independent of APR hash order.
   Justification:
     Make 'svnadmin load', and other commits,  produce reproducible revision
     files.
   Votes:
     +1: philip, steveking, jerenkrantz

Modified:
    subversion/branches/1.7.x/   (props changed)
    subversion/branches/1.7.x/STATUS
    subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c

Propchange: subversion/branches/1.7.x/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1367498

Modified: subversion/branches/1.7.x/STATUS
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/STATUS?rev=1368348&r1=1368347&r2=1368348&view=diff
==============================================================================
--- subversion/branches/1.7.x/STATUS (original)
+++ subversion/branches/1.7.x/STATUS Thu Aug  2 04:03:02 2012
@@ -68,14 +68,6 @@ Veto-blocked changes:
 Approved changes:
 =================
 
- * r1367498
-   Make FSFS revision files independent of APR hash order.
-   Justification:
-     Make 'svnadmin load', and other commits,  produce reproducible revision
-     files.
-   Votes:
-     +1: philip, steveking, jerenkrantz
-
  * r1362508
    Avoid errors when users run 'svnlook changed', 'svnlook
    dirs-changed', or 'svnlook diff' on r0.  Though the output from

Modified: subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c?rev=1368348&r1=1368347&r2=1368348&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/1.7.x/subversion/libsvn_fs_fs/fs_fs.c Thu Aug  2 04:03:02 2012
@@ -5992,16 +5992,23 @@ write_final_rev(const svn_fs_id_t **new_
     {
       apr_pool_t *subpool;
       apr_hash_t *entries, *str_entries;
-      apr_hash_index_t *hi;
+      apr_array_header_t *sorted_entries;
+      int i;
 
       /* This is a directory.  Write out all the children first. */
       subpool = svn_pool_create(pool);
 
       SVN_ERR(svn_fs_fs__rep_contents_dir(&entries, fs, noderev, pool));
-
-      for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
+      /* For the sake of the repository administrator sort the entries
+         so that the final file is deterministic and repeatable,
+         however the rest of the FSFS code doesn't require any
+         particular order here. */
+      sorted_entries = svn_sort__hash(entries, svn_sort_compare_items_lexically,
+                                      pool);
+      for (i = 0; i < sorted_entries->nelts; ++i)
         {
-          svn_fs_dirent_t *dirent = svn__apr_hash_index_val(hi);
+          svn_fs_dirent_t *dirent = APR_ARRAY_IDX(sorted_entries, i,
+                                                  svn_sort__item_t).value;
 
           svn_pool_clear(subpool);
           SVN_ERR(write_final_rev(&new_id, file, rev, fs, dirent->id,
@@ -6140,19 +6147,25 @@ write_final_changed_path_info(apr_off_t 
 {
   apr_hash_t *changed_paths;
   apr_off_t offset;
-  apr_hash_index_t *hi;
   apr_pool_t *iterpool = svn_pool_create(pool);
   fs_fs_data_t *ffd = fs->fsap_data;
   svn_boolean_t include_node_kinds =
       ffd->format >= SVN_FS_FS__MIN_KIND_IN_CHANGED_FORMAT;
+  apr_array_header_t *sorted_changed_paths;
+  int i;
 
   SVN_ERR(get_file_offset(&offset, file, pool));
 
   SVN_ERR(svn_fs_fs__txn_changes_fetch(&changed_paths, fs, txn_id, pool));
+  /* For the sake of the repository administrator sort the changes so
+     that the final file is deterministic and repeatable, however the
+     rest of the FSFS code doesn't require any particular order here. */
+  sorted_changed_paths = svn_sort__hash(changed_paths,
+                                        svn_sort_compare_items_lexically, pool);
 
   /* Iterate through the changed paths one at a time, and convert the
      temporary node-id into a permanent one for each change entry. */
-  for (hi = apr_hash_first(pool, changed_paths); hi; hi = apr_hash_next(hi))
+  for (i = 0; i < sorted_changed_paths->nelts; ++i)
     {
       node_revision_t *noderev;
       const svn_fs_id_t *id;
@@ -6161,8 +6174,8 @@ write_final_changed_path_info(apr_off_t 
 
       svn_pool_clear(iterpool);
 
-      change = svn__apr_hash_index_val(hi);
-      path = svn__apr_hash_index_key(hi);
+      change = APR_ARRAY_IDX(sorted_changed_paths, i, svn_sort__item_t).value;
+      path = APR_ARRAY_IDX(sorted_changed_paths, i, svn_sort__item_t).key;
 
       id = change->node_rev_id;