Author: stefan2
Date: Fri Dec 28 23:49:47 2012
New Revision: 1426668

URL: http://svn.apache.org/viewvc?rev=1426668&view=rev
Log:
On the fsfs-format7 branch: get rid of the get_root_changes_offset API
function because it does not fit any of the abstraction levels.

* subversion/libsvn_fs_fs/low_level.h
  (get_root_changes_offset): drop from API
* subversion/libsvn_fs_fs/low_level.c
  (get_root_changes_offset): move from here ...
* subversion/libsvn_fs_fs/cached_data.c
  (get_root_changes_offset): ... to here
* subversion/libsvn_fs_fs/recovery.c
  (svn_fs_fs__find_max_ids): reformulate, not calling get_root_changes_offset
  (recover_body): call svn_fs_fs__find_max_ids instead of duplicating code

Modified:
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c?rev=1426668&r1=1426667&r2=1426668&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c Fri 
Dec 28 23:49:47 2012
@@ -291,6 +291,89 @@ get_fs_id_at_offset(svn_fs_id_t **id_p,
   return SVN_NO_ERROR;
 }
 
+/* Given an open revision file REV_FILE in FS for REV, locate the trailer that
+   specifies the offset to the root node-id and to the changed path
+   information.  Store the root node offset in *ROOT_OFFSET and the
+   changed path offset in *CHANGES_OFFSET.  If either of these
+   pointers is NULL, do nothing with it.
+
+   If PACKED is true, REV_FILE should be a packed shard file.
+   ### There is currently no such parameter.  This function assumes that
+       is_packed_rev(FS, REV) will indicate whether REV_FILE is a packed
+       file.  Therefore FS->fsap_data->min_unpacked_rev must not have been
+       refreshed since REV_FILE was opened if there is a possibility that
+       revision REV may have become packed since then.
+       TODO: Take an IS_PACKED parameter instead, in order to remove this
+       requirement.
+
+   Allocate temporary variables from POOL. */
+static svn_error_t *
+get_root_changes_offset(apr_off_t *root_offset,
+                        apr_off_t *changes_offset,
+                        apr_file_t *rev_file,
+                        svn_fs_t *fs,
+                        svn_revnum_t rev,
+                        apr_pool_t *pool)
+{
+  fs_fs_data_t *ffd = fs->fsap_data;
+  apr_off_t offset;
+  apr_off_t rev_offset;
+  apr_seek_where_t seek_relative;
+  svn_stringbuf_t *trailer = svn_stringbuf_create_ensure(64, pool);
+
+  /* Determine where to seek to in the file.
+
+     If we've got a pack file, we want to seek to the end of the desired
+     revision.  But we don't track that, so we seek to the beginning of the
+     next revision.
+
+     Unless the next revision is in a different file, in which case, we can
+     just seek to the end of the pack file -- just like we do in the
+     non-packed case. */
+  if (is_packed_rev(fs, rev) && ((rev + 1) % ffd->max_files_per_dir != 0))
+    {
+      SVN_ERR(svn_fs_fs__get_packed_offset(&offset, fs, rev + 1, pool));
+      seek_relative = APR_SET;
+    }
+  else
+    {
+      seek_relative = APR_END;
+      offset = 0;
+    }
+
+  /* Offset of the revision from the start of the pack file, if applicable. */
+  if (is_packed_rev(fs, rev))
+    SVN_ERR(svn_fs_fs__get_packed_offset(&rev_offset, fs, rev, pool));
+  else
+    rev_offset = 0;
+
+  /* We will assume that the last line containing the two offsets
+     will never be longer than 64 characters. */
+  SVN_ERR(svn_io_file_seek(rev_file, seek_relative, &offset, pool));
+
+  trailer->len = trailer->blocksize-1;
+  offset -= trailer->len;
+  SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset, pool));
+
+  /* Read in this last block, from which we will identify the last line. */
+  SVN_ERR(svn_io_file_read(rev_file, trailer->data, &trailer->len, pool));
+  trailer->data[trailer->len] = 0;
+
+  /* Parse the last line. */
+  SVN_ERR(svn_fs_fs__parse_revision_trailer(root_offset,
+                                            changes_offset,
+                                            trailer,
+                                            rev));
+
+  /* return absolute offsets */
+  if (root_offset)
+    *root_offset += rev_offset;
+  if (changes_offset)
+    *changes_offset += rev_offset;
+
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_fs_fs__rev_get_root(svn_fs_id_t **root_id_p,
                         svn_fs_t *fs,

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c?rev=1426668&r1=1426667&r2=1426668&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c Fri 
Dec 28 23:49:47 2012
@@ -985,86 +985,3 @@ svn_fs_fs__write_changes(svn_stream_t *s
   return SVN_NO_ERROR;
 }
 
-/* Given an open revision file REV_FILE in FS for REV, locate the trailer that
-   specifies the offset to the root node-id and to the changed path
-   information.  Store the root node offset in *ROOT_OFFSET and the
-   changed path offset in *CHANGES_OFFSET.  If either of these
-   pointers is NULL, do nothing with it.
-
-   If PACKED is true, REV_FILE should be a packed shard file.
-   ### There is currently no such parameter.  This function assumes that
-       is_packed_rev(FS, REV) will indicate whether REV_FILE is a packed
-       file.  Therefore FS->fsap_data->min_unpacked_rev must not have been
-       refreshed since REV_FILE was opened if there is a possibility that
-       revision REV may have become packed since then.
-       TODO: Take an IS_PACKED parameter instead, in order to remove this
-       requirement.
-
-   Allocate temporary variables from POOL. */
-svn_error_t *
-get_root_changes_offset(apr_off_t *root_offset,
-                        apr_off_t *changes_offset,
-                        apr_file_t *rev_file,
-                        svn_fs_t *fs,
-                        svn_revnum_t rev,
-                        apr_pool_t *pool)
-{
-  fs_fs_data_t *ffd = fs->fsap_data;
-  apr_off_t offset;
-  apr_off_t rev_offset;
-  apr_seek_where_t seek_relative;
-  svn_stringbuf_t *trailer = svn_stringbuf_create_ensure(64, pool);
-
-  /* Determine where to seek to in the file.
-
-     If we've got a pack file, we want to seek to the end of the desired
-     revision.  But we don't track that, so we seek to the beginning of the
-     next revision.
-
-     Unless the next revision is in a different file, in which case, we can
-     just seek to the end of the pack file -- just like we do in the
-     non-packed case. */
-  if (is_packed_rev(fs, rev) && ((rev + 1) % ffd->max_files_per_dir != 0))
-    {
-      SVN_ERR(svn_fs_fs__get_packed_offset(&offset, fs, rev + 1, pool));
-      seek_relative = APR_SET;
-    }
-  else
-    {
-      seek_relative = APR_END;
-      offset = 0;
-    }
-
-  /* Offset of the revision from the start of the pack file, if applicable. */
-  if (is_packed_rev(fs, rev))
-    SVN_ERR(svn_fs_fs__get_packed_offset(&rev_offset, fs, rev, pool));
-  else
-    rev_offset = 0;
-
-  /* We will assume that the last line containing the two offsets
-     will never be longer than 64 characters. */
-  SVN_ERR(svn_io_file_seek(rev_file, seek_relative, &offset, pool));
-
-  trailer->len = trailer->blocksize-1;
-  offset -= trailer->len;
-  SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset, pool));
-
-  /* Read in this last block, from which we will identify the last line. */
-  SVN_ERR(svn_io_file_read(rev_file, trailer->data, &trailer->len, pool));
-  trailer->data[trailer->len] = 0;
-
-  /* Parse the last line. */
-  SVN_ERR(svn_fs_fs__parse_revision_trailer(root_offset,
-                                            changes_offset,
-                                            trailer,
-                                            rev));
-
-  /* return absolute offsets */
-  if (root_offset)
-    *root_offset += rev_offset;
-  if (changes_offset)
-    *changes_offset += rev_offset;
-
-  return SVN_NO_ERROR;
-}
-

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h?rev=1426668&r1=1426667&r2=1426668&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h Fri 
Dec 28 23:49:47 2012
@@ -178,10 +178,3 @@ svn_fs_fs__write_changes(svn_stream_t *s
                          apr_hash_t *changes,
                          apr_pool_t *pool);
 
-svn_error_t *
-get_root_changes_offset(apr_off_t *root_offset,
-                        apr_off_t *changes_offset,
-                        apr_file_t *rev_file,
-                        svn_fs_t *fs,
-                        svn_revnum_t rev,
-                        apr_pool_t *pool);

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c?rev=1426668&r1=1426667&r2=1426668&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c Fri Dec 
28 23:49:47 2012
@@ -31,6 +31,7 @@
 #include "revprops.h"
 #include "transaction.h"
 #include "util.h"
+#include "cached_data.h"
 
 #include "../libsvn_fs/fs-loader.h"
 
@@ -283,13 +284,15 @@ svn_fs_fs__find_max_ids(svn_fs_t *fs, sv
   fs_fs_data_t *ffd = fs->fsap_data;
   apr_off_t root_offset;
   apr_file_t *rev_file;
+  svn_fs_id_t *root_id;
 
   /* call this function for old repo formats only */
   SVN_ERR_ASSERT(ffd->format < SVN_FS_FS__MIN_NO_GLOBAL_IDS_FORMAT);
 
+  SVN_ERR(svn_fs_fs__rev_get_root(&root_id, fs, youngest, pool));
+  root_offset = svn_fs_fs__id_offset(root_id);
+
   SVN_ERR(svn_fs_fs__open_pack_or_rev_file(&rev_file, fs, youngest, pool));
-  SVN_ERR(get_root_changes_offset(&root_offset, NULL, rev_file,
-                                  fs, youngest, pool));
   SVN_ERR(recover_find_max_ids(fs, youngest, rev_file, root_offset,
                                max_node_id, max_copy_id, pool));
   SVN_ERR(svn_io_file_close(rev_file, pool));
@@ -380,20 +383,13 @@ recover_body(void *baton, apr_pool_t *po
 
       for (rev = 0; rev <= max_rev; rev++)
         {
-          apr_file_t *rev_file;
-          apr_off_t root_offset;
-
           svn_pool_clear(iterpool);
 
           if (b->cancel_func)
             SVN_ERR(b->cancel_func(b->cancel_baton));
 
-          SVN_ERR(svn_fs_fs__open_pack_or_rev_file(&rev_file, fs, rev, 
iterpool));
-          SVN_ERR(get_root_changes_offset(&root_offset, NULL, rev_file, fs, 
rev,
+          SVN_ERR(svn_fs_fs__find_max_ids(fs, rev, max_node_id, max_copy_id,
                                           iterpool));
-          SVN_ERR(recover_find_max_ids(fs, rev, rev_file, root_offset,
-                                       max_node_id, max_copy_id, iterpool));
-          SVN_ERR(svn_io_file_close(rev_file, iterpool));
         }
       svn_pool_destroy(iterpool);
 


Reply via email to