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/12/27 21:53:56 UTC

svn commit: r1426318 - in /subversion/branches/fsfs-format7/subversion/libsvn_fs_fs: cached_data.c low_level.c low_level.h recovery.c transaction.c

Author: stefan2
Date: Thu Dec 27 20:53:56 2012
New Revision: 1426318

URL: http://svn.apache.org/viewvc?rev=1426318&view=rev
Log:
On the fsfs-format7 branch: define the low-level API for
parsing and unparsing of representations, noderevs and
revision trailers.  Update callers.

* subversion/libsvn_fs_fs/low_level.h
  (svn_fs_fs__parse_revision_trailer): renamed from parse_revision_trailer;
   update docstring
  (svn_fs_fs__unparse_revision_trailer): renamed from unparse_revision_trailer
  (read_header_block,
   read_rep_offsets_body): drop from API
  (svn_fs_fs__parse_representation): supersedes read_rep_offsets;
   take a simple stringbuf as input
  (svn_fs_fs__unparse_representation): renamed from representation_string;
   return a stringbuf for symmetry with other low-level API

* subversion/libsvn_fs_fs/low_level.c
  (svn_fs_fs__parse_revision_trailer): renamed from parse_revision_trailer
  (svn_fs_fs__unparse_revision_trailer): renamed from unparse_revision_trailer
  (read_header_block): now static
  (svn_fs_fs__parse_representation): rename and update;
   be more intelligent about "-1" reps
  (read_rep_offsets): now static; automatically handle "-1" reps
  (svn_fs_fs__unparse_representation): renamed from representation_string;
   update to changed signature
  (svn_fs_fs__read_noderev,
   svn_fs_fs__write_noderev): update callers
  (get_root_changes_offset): simplify using svn_fs_fs__parse_revision_trailer

* subversion/libsvn_fs_fs/cached_data.c
  (get_fs_id_at_offset): simplify using low-level API
  (create_rep_state): update API caller

* subversion/libsvn_fs_fs/recovery.c
  (recover_find_max_ids): simplify using low-level API

* subversion/libsvn_fs_fs/transaction.c
  (store_sha1_rep_mapping,
   get_shared_rep,
   commit_body): adapt to low-level API changes

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
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.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=1426318&r1=1426317&r2=1426318&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 Thu Dec 27 20:53:56 2012
@@ -22,6 +22,8 @@
 
 #include "cached_data.h"
 
+#include <assert.h>
+
 #include "svn_hash.h"
 #include "svn_ctype.h"
 
@@ -270,40 +272,21 @@ get_fs_id_at_offset(svn_fs_id_t **id_p,
                     apr_off_t offset,
                     apr_pool_t *pool)
 {
-  svn_fs_id_t *id;
-  apr_hash_t *headers;
-  const char *node_id_str;
+  node_revision_t *noderev;
 
   SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset, pool));
+  SVN_ERR(svn_fs_fs__read_noderev(&noderev,
+                                  svn_stream_from_aprfile2(rev_file, TRUE,
+                                                           pool),
+                                  pool));
 
-  SVN_ERR(read_header_block(&headers,
-                            svn_stream_from_aprfile2(rev_file, TRUE, pool),
-                            pool));
-
-  /* In error messages, the offset is relative to the pack file,
-     not to the rev file. */
-
-  node_id_str = apr_hash_get(headers, HEADER_ID, APR_HASH_KEY_STRING);
-
-  if (node_id_str == NULL)
-    return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
-                             _("Missing node-id in node-rev at r%ld "
-                             "(offset %s)"),
-                             rev,
-                             apr_psprintf(pool, "%" APR_OFF_T_FMT, offset));
-
-  id = svn_fs_fs__id_parse(node_id_str, strlen(node_id_str), pool);
-
-  if (id == NULL)
-    return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
-                             _("Corrupt node-id '%s' in node-rev at r%ld "
-                               "(offset %s)"),
-                             node_id_str, rev,
-                             apr_psprintf(pool, "%" APR_OFF_T_FMT, offset));
-
-  *id_p = id;
+  /* noderev->id is const, get rid of that */
+  *id_p = svn_fs_fs__id_copy(noderev->id, pool);
 
-  /* ### assert that the txn_id is REV/OFFSET ? */
+  /* assert that the txn_id is REV
+   * (asserting on offset would be harder because we the rev_offset is not
+   * known here) */
+  assert(svn_fs_fs__id_rev(*id_p) == rev);
 
   return SVN_NO_ERROR;
 }
@@ -478,8 +461,8 @@ create_rep_state(rep_state_t **rep_state
       return svn_error_createf(SVN_ERR_FS_CORRUPT, err,
                                "Corrupt representation '%s'",
                                rep
-                               ? representation_string(rep, ffd->format, TRUE,
-                                                       TRUE, pool)
+                               ? svn_fs_fs__unparse_representation
+                                   (rep, ffd->format, TRUE, TRUE, pool)->data
                                : "(null)");
     }
   /* ### Call representation_string() ? */

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=1426318&r1=1426317&r2=1426318&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 Thu Dec 27 20:53:56 2012
@@ -46,10 +46,10 @@
  * Note that REV is only used to construct nicer error objects.
  */
 svn_error_t *
-parse_revision_trailer(apr_off_t *root_offset,
-                       apr_off_t *changes_offset,
-                       svn_stringbuf_t *trailer,
-                       svn_revnum_t rev)
+svn_fs_fs__parse_revision_trailer(apr_off_t *root_offset,
+                                  apr_off_t *changes_offset,
+                                  svn_stringbuf_t *trailer,
+                                  svn_revnum_t rev)
 {
   int i, num_bytes;
   const char *str;
@@ -128,9 +128,9 @@ parse_revision_trailer(apr_off_t *root_o
  * trailer.  Allocate it in POOL.
  */
 svn_stringbuf_t *
-unparse_revision_trailer(apr_off_t root_offset,
-                         apr_off_t changes_offset,
-                         apr_pool_t *pool)
+svn_fs_fs__unparse_revision_trailer(apr_off_t root_offset,
+                                    apr_off_t changes_offset,
+                                    apr_pool_t *pool)
 {
   return svn_stringbuf_createf(pool,
                                "\n%" APR_OFF_T_FMT " %" APR_OFF_T_FMT "\n",
@@ -142,7 +142,7 @@ unparse_revision_trailer(apr_off_t root_
    beginning of a Node-Rev header block, read in that header block and
    store it in the apr_hash_t HEADERS.  All allocations will be from
    POOL. */
-svn_error_t *
+static svn_error_t *
 read_header_block(apr_hash_t **headers,
                   svn_stream_t *stream,
                   apr_pool_t *pool)
@@ -207,15 +207,14 @@ read_header_block(apr_hash_t **headers,
    expected except the "-1" revision number for a mutable
    representation.  Allocate *REP_P in POOL. */
 svn_error_t *
-read_rep_offsets_body(representation_t **rep_p,
-                      char *string,
-                      const char *txn_id,
-                      svn_boolean_t mutable_rep_truncated,
-                      apr_pool_t *pool)
+svn_fs_fs__parse_representation(representation_t **rep_p,
+                                svn_stringbuf_t *text,
+                                apr_pool_t *pool)
 {
   representation_t *rep;
   char *str;
   apr_int64_t val;
+  char *string = text->data;
 
   rep = apr_pcalloc(pool, sizeof(*rep));
   *rep_p = rep;
@@ -227,17 +226,17 @@ read_rep_offsets_body(representation_t *
 
 
   rep->revision = SVN_STR_TO_REV(str);
-  if (rep->revision == SVN_INVALID_REVNUM)
-    {
-      rep->txn_id = txn_id;
-      if (mutable_rep_truncated)
-        return SVN_NO_ERROR;
-    }
 
+  /* while in transactions, it is legal to simply write "-1" */
   str = svn_cstring_tokenize(" ", &string);
   if (str == NULL)
-    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                            _("Malformed text representation offset line in node-rev"));
+    {
+      if (rep->revision == SVN_INVALID_REVNUM)
+        return SVN_NO_ERROR;
+    
+      return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
+                              _("Malformed text representation offset line in node-rev"));
+    }
 
   SVN_ERR(svn_cstring_atoi64(&val, str));
   rep->offset = (apr_off_t)val;
@@ -293,23 +292,16 @@ read_rep_offsets_body(representation_t *
 
 /* Wrap read_rep_offsets_body(), extracting its TXN_ID from our NODEREV_ID,
    and adding an error message. */
-svn_error_t *
+static svn_error_t *
 read_rep_offsets(representation_t **rep_p,
                  char *string,
                  const svn_fs_id_t *noderev_id,
-                 svn_boolean_t mutable_rep_truncated,
                  apr_pool_t *pool)
 {
-  svn_error_t *err;
-  const char *txn_id;
-
-  if (noderev_id)
-    txn_id = svn_fs_fs__id_txn_id(noderev_id);
-  else
-    txn_id = NULL;
-
-  err = read_rep_offsets_body(rep_p, string, txn_id, mutable_rep_truncated,
-                              pool);
+  svn_error_t *err
+    = svn_fs_fs__parse_representation(rep_p,
+                                      svn_stringbuf_create_wrap(string, pool),
+                                      pool);
   if (err)
     {
       const svn_string_t *id_unparsed = svn_fs_fs__id_unparse(noderev_id, pool);
@@ -321,8 +313,12 @@ read_rep_offsets(representation_t **rep_
 
       return svn_error_quick_wrap(err, where);
     }
-  else
-    return SVN_NO_ERROR;
+
+  if ((*rep_p)->revision == SVN_INVALID_REVNUM)
+    if (noderev_id)
+      (*rep_p)->txn_id = svn_fs_fs__id_txn_id(noderev_id);
+
+  return SVN_NO_ERROR;
 }
 
 svn_error_t *
@@ -376,7 +372,7 @@ svn_fs_fs__read_noderev(node_revision_t 
   if (value)
     {
       SVN_ERR(read_rep_offsets(&noderev->prop_rep, value,
-                               noderev->id, TRUE, pool));
+                               noderev->id, pool));
     }
 
   /* Get the data location. */
@@ -384,8 +380,7 @@ svn_fs_fs__read_noderev(node_revision_t 
   if (value)
     {
       SVN_ERR(read_rep_offsets(&noderev->data_rep, value,
-                               noderev->id,
-                               (noderev->kind == svn_node_dir), pool));
+                               noderev->id, pool));
     }
 
   /* Get the created path. */
@@ -484,15 +479,15 @@ svn_fs_fs__read_noderev(node_revision_t 
    and only a "-1" revision number will be given for a mutable rep.
    If MAY_BE_CORRUPT is true, guard for NULL when constructing the string.
    Perform the allocation from POOL.  */
-const char *
-representation_string(representation_t *rep,
-                      int format,
-                      svn_boolean_t mutable_rep_truncated,
-                      svn_boolean_t may_be_corrupt,
-                      apr_pool_t *pool)
+svn_stringbuf_t *
+svn_fs_fs__unparse_representation(representation_t *rep,
+                                  int format,
+                                  svn_boolean_t mutable_rep_truncated,
+                                  svn_boolean_t may_be_corrupt,
+                                  apr_pool_t *pool)
 {
   if (rep->txn_id && mutable_rep_truncated)
-    return "-1";
+    return svn_stringbuf_ncreate("-1", 2, pool);
 
 #define DISPLAY_MAYBE_NULL_CHECKSUM(checksum)          \
   ((may_be_corrupt == FALSE || (checksum) != NULL)     \
@@ -500,19 +495,21 @@ representation_string(representation_t *
    : "(null)")
 
   if (format < SVN_FS_FS__MIN_REP_SHARING_FORMAT || rep->sha1_checksum == NULL)
-    return apr_psprintf(pool, "%ld %" APR_OFF_T_FMT " %" SVN_FILESIZE_T_FMT
-                        " %" SVN_FILESIZE_T_FMT " %s",
-                        rep->revision, rep->offset, rep->size,
-                        rep->expanded_size,
-                        DISPLAY_MAYBE_NULL_CHECKSUM(rep->md5_checksum));
-
-  return apr_psprintf(pool, "%ld %" APR_OFF_T_FMT " %" SVN_FILESIZE_T_FMT
-                      " %" SVN_FILESIZE_T_FMT " %s %s %s",
-                      rep->revision, rep->offset, rep->size,
-                      rep->expanded_size,
-                      DISPLAY_MAYBE_NULL_CHECKSUM(rep->md5_checksum),
-                      DISPLAY_MAYBE_NULL_CHECKSUM(rep->sha1_checksum),
-                      rep->uniquifier);
+    return svn_stringbuf_createf
+            (pool, "%ld %" APR_OFF_T_FMT " %" SVN_FILESIZE_T_FMT
+             " %" SVN_FILESIZE_T_FMT " %s",
+             rep->revision, rep->offset, rep->size,
+             rep->expanded_size,
+             DISPLAY_MAYBE_NULL_CHECKSUM(rep->md5_checksum));
+
+  return svn_stringbuf_createf
+          (pool, "%ld %" APR_OFF_T_FMT " %" SVN_FILESIZE_T_FMT
+           " %" SVN_FILESIZE_T_FMT " %s %s %s",
+           rep->revision, rep->offset, rep->size,
+           rep->expanded_size,
+           DISPLAY_MAYBE_NULL_CHECKSUM(rep->md5_checksum),
+           DISPLAY_MAYBE_NULL_CHECKSUM(rep->sha1_checksum),
+           rep->uniquifier);
 
 #undef DISPLAY_MAYBE_NULL_CHECKSUM
 
@@ -544,17 +541,18 @@ svn_fs_fs__write_noderev(svn_stream_t *o
 
   if (noderev->data_rep)
     SVN_ERR(svn_stream_printf(outfile, pool, HEADER_TEXT ": %s\n",
-                              representation_string(noderev->data_rep,
-                                                    format,
-                                                    (noderev->kind
-                                                     == svn_node_dir),
-                                                    FALSE,
-                                                    pool)));
+                              svn_fs_fs__unparse_representation
+                                (noderev->data_rep,
+                                 format,
+                                 noderev->kind == svn_node_dir,
+                                 FALSE,
+                                 pool)->data));
 
   if (noderev->prop_rep)
     SVN_ERR(svn_stream_printf(outfile, pool, HEADER_PROPS ": %s\n",
-                              representation_string(noderev->prop_rep, format,
-                                                    TRUE, FALSE, pool)));
+                              svn_fs_fs__unparse_representation
+                                (noderev->prop_rep, format,
+                                 TRUE, FALSE, pool)->data));
 
   SVN_ERR(svn_stream_printf(outfile, pool, HEADER_CPATH ": %s\n",
                             noderev->created_path));
@@ -1033,11 +1031,8 @@ get_root_changes_offset(apr_off_t *root_
   fs_fs_data_t *ffd = fs->fsap_data;
   apr_off_t offset;
   apr_off_t rev_offset;
-  char buf[64];
-  int i, num_bytes;
-  const char *str;
-  apr_size_t len;
   apr_seek_where_t seek_relative;
+  svn_stringbuf_t *trailer = svn_stringbuf_create_ensure(64, pool);
 
   /* Determine where to seek to in the file.
 
@@ -1069,78 +1064,25 @@ get_root_changes_offset(apr_off_t *root_
      will never be longer than 64 characters. */
   SVN_ERR(svn_io_file_seek(rev_file, seek_relative, &offset, pool));
 
-  offset -= sizeof(buf);
+  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. */
-  len = sizeof(buf);
-  SVN_ERR(svn_io_file_read(rev_file, buf, &len, pool));
-
-  /* This cast should be safe since the maximum amount read, 64, will
-     never be bigger than the size of an int. */
-  num_bytes = (int) len;
-
-  /* The last byte should be a newline. */
-  if (buf[num_bytes - 1] != '\n')
-    {
-      return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
-                               _("Revision file (r%ld) lacks trailing newline"),
-                               rev);
-    }
-
-  /* Look for the next previous newline. */
-  for (i = num_bytes - 2; i >= 0; i--)
-    {
-      if (buf[i] == '\n')
-        break;
-    }
-
-  if (i < 0)
-    {
-      return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
-                               _("Final line in revision file (r%ld) longer "
-                                 "than 64 characters"),
-                               rev);
-    }
+  SVN_ERR(svn_io_file_read(rev_file, trailer->data, &trailer->len, pool));
+  trailer->data[trailer->len] = 0;
 
-  i++;
-  str = &buf[i];
-
-  /* find the next space */
-  for ( ; i < (num_bytes - 2) ; i++)
-    if (buf[i] == ' ')
-      break;
-
-  if (i == (num_bytes - 2))
-    return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
-                             _("Final line in revision file r%ld missing space"),
-                             rev);
+  /* Parse the last line. */
+  SVN_ERR(svn_fs_fs__parse_revision_trailer(root_offset,
+                                            changes_offset,
+                                            trailer,
+                                            rev));
 
+  /* return absolute offsets */
   if (root_offset)
-    {
-      apr_int64_t val;
-
-      buf[i] = '\0';
-      SVN_ERR(svn_cstring_atoi64(&val, str));
-      *root_offset = rev_offset + (apr_off_t)val;
-    }
-
-  i++;
-  str = &buf[i];
-
-  /* find the next newline */
-  for ( ; i < num_bytes; i++)
-    if (buf[i] == '\n')
-      break;
-
+    *root_offset += rev_offset;
   if (changes_offset)
-    {
-      apr_int64_t val;
-
-      buf[i] = '\0';
-      SVN_ERR(svn_cstring_atoi64(&val, str));
-      *changes_offset = rev_offset + (apr_off_t)val;
-    }
+    *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=1426318&r1=1426317&r2=1426318&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 Thu Dec 27 20:53:56 2012
@@ -65,56 +65,45 @@
 /* Given the last "few" bytes (should be at least 40) of revision REV in
  * TRAILER,  parse the last line and return the offset of the root noderev
  * in *ROOT_OFFSET and the offset of the changes list in *CHANGES_OFFSET.
- * All offsets are relative to the revision's start offset.
+ * All offsets are relative to the revision's start offset.  ROOT_OFFSET
+ * and / or CHANGES_OFFSET may be NULL.
  * 
  * Note that REV is only used to construct nicer error objects.
  */
 svn_error_t *
-parse_revision_trailer(apr_off_t *root_offset,
-                       apr_off_t *changes_offset,
-                       svn_stringbuf_t *trailer,
-                       svn_revnum_t rev);
+svn_fs_fs__parse_revision_trailer(apr_off_t *root_offset,
+                                  apr_off_t *changes_offset,
+                                  svn_stringbuf_t *trailer,
+                                  svn_revnum_t rev);
 
 /* Given the offset of the root noderev in ROOT_OFFSET and the offset of
  * the changes list in CHANGES_OFFSET,  return the corresponding revision's
  * trailer.  Allocate it in POOL.
  */
 svn_stringbuf_t *
-unparse_revision_trailer(apr_off_t root_offset,
-                         apr_off_t changes_offset,
-                         apr_pool_t *pool);
+svn_fs_fs__unparse_revision_trailer(apr_off_t root_offset,
+                                    apr_off_t changes_offset,
+                                    apr_pool_t *pool);
+
+/* Parse the description of a representation from TEXT and store it
+   into *REP_P.  Allocate *REP_P in POOL. */
+svn_error_t *
+svn_fs_fs__parse_representation(representation_t **rep_p,
+                                svn_stringbuf_t *text,
+                                apr_pool_t *pool);
 
-/* Given a revision file FILE that has been pre-positioned at the
-   beginning of a Node-Rev header block, read in that header block and
-   store it in the apr_hash_t HEADERS.  All allocations will be from
-   POOL. */
-svn_error_t *
-read_header_block(apr_hash_t **headers,
-                  svn_stream_t *stream,
-                  apr_pool_t *pool);
-
-/* Parse the description of a representation from STRING and store it
-   into *REP_P.  If the representation is mutable (the revision is
-   given as -1), then use TXN_ID for the representation's txn_id
-   field.  If MUTABLE_REP_TRUNCATED is true, then this representation
-   is for property or directory contents, and no information will be
-   expected except the "-1" revision number for a mutable
-   representation.  Allocate *REP_P in POOL. */
-svn_error_t *
-read_rep_offsets_body(representation_t **rep_p,
-                      char *string,
-                      const char *txn_id,
-                      svn_boolean_t mutable_rep_truncated,
-                      apr_pool_t *pool);
-
-/* Wrap read_rep_offsets_body(), extracting its TXN_ID from our NODEREV_ID,
-   and adding an error message. */
-svn_error_t *
-read_rep_offsets(representation_t **rep_p,
-                 char *string,
-                 const svn_fs_id_t *noderev_id,
-                 svn_boolean_t mutable_rep_truncated,
-                 apr_pool_t *pool);
+/* Return a formatted string, compatible with filesystem format FORMAT,
+   that represents the location of representation REP.  If
+   MUTABLE_REP_TRUNCATED is given, the rep is for props or dir contents,
+   and only a "-1" revision number will be given for a mutable rep.
+   If MAY_BE_CORRUPT is true, guard for NULL when constructing the string.
+   Perform the allocation from POOL.  */
+svn_stringbuf_t *
+svn_fs_fs__unparse_representation(representation_t *rep,
+                                  int format,
+                                  svn_boolean_t mutable_rep_truncated,
+                                  svn_boolean_t may_be_corrupt,
+                                  apr_pool_t *pool);
 
 /* Write the node-revision NODEREV into the stream OUTFILE, compatible with
    filesystem format FORMAT.  Only write mergeinfo-related metadata if
@@ -133,19 +122,6 @@ svn_fs_fs__read_noderev(node_revision_t 
                         svn_stream_t *stream,
                         apr_pool_t *pool);
 
-/* Return a formatted string, compatible with filesystem format FORMAT,
-   that represents the location of representation REP.  If
-   MUTABLE_REP_TRUNCATED is given, the rep is for props or dir contents,
-   and only a "-1" revision number will be given for a mutable rep.
-   If MAY_BE_CORRUPT is true, guard for NULL when constructing the string.
-   Perform the allocation from POOL.  */
-const char *
-representation_string(representation_t *rep,
-                      int format,
-                      svn_boolean_t mutable_rep_truncated,
-                      svn_boolean_t may_be_corrupt,
-                      apr_pool_t *pool);
-
 /* This structure is used to hold the information associated with a
    REP line. */
 typedef struct rep_args_t

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=1426318&r1=1426317&r2=1426318&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c Thu Dec 27 20:53:56 2012
@@ -149,43 +149,39 @@ recover_find_max_ids(svn_fs_t *fs, svn_r
                      char *max_node_id, char *max_copy_id,
                      apr_pool_t *pool)
 {
-  apr_hash_t *headers;
-  char *value;
-  representation_t *data_rep;
   rep_args_t *ra;
   struct recover_read_from_file_baton baton;
   svn_stream_t *stream;
   apr_hash_t *entries;
   apr_hash_index_t *hi;
   apr_pool_t *iterpool;
+  node_revision_t *noderev;
 
   SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset, pool));
-  SVN_ERR(read_header_block(&headers, svn_stream_from_aprfile2(rev_file, TRUE,
-                                                               pool),
-                            pool));
+  SVN_ERR(svn_fs_fs__read_noderev(&noderev,
+                                  svn_stream_from_aprfile2(rev_file, TRUE,
+                                                           pool),
+                                  pool));
 
   /* Check that this is a directory.  It should be. */
-  value = apr_hash_get(headers, HEADER_TYPE, APR_HASH_KEY_STRING);
-  if (value == NULL || strcmp(value, KIND_DIR) != 0)
+  if (noderev->kind != svn_node_dir)
     return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                             _("Recovery encountered a non-directory node"));
 
   /* Get the data location.  No data location indicates an empty directory. */
-  value = apr_hash_get(headers, HEADER_TEXT, APR_HASH_KEY_STRING);
-  if (!value)
+  if (!noderev->data_rep)
     return SVN_NO_ERROR;
-  SVN_ERR(read_rep_offsets(&data_rep, value, NULL, FALSE, pool));
 
   /* If the directory's data representation wasn't changed in this revision,
      we've already scanned the directory's contents for noderevs, so we don't
      need to again.  This will occur if a property is changed on a directory
      without changing the directory's contents. */
-  if (data_rep->revision != rev)
+  if (noderev->data_rep->revision != rev)
     return SVN_NO_ERROR;
 
   /* We could use get_dir_contents(), but this is much cheaper.  It does
      rely on directory entries being stored as PLAIN reps, though. */
-  offset = data_rep->offset;
+  offset = noderev->data_rep->offset;
   SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset, pool));
 
   baton.stream = svn_stream_from_aprfile2(rev_file, TRUE, pool);
@@ -198,7 +194,7 @@ recover_find_max_ids(svn_fs_t *fs, svn_r
   /* Now create a stream that's allowed to read only as much data as is
      stored in the representation. */
   baton.pool = pool;
-  baton.remaining = (apr_size_t) data_rep->expanded_size;
+  baton.remaining = (apr_size_t) noderev->data_rep->expanded_size;
   stream = svn_stream_create(&baton, pool);
   svn_stream_set_read(stream, read_handler_recover);
 

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c?rev=1426318&r1=1426317&r2=1426318&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c Thu Dec 27 20:53:56 2012
@@ -560,12 +560,12 @@ store_sha1_rep_mapping(svn_fs_t *fs,
                                             svn_fs_fs__id_txn_id(noderev->id),
                                             noderev->data_rep->sha1_checksum,
                                             pool);
-      const char *rep_string = representation_string(noderev->data_rep,
-                                                     ffd->format,
-                                                     (noderev->kind
-                                                      == svn_node_dir),
-                                                     FALSE,
-                                                     pool);
+      svn_string_t *rep_string
+        = svn_fs_fs__unparse_representation(noderev->data_rep,
+                                            ffd->format,
+                                            (noderev->kind == svn_node_dir),
+                                            FALSE,
+                                            pool);
       SVN_ERR(svn_io_file_open(&rep_file, file_name,
                                APR_WRITE | APR_CREATE | APR_TRUNCATE
                                | APR_BUFFERED, APR_OS_DEFAULT, pool));
@@ -1905,8 +1905,7 @@ get_shared_rep(representation_t **old_re
         {
           svn_stringbuf_t *rep_string;
           SVN_ERR(svn_stringbuf_from_file2(&rep_string, file_name, pool));
-          SVN_ERR(read_rep_offsets_body(old_rep, rep_string->data,
-                                        rep->txn_id, FALSE, pool));
+          SVN_ERR(svn_fs_fs__parse_representation(old_rep, rep_string, pool));
         }
     }
 
@@ -2790,7 +2789,7 @@ commit_body(void *baton, apr_pool_t *poo
   apr_file_t *proto_file;
   void *proto_file_lockcookie;
   apr_off_t initial_offset, changed_path_offset;
-  char *buf;
+  svn_stringbuf_t *trailer;
   apr_hash_t *txnprops;
   apr_array_header_t *txnprop_list;
   svn_prop_t prop;
@@ -2836,11 +2835,12 @@ commit_body(void *baton, apr_pool_t *poo
                                         cb->fs, cb->txn->id, pool));
 
   /* Write the final line. */
-  buf = apr_psprintf(pool, "\n%" APR_OFF_T_FMT " %" APR_OFF_T_FMT "\n",
-                     svn_fs_fs__id_offset(new_root_id),
-                     changed_path_offset);
-  SVN_ERR(svn_io_file_write_full(proto_file, buf, strlen(buf), NULL,
-                                 pool));
+  trailer = svn_fs_fs__unparse_revision_trailer
+              (svn_fs_fs__id_offset(new_root_id),
+               changed_path_offset,
+               pool);
+  SVN_ERR(svn_io_file_write_full(proto_file, trailer->data, trailer->len,
+                                 NULL, pool));
   SVN_ERR(svn_io_file_flush_to_disk(proto_file, pool));
   SVN_ERR(svn_io_file_close(proto_file, pool));