subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1454671 - in /subversion/branches/fsfs-format7/subversion: include/svn_error_codes.h libsvn_fs_fs/fs.h libsvn_fs_fs/fs_fs.c libsvn_fs_fs/id.c libsvn_fs_fs/id.h libsvn_fs_fs/low_level.c libsvn_fs_fs/temp_serializer.c libsvn_fs_fs/transaction.c
Date Sat, 09 Mar 2013 07:40:24 GMT
Author: stefan2
Date: Sat Mar  9 07:40:24 2013
New Revision: 1454671

URL: http://svn.apache.org/r1454671
Log:
On the fsfs-format7 branch:  Switch the representation uniquifier from
string to integers.  This is the first place where a transaction ID is
no longer used in its string format.

This is part of the "numerical IDs" patch series.

* subversion/include/svn_error_codes.h
  (SVN_ERR_FS_MALFORMED_TXN_ID): declare new error code

* subversion/libsvn_fs_fs/id.h
  (svn_fs_fs__id_part_t): document txn-id-specific behavior
  (svn_fs_fs__id_txn_parse,
   svn_fs_fs__id_txn_unparse): declare new API functions

* subversion/libsvn_fs_fs/id.c
  (txn_id_parse): new parser utility
  (svn_fs_fs__id_txn_parse,
   svn_fs_fs__id_txn_unparse): implement new API functions

* subversion/libsvn_fs_fs/fs.h
  (representation_t): the uniquifier is now a struct of ints

* subversion/libsvn_fs_fs/fs_fs.c
  (svn_fs_fs__noderev_same_rep_key,
   svn_fs_fs__rep_copy): update and simplify

* subversion/libsvn_fs_fs/low_level.c
  (svn_fs_fs__parse_representation,
   svn_fs_fs__unparse_representation): convert uniquifier <-> string

* subversion/libsvn_fs_fs/temp_serializer.c
  (serialize_representation,
   deserialize_representation): update and simplify

* subversion/libsvn_fs_fs/transaction.c
  (set_uniquifier): convert txn id string -> id part

* subversion/tests/cmdline/svntest/main.py

Modified:
    subversion/branches/fsfs-format7/subversion/include/svn_error_codes.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/branches/fsfs-format7/subversion/include/svn_error_codes.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/include/svn_error_codes.h?rev=1454671&r1=1454670&r2=1454671&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/include/svn_error_codes.h (original)
+++ subversion/branches/fsfs-format7/subversion/include/svn_error_codes.h Sat Mar  9 07:40:24
2013
@@ -807,6 +807,11 @@ SVN_ERROR_START
              SVN_ERR_FS_CATEGORY_START + 55,
              "Item index too large for this revision.")
 
+  /** @since New in 1.9. */
+  SVN_ERRDEF(SVN_ERR_FS_MALFORMED_TXN_ID,
+             SVN_ERR_FS_CATEGORY_START + 56,
+             "Malformed transaction ID string.")
+
   /* repos errors */
 
   SVN_ERRDEF(SVN_ERR_REPOS_LOCKED,

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h?rev=1454671&r1=1454670&r2=1454671&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h Sat Mar  9 07:40:24 2013
@@ -487,11 +487,12 @@ typedef struct representation_t
   /* For rep-sharing, we need a way of uniquifying node-revs which share the
      same representation (see svn_fs_fs__noderev_same_rep_key() ).  So, we
      store the original txn of the node rev (not the rep!), along with some
-     intra-node uniqification content.
-
-     May be NULL, in which case, it is considered to match other NULL
-     values.*/
-  const char *uniquifier;
+     intra-node uniqification content. */
+  struct
+  {
+    svn_fs_fs__id_part_t txn_id;
+    apr_uint64_t number;
+  } uniquifier;
 } representation_t;
 
 

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c?rev=1454671&r1=1454670&r2=1454671&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c Sat Mar  9 07:40:24 2013
@@ -836,13 +836,7 @@ svn_fs_fs__noderev_same_rep_key(represen
   if (a->revision != b->revision)
     return FALSE;
 
-  if (a->uniquifier == b->uniquifier)
-    return TRUE;
-
-  if (a->uniquifier == NULL || b->uniquifier == NULL)
-    return FALSE;
-
-  return strcmp(a->uniquifier, b->uniquifier) == 0;
+  return memcmp(&a->uniquifier, &b->uniquifier, sizeof(a->uniquifier)) ==
0;
 }
 
 svn_error_t *
@@ -882,12 +876,11 @@ svn_fs_fs__rep_copy(representation_t *re
   if (rep == NULL)
     return NULL;
 
-  rep_new = apr_pcalloc(pool, sizeof(*rep_new));
+  rep_new = apr_palloc(pool, sizeof(*rep_new));
 
   memcpy(rep_new, rep, sizeof(*rep_new));
   rep_new->md5_checksum = svn_checksum_dup(rep->md5_checksum, pool);
   rep_new->sha1_checksum = svn_checksum_dup(rep->sha1_checksum, pool);
-  rep_new->uniquifier = apr_pstrdup(pool, rep->uniquifier);
 
   return rep_new;
 }

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.c?rev=1454671&r1=1454670&r2=1454671&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.c Sat Mar  9 07:40:24 2013
@@ -78,6 +78,22 @@ part_parse(svn_fs_fs__id_part_t *part,
   return TRUE;
 }
 
+/* Parse the transaction id in DATA and store the result in *TXN_ID.
+ * Return FALSE if there was some problem.
+ */
+static svn_boolean_t
+txn_id_parse(svn_fs_fs__id_part_t *txn_id,
+             const char *data)
+{
+  txn_id->revision = SVN_STR_TO_REV(data);
+  data = strchr(data, '-');
+  if (data == NULL)
+    return FALSE;
+  
+  txn_id->number = svn__base36toui64(&data, ++data);
+  return *data == '\0';
+}
+
 /* Write the textual representation of *PART into P and return a pointer
  * to the first position behind that string.
  */
@@ -124,6 +140,31 @@ svn_fs_fs__id_part_eq(const svn_fs_fs__i
   return lhs->revision == rhs->revision && lhs->number == rhs->number;
 }
 
+svn_error_t *
+svn_fs_fs__id_txn_parse(svn_fs_fs__id_part_t *txn_id,
+                        const char *data)
+{
+  if (! txn_id_parse(txn_id, data))
+    return svn_error_createf(SVN_ERR_FS_MALFORMED_TXN_ID, NULL,
+                             "malformed txn id '%s'", data);
+
+  return SVN_NO_ERROR;
+}
+
+const char *
+svn_fs_fs__id_txn_unparse(const svn_fs_fs__id_part_t *txn_id,
+                          apr_pool_t *pool)
+{
+  char string[2 * SVN_INT64_BUFFER_SIZE + 1];
+  char *p = string;
+  
+  p += svn__i64toa(p, txn_id->revision);
+  *(p++) = '-';
+  p += svn__ui64tobase36(p, txn_id->number);
+
+  return apr_pstrmemdup(pool, string, p - string);
+}
+
 
 
 /* Accessing ID Pieces.  */

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.h?rev=1454671&r1=1454670&r2=1454671&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/id.h Sat Mar  9 07:40:24 2013
@@ -35,8 +35,9 @@ extern "C" {
  */
 typedef struct svn_fs_fs__id_part_t
 {
-  /* SVN_INVALID_REVNUM -> not assigned to a revision, yet
-     0                  -> old-style ID or the root in rev 0. */
+  /* SVN_INVALID_REVNUM for txns -> not a txn, COUNTER must be 0.
+     SVN_INVALID_REVNUM for others -> not assigned to a revision, yet.
+     0                  for others -> old-style ID or the root in rev 0. */
   svn_revnum_t revision;
 
   /* some numerical value. */
@@ -54,6 +55,15 @@ svn_boolean_t svn_fs_fs__id_part_is_root
 svn_boolean_t svn_fs_fs__id_part_eq(const svn_fs_fs__id_part_t *lhs,
                                     const svn_fs_fs__id_part_t *rhs);
 
+/* Parse the transaction id in DATA and store the result in *TXN_ID */
+svn_error_t *svn_fs_fs__id_txn_parse(svn_fs_fs__id_part_t *txn_id,
+                                     const char *data);
+
+/* Convert the transaction id in *TXN_ID into a textual representation
+ * allocated in POOL. */
+const char *svn_fs_fs__id_txn_unparse(const svn_fs_fs__id_part_t *txn_id,
+                                      apr_pool_t *pool);
+
 
 /*** ID accessor functions. ***/
 

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=1454671&r1=1454670&r2=1454671&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 Sat Mar  9 07:40:24
2013
@@ -26,6 +26,7 @@
 #include "svn_private_config.h"
 #include "svn_pools.h"
 #include "svn_sorts.h"
+#include "private/svn_string_private.h"
 
 #include "../libsvn_fs/fs-loader.h"
 
@@ -313,12 +314,19 @@ svn_fs_fs__parse_representation(represen
                                  pool));
 
   /* Read the uniquifier. */
+  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"));
+
+  SVN_ERR(svn_fs_fs__id_txn_parse(&rep->uniquifier.txn_id, str));
+
   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"));
 
-  rep->uniquifier = apr_pstrdup(pool, str);
+  rep->uniquifier.number = svn__base36toui64(NULL, str);
 
   return SVN_NO_ERROR;
 }
@@ -521,6 +529,7 @@ svn_fs_fs__unparse_representation(repres
                                   svn_boolean_t may_be_corrupt,
                                   apr_pool_t *pool)
 {
+  char buffer[SVN_INT64_BUFFER_SIZE];
   if (rep->txn_id && mutable_rep_truncated)
     return svn_stringbuf_ncreate("-1", 2, pool);
 
@@ -537,14 +546,16 @@ svn_fs_fs__unparse_representation(repres
              rep->expanded_size,
              DISPLAY_MAYBE_NULL_CHECKSUM(rep->md5_checksum));
 
+  svn__ui64tobase36(buffer, rep->uniquifier.number);
   return svn_stringbuf_createf
           (pool, "%ld %" APR_OFF_T_FMT " %" SVN_FILESIZE_T_FMT
-           " %" SVN_FILESIZE_T_FMT " %s %s %s",
+           " %" SVN_FILESIZE_T_FMT " %s %s %s/%s",
            rep->revision, rep->item_index, rep->size,
            rep->expanded_size,
            DISPLAY_MAYBE_NULL_CHECKSUM(rep->md5_checksum),
            DISPLAY_MAYBE_NULL_CHECKSUM(rep->sha1_checksum),
-           rep->uniquifier);
+           svn_fs_fs__id_txn_unparse(&rep->uniquifier.txn_id, pool),
+           buffer);
 
 #undef DISPLAY_MAYBE_NULL_CHECKSUM
 

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c?rev=1454671&r1=1454670&r2=1454671&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c Sat Mar  9
07:40:24 2013
@@ -185,7 +185,6 @@ serialize_representation(svn_temp_serial
   serialize_checksum(context, &rep->sha1_checksum);
 
   svn_temp_serializer__add_string(context, &rep->txn_id);
-  svn_temp_serializer__add_string(context, &rep->uniquifier);
 
   /* return to the caller's nesting level */
   svn_temp_serializer__pop(context);
@@ -210,7 +209,6 @@ deserialize_representation(void *buffer,
   deserialize_checksum(rep, &rep->sha1_checksum);
 
   svn_temp_deserializer__resolve(rep, (void **)&rep->txn_id);
-  svn_temp_deserializer__resolve(rep, (void **)&rep->uniquifier);
 }
 
 /* auxilliary structure representing the content of a directory hash */

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=1454671&r1=1454670&r2=1454671&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c Sat Mar  9 07:40:24
2013
@@ -1440,12 +1440,11 @@ set_uniquifier(svn_fs_t *fs,
                const char *txn_id,
                apr_pool_t *pool)
 {
-  char unique_suffix[SVN_INT64_BUFFER_SIZE];
   svn_fs_fs__id_part_t temp;
 
   SVN_ERR(get_new_txn_node_id(&temp, fs, txn_id, pool));
-  svn__ui64tobase36(unique_suffix, temp.number);
-  rep->uniquifier = apr_psprintf(pool, "%s/_%s", txn_id, unique_suffix);
+  SVN_ERR(svn_fs_fs__id_txn_parse(&rep->uniquifier.txn_id, txn_id));
+  rep->uniquifier.number = temp.number;
 
   return SVN_NO_ERROR;
 }



Mime
View raw message