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 2013/06/05 12:44:03 UTC

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

Author: stefan2
Date: Wed Jun  5 10:44:02 2013
New Revision: 1489804

URL: http://svn.apache.org/r1489804
Log:
On the fsfs-format7 branch:  Instead of using a set of flags,
use a single enum value to determine the type / format of a
representation.  Update all users.

* subversion/libsvn_fs_fs/low_level.h
  (svn_fs_fs__rep_type_t): declare new private API type
  (svn_fs_fs__rep_header_t): use that instead of boolean flags

* subversion/libsvn_fs_fs/low_level.c
  (svn_fs_fs__read_rep_header,
   svn_fs_fs__write_rep_header): update parsers and writers

* subversion/libsvn_fs_fs/cached_data.c
  (dgb__log_access,
   create_rep_state_body,
   svn_fs_fs__rep_chain_length,
   build_rep_list,
   svn_fs_fs__get_file_delta_stream,
   block_read_windows): update users

* subversion/libsvn_fs_fs/pack.c
  (copy_rep_to_temp): ditto

* subversion/libsvn_fs_fs/recovery.c
  (recover_find_max_ids): ditto

* subversion/libsvn_fs_fs/transaction.c
  (rep_write_get_baton,
   write_hash_delta_rep): ditto

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/pack.c
    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=1489804&r1=1489803&r2=1489804&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 Wed Jun  5 10:44:02 2013
@@ -122,9 +122,9 @@ dgb__log_access(svn_fs_t *fs,
       svn_fs_fs__rep_header_t *header = item;
       if (header == NULL)
         description = "  (txdelta window)";
-      else if (!header->is_delta)
+      else if (header->type == svn_fs_fs__rep_plain)
         description = "  PLAIN";
-      else if (header->is_delta_vs_empty)
+      else if (header->type == svn_fs_fs__rep_self_delta)
         description = "  DELTA";
       else
         description = apr_psprintf(scratch_pool,
@@ -757,7 +757,7 @@ create_rep_state_body(rep_state_t **rep_
   *rep_state = rs;
   *rep_header = rh;
 
-  if (!rh->is_delta)
+  if (rh->type == svn_fs_fs__rep_plain)
     /* This is a plaintext, so just return the current rep_state. */
     return SVN_NO_ERROR;
 
@@ -865,7 +865,7 @@ svn_fs_fs__rep_chain_length(int *chain_l
       base_rep.item_index = header->base_item_index;
       base_rep.size = header->base_length;
       svn_fs_fs__id_txn_reset(&base_rep.txn_id);
-      is_delta = header->is_delta;
+      is_delta = header->type == svn_fs_fs__rep_delta;
 
       ++count;
       if (count % 16 == 0)
@@ -1121,7 +1121,7 @@ build_rep_list(apr_array_header_t **list
      Please note that for all non-empty deltas have
      a 4-byte header _plus_ some data. */
   if (*expanded_size == 0)
-    if (! rep_header->is_delta || first_rep->size != 4)
+    if (rep_header->type == svn_fs_fs__rep_plain || first_rep->size != 4)
       *expanded_size = first_rep->size;
 
   while (1)
@@ -1145,7 +1145,7 @@ build_rep_list(apr_array_header_t **list
           return SVN_NO_ERROR;
         }
 
-      if (!rep_header->is_delta)
+      if (rep_header->type == svn_fs_fs__rep_plain)
         {
           /* This is a plaintext, so just return the current rep_state. */
           *src_state = rs;
@@ -1154,7 +1154,7 @@ build_rep_list(apr_array_header_t **list
 
       /* Push this rep onto the list.  If it's self-compressed, we're done. */
       APR_ARRAY_PUSH(*list, rep_state_t *) = rs;
-      if (rep_header->is_delta_vs_empty)
+      if (rep_header->type == svn_fs_fs__rep_self_delta)
         {
           *src_state = NULL;
           return SVN_NO_ERROR;
@@ -1810,10 +1810,10 @@ svn_fs_fs__get_file_delta_stream(svn_txd
       SVN_ERR(create_rep_state(&rep_state, &rep_header, NULL,
                                target->data_rep, fs, pool));
       /* If that matches source, then use this delta as is. */
-      if (rep_header->is_delta
-          && (rep_header->is_delta_vs_empty
-              || (rep_header->base_revision == source->data_rep->revision
-                  && rep_header->base_item_index == source->data_rep->item_index)))
+      if (rep_header->type == svn_fs_fs__rep_self_delta
+          || (rep_header->type == svn_fs_fs__rep_delta
+              && rep_header->base_revision == source->data_rep->revision
+              && rep_header->base_item_index == source->data_rep->item_index))
         {
           /* Create the delta read baton. */
           struct delta_read_baton *drb = apr_pcalloc(pool, sizeof(*drb));
@@ -2264,8 +2264,10 @@ block_read_windows(svn_fs_fs__rep_header
   svn_boolean_t is_cached = FALSE;
   window_cache_key_t key = { 0 };
 
-  if (   (rep_header->is_delta && !ffd->txdelta_window_cache)
-      || (!rep_header->is_delta && !ffd->combined_window_cache))
+  if (   (rep_header->type != svn_fs_fs__rep_plain
+          && !ffd->txdelta_window_cache)
+      || (rep_header->type == svn_fs_fs__rep_plain
+          && !ffd->combined_window_cache))
     return SVN_NO_ERROR;
 
   /* we don't support containers, yet */
@@ -2282,7 +2284,7 @@ block_read_windows(svn_fs_fs__rep_header
   rs.item_index = entry->items[0].number;
   rs.header_size = rep_header->header_size;
   rs.start = entry->offset + rs.header_size;
-  rs.current = rep_header->is_delta ? 4 : 0;
+  rs.current = rep_header->type == svn_fs_fs__rep_plain ? 0 : 4;
   rs.size = entry->size - rep_header->header_size - 7;
   rs.ver = 1;
   rs.chunk_index = 0;
@@ -2292,7 +2294,7 @@ block_read_windows(svn_fs_fs__rep_header
   /* RS->FILE may be shared between RS instances -> make sure we point
    * to the right data. */
   offset = rs.start + rs.current;
-  if (!rep_header->is_delta)
+  if (rep_header->type == svn_fs_fs__rep_plain)
     {
       svn_stringbuf_t *plaintext;
       

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=1489804&r1=1489803&r2=1489804&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 Wed Jun  5 10:44:02 2013
@@ -640,18 +640,19 @@ svn_fs_fs__read_rep_header(svn_fs_fs__re
   *header = apr_pcalloc(pool, sizeof(**header));
   (*header)->header_size = buffer->len + 1;
   if (strcmp(buffer->data, REP_PLAIN) == 0)
-    return SVN_NO_ERROR;
+    {
+      (*header)->type = svn_fs_fs__rep_plain;
+      return SVN_NO_ERROR;
+    }
 
   if (strcmp(buffer->data, REP_DELTA) == 0)
     {
       /* This is a delta against the empty stream. */
-      (*header)->is_delta = TRUE;
-      (*header)->is_delta_vs_empty = TRUE;
+      (*header)->type = svn_fs_fs__rep_self_delta;
       return SVN_NO_ERROR;
     }
 
-  (*header)->is_delta = TRUE;
-  (*header)->is_delta_vs_empty = FALSE;
+  (*header)->type = svn_fs_fs__rep_delta;
 
   /* We have hopefully a DELTA vs. a non-empty base revision. */
   last_str = buffer->data;
@@ -690,20 +691,21 @@ svn_fs_fs__write_rep_header(svn_fs_fs__r
 {
   const char *text;
   
-  if (!header->is_delta)
-    {
-      text = REP_PLAIN "\n";
-    }
-  else if (header->is_delta_vs_empty)
-    {
-      text = REP_DELTA "\n";
-    }
-  else
+  switch (header->type)
     {
-      text = apr_psprintf(pool, REP_DELTA " %ld %" APR_OFF_T_FMT " %"
-                          SVN_FILESIZE_T_FMT "\n",
-                          header->base_revision, header->base_item_index,
-                          header->base_length);
+      case svn_fs_fs__rep_plain:
+        text = REP_PLAIN "\n";
+        break;
+
+      case svn_fs_fs__rep_self_delta:
+        text = REP_DELTA "\n";
+        break;
+
+      default:
+        text = apr_psprintf(pool, REP_DELTA " %ld %" APR_OFF_T_FMT " %"
+                            SVN_FILESIZE_T_FMT "\n",
+                            header->base_revision, header->base_item_index,
+                            header->base_length);
     }
 
   return svn_error_trace(svn_stream_puts(stream, text));

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=1489804&r1=1489803&r2=1489804&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 Wed Jun  5 10:44:02 2013
@@ -88,17 +88,25 @@ svn_fs_fs__write_noderev(svn_stream_t *o
                          svn_boolean_t include_mergeinfo,
                          apr_pool_t *pool);
 
+/* This type enumerates all forms of representations that we support. */
+typedef enum svn_fs_fs__rep_type_t
+{
+  /* this is a PLAIN representation */
+  svn_fs_fs__rep_plain,
+
+  /* this is a DELTA representation with no base representation */
+  svn_fs_fs__rep_self_delta,
+
+  /* this is a DELTA representation against some base representation */
+  svn_fs_fs__rep_delta
+} svn_fs_fs__rep_type_t;
+
 /* This structure is used to hold the information stored in a representation
  * header. */
 typedef struct svn_fs_fs__rep_header_t
 {
-  /* if TRUE,  this is a DELTA rep, PLAIN otherwise */
-  svn_boolean_t is_delta;
-
-  /* if IS_DELTA is TRUE, this flag indicates that there is no base rep,
-   * i.e. this rep is simply self-compressed.  Ignored for PLAIN reps
-   * but should be FALSE in that case. */
-  svn_boolean_t is_delta_vs_empty;
+  /* type of the representation, i.e. whether it is PLAIN, self-DELTA etc. */
+  svn_fs_fs__rep_type_t type;
 
   /* if this rep is a delta against some other rep, that base rep can
    * be found in this revision.  Should be 0 if there is no base rep. */

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c?rev=1489804&r1=1489803&r2=1489804&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c Wed Jun  5 10:44:02 2013
@@ -514,8 +514,7 @@ copy_rep_to_temp(pack_context_t *context
   svn_stream_close(stream);
 
   /* if the representation is a delta against some other rep, link the two */
-  if (   rep_header->is_delta
-      && !rep_header->is_delta_vs_empty
+  if (   rep_header->type == svn_fs_fs__rep_delta
       && rep_header->base_revision >= context->start_rev)
     {
       int idx = get_item_array_index(context, rep_header->base_revision,

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=1489804&r1=1489803&r2=1489804&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c Wed Jun  5 10:44:02 2013
@@ -192,7 +192,7 @@ recover_find_max_ids(svn_fs_t *fs, svn_r
 
   baton.stream = svn_stream_from_aprfile2(rev_file, TRUE, pool);
   SVN_ERR(svn_fs_fs__read_rep_header(&header, baton.stream, pool));
-  if (header->is_delta)
+  if (header->type != svn_fs_fs__rep_plain)
     return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                             _("Recovery encountered a deltified directory "
                               "representation"));

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=1489804&r1=1489803&r2=1489804&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c Wed Jun  5 10:44:02 2013
@@ -1911,10 +1911,11 @@ rep_write_get_baton(struct rep_write_bat
       header.base_revision = base_rep->revision;
       header.base_item_index = base_rep->item_index;
       header.base_length = base_rep->size;
+      header.type = svn_fs_fs__rep_delta;
     }
   else
     {
-      header.is_delta_vs_empty = TRUE;
+      header.type = svn_fs_fs__rep_self_delta;
     }
   SVN_ERR(svn_fs_fs__write_rep_header(&header, b->rep_stream, b->pool));
 
@@ -2453,10 +2454,11 @@ write_hash_delta_rep(representation_t *r
       header.base_revision = base_rep->revision;
       header.base_item_index = base_rep->item_index;
       header.base_length = base_rep->size;
+      header.type = svn_fs_fs__rep_delta;
     }
   else
     {
-      header.is_delta_vs_empty = TRUE;
+      header.type = svn_fs_fs__rep_self_delta;
     }
 
   file_stream = svn_stream_from_aprfile2(file, TRUE, pool);