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 2014/12/27 20:48:46 UTC

svn commit: r1648097 - in /subversion/branches/fsx-id/subversion/libsvn_fs_x: id.c id.h temp_serializer.c temp_serializer.h

Author: stefan2
Date: Sat Dec 27 19:48:45 2014
New Revision: 1648097

URL: http://svn.apache.org/r1648097
Log:
On the fsx-id branch:  Remove the now unused FS API ID serialization and
parser support.  Minimize the FS API ID functions to a single constructor.

* subversion/libsvn_fs_x/temp_serializer.h
  (svn_fs_x__serialize_id,
   svn_fs_x__deserialize_id): Drop.

* subversion/libsvn_fs_x/temp_serializer.c
  (svn_fs_x__serialize_id,
   svn_fs_x__deserialize_id): Drop.

* subversion/libsvn_fs_x/id.h
  (svn_fs_x__id_node_id,
   svn_fs_x__id_noderev_id,
   svn_fs_x__id_is_txn,
   svn_fs_x__id_unparse,
   svn_fs_x__id_eq,
   svn_fs_x__id_copy,
   svn_fs_x__id_parse,
   svn_fs_x__id_serialize,
   svn_fs_x__id_deserialize): Drop.

* subversion/libsvn_fs_x/id.c
  (svn_fs_x__id_node_id,
   svn_fs_x__id_noderev_id,
   svn_fs_x__id_is_txn): Drop.
  (svn_fs_x__id_unparse): Rename to ...
  (id_unparse): ... this.
  (svn_fs_x__id_eq,
   id_check_related): Merge into ...
  (id_compare): ... this one.
  (id_vtable): Update function reference.
  (svn_fs_x__id_copy,
   id_parse,
   svn_fs_x__id_parse,
   svn_fs_x__id_serialize,
   svn_fs_x__id_deserialize): Drop.

Modified:
    subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c
    subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h
    subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.c
    subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.h

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c?rev=1648097&r1=1648096&r2=1648097&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c Sat Dec 27 19:48:45 2014
@@ -205,34 +205,9 @@ svn_fs_x__init_rev_root(svn_fs_x__nodere
 
 /* Accessing ID Pieces.  */
 
-const svn_fs_x__id_part_t *
-svn_fs_x__id_node_id(const svn_fs_id_t *fs_id)
-{
-  const fs_x__id_t *id = (const fs_x__id_t *)fs_id;
-
-  return &id->node_id;
-}
-
-
-const svn_fs_x__noderev_id_t *
-svn_fs_x__id_noderev_id(const svn_fs_id_t* fs_id)
-{
-  const fs_x__id_t *id = (const fs_x__id_t *)fs_id;
-
-  return &id->noderev_id;
-}
-
-svn_boolean_t
-svn_fs_x__id_is_txn(const svn_fs_id_t *fs_id)
-{
-  const fs_x__id_t *id = (const fs_x__id_t *)fs_id;
-
-  return svn_fs_x__is_txn(id->noderev_id.change_set);
-}
-
-svn_string_t *
-svn_fs_x__id_unparse(const svn_fs_id_t *fs_id,
-                     apr_pool_t *pool)
+static svn_string_t *
+id_unparse(const svn_fs_id_t *fs_id,
+           apr_pool_t *pool)
 {
   char string[4 * SVN_INT64_BUFFER_SIZE + 4];
   const fs_x__id_t *id = (const fs_x__id_t *)fs_id;
@@ -247,46 +222,26 @@ svn_fs_x__id_unparse(const svn_fs_id_t *
 
 /*** Comparing node IDs ***/
 
-svn_boolean_t
-svn_fs_x__id_eq(const svn_fs_id_t *a,
-                const svn_fs_id_t *b)
-{
-  const fs_x__id_t *id_a = (const fs_x__id_t *)a;
-  const fs_x__id_t *id_b = (const fs_x__id_t *)b;
-
-  return svn_fs_x__id_part_eq(&id_a->noderev_id, &id_b->noderev_id);
-}
-
-
-static svn_boolean_t
-id_check_related(const svn_fs_id_t *a,
-                 const svn_fs_id_t *b)
+static svn_fs_node_relation_t
+id_compare(const svn_fs_id_t *a,
+           const svn_fs_id_t *b)
 {
   const fs_x__id_t *id_a = (const fs_x__id_t *)a;
   const fs_x__id_t *id_b = (const fs_x__id_t *)b;
 
-  if (a == b)
-    return TRUE;
+  /* Quick check: same IDs? */
+  if (svn_fs_x__id_part_eq(&id_a->noderev_id, &id_b->noderev_id))
+    return svn_fs_node_same;
 
   /* Items from different txns are unrelated. */
   if (   svn_fs_x__is_txn(id_a->noderev_id.change_set)
       && svn_fs_x__is_txn(id_b->noderev_id.change_set)
       && id_a->noderev_id.change_set != id_b->noderev_id.change_set)
-    return FALSE;
+    return svn_fs_node_unrelated;
 
-  /* related if they trace back to the same node creation */
-  return svn_fs_x__id_part_eq(&id_a->node_id, &id_b->node_id);
-}
-
-
-static svn_fs_node_relation_t
-id_compare(const svn_fs_id_t *a,
-           const svn_fs_id_t *b)
-{
-  if (svn_fs_x__id_eq(a, b))
-    return svn_fs_node_same;
-  return (id_check_related(a, b) ? svn_fs_node_common_ancestor
-                                 : svn_fs_node_unrelated);
+  return svn_fs_x__id_part_eq(&id_a->node_id, &id_b->node_id)
+       ? svn_fs_node_common_ancestor
+       : svn_fs_node_unrelated;
 }
 
 int
@@ -306,7 +261,7 @@ svn_fs_x__id_part_compare(const svn_fs_x
 /* Creating ID's.  */
 
 static id_vtable_t id_vtable = {
-  svn_fs_x__id_unparse,
+  id_unparse,
   id_compare
 };
 
@@ -329,114 +284,3 @@ svn_fs_x__id_create(const svn_fs_x__id_p
 
   return (svn_fs_id_t *)id;
 }
-
-
-svn_fs_id_t *
-svn_fs_x__id_copy(const svn_fs_id_t *source, apr_pool_t *pool)
-{
-  const fs_x__id_t *id = (const fs_x__id_t *)source;
-  fs_x__id_t *new_id = apr_pmemdup(pool, id, sizeof(*new_id));
-
-  new_id->generic_id.fsap_data = new_id;
-
-  return (svn_fs_id_t *)new_id;
-}
-
-/* Return an ID resulting from parsing the string DATA, or NULL if DATA is
-   an invalid ID string. *DATA will be modified / invalidated by this call. */
-static svn_fs_id_t *
-id_parse(char *data,
-         apr_pool_t *pool)
-{
-  fs_x__id_t *id;
-  char *str;
-
-  /* Alloc a new svn_fs_id_t structure. */
-  id = apr_pcalloc(pool, sizeof(*id));
-  id->generic_id.vtable = &id_vtable;
-  id->generic_id.fsap_data = id;
-
-  /* Now, we basically just need to "split" this data on `.'
-     characters.  We will use svn_cstring_tokenize, which will put
-     terminators where each of the '.'s used to be.  Then our new
-     id field will reference string locations inside our duplicate
-     string.*/
-
-  /* Node Id */
-  str = svn_cstring_tokenize(".", &data);
-  if (str == NULL)
-    return NULL;
-  if (! part_parse(&id->node_id, str))
-    return NULL;
-
-  /* NodeRev Id */
-  str = svn_cstring_tokenize(".", &data);
-  if (str == NULL)
-    return NULL;
-
-  if (! part_parse(&id->noderev_id, str))
-    return NULL;
-
-  return (svn_fs_id_t *)id;
-}
-
-svn_error_t *
-svn_fs_x__id_parse(const svn_fs_id_t **id_p,
-                   char *data,
-                   apr_pool_t *pool)
-{
-  svn_fs_id_t *id = id_parse(data, pool);
-  if (id == NULL)
-    return svn_error_createf(SVN_ERR_FS_MALFORMED_NODEREV_ID, NULL,
-                             "Malformed node revision ID string");
-
-  *id_p = id;
-
-  return SVN_NO_ERROR;
-}
-
-/* (de-)serialization support */
-
-/* Serialize an ID within the serialization CONTEXT.
- */
-void
-svn_fs_x__id_serialize(svn_temp_serializer__context_t *context,
-                       const svn_fs_id_t * const *in)
-{
-  const fs_x__id_t *id = (const fs_x__id_t *)*in;
-
-  /* nothing to do for NULL ids */
-  if (id == NULL)
-    return;
-
-  /* serialize the id data struct itself */
-  svn_temp_serializer__add_leaf(context,
-                                (const void * const *)in,
-                                sizeof(fs_x__id_t));
-}
-
-/* Deserialize an ID inside the BUFFER.
- */
-void
-svn_fs_x__id_deserialize(void *buffer,
-                         svn_fs_id_t **in_out,
-                         apr_pool_t *pool)
-{
-  fs_x__id_t *id;
-
-  /* The id maybe all what is in the whole buffer.
-   * Don't try to fixup the pointer in that case*/
-  if (*in_out != buffer)
-    svn_temp_deserializer__resolve(buffer, (void**)in_out);
-
-  id = (fs_x__id_t *)*in_out;
-
-  /* no id, no sub-structure fixup necessary */
-  if (id == NULL)
-    return;
-
-  /* the stored vtable is bogus at best -> set the right one */
-  id->generic_id.vtable = &id_vtable;
-  id->generic_id.fsap_data = id;
-}
-

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h?rev=1648097&r1=1648096&r2=1648097&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h Sat Dec 27 19:48:45 2014
@@ -124,61 +124,12 @@ svn_fs_x__init_rev_root(svn_fs_x__nodere
 
 /*** ID accessor functions. ***/
 
-/* Get the "node id" portion of ID. */
-const svn_fs_x__id_part_t *svn_fs_x__id_node_id(const svn_fs_id_t *id);
-
-/* Get the "noderev id" portion of ID. */
-const svn_fs_x__noderev_id_t *svn_fs_x__id_noderev_id(const svn_fs_id_t *id);
-
-/* Return TRUE, if this is a transaction ID. */
-svn_boolean_t svn_fs_x__id_is_txn(const svn_fs_id_t *id);
-
-/* Convert ID into string form, allocated in POOL. */
-svn_string_t *svn_fs_x__id_unparse(const svn_fs_id_t *id,
-                                   apr_pool_t *pool);
-
-/* Return true if A and B are equal. */
-svn_boolean_t svn_fs_x__id_eq(const svn_fs_id_t *a,
-                              const svn_fs_id_t *b);
-
 /* Create a permanent ID based on NODE_ID and NODEREV_ID, allocated in
    POOL.  Return NULL, if the NODEREV_ID is "unused". */
 svn_fs_id_t *svn_fs_x__id_create(const svn_fs_x__id_part_t *node_id,
                                  const svn_fs_x__id_part_t *noderev_id,
                                  apr_pool_t *pool);
 
-/* Return a copy of ID, allocated from POOL. */
-svn_fs_id_t *svn_fs_x__id_copy(const svn_fs_id_t *id,
-                               apr_pool_t *pool);
-
-/* Return an ID in *ID_P resulting from parsing the string DATA, or an error
-   if DATA is an invalid ID string. *DATA will be modified / invalidated by
-   this call. */
-svn_error_t *
-svn_fs_x__id_parse(const svn_fs_id_t **id_p,
-                   char *data,
-                   apr_pool_t *pool);
-
-
-/* (de-)serialization support*/
-
-struct svn_temp_serializer__context_t;
-
-/**
- * Serialize an @a id within the serialization @a context.
- */
-void
-svn_fs_x__id_serialize(struct svn_temp_serializer__context_t *context,
-                        const svn_fs_id_t * const *id);
-
-/**
- * Deserialize an @a id within the @a buffer and associate it with @a pool.
- */
-void
-svn_fs_x__id_deserialize(void *buffer,
-                         svn_fs_id_t **id,
-                         apr_pool_t *pool);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.c?rev=1648097&r1=1648096&r2=1648097&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.c Sat Dec 27 19:48:45 2014
@@ -638,47 +638,6 @@ svn_fs_x__deserialize_properties(void **
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_fs_x__serialize_id(void **data,
-                       apr_size_t *data_len,
-                       void *in,
-                       apr_pool_t *pool)
-{
-  const svn_fs_id_t *id = in;
-  svn_stringbuf_t *serialized;
-
-  /* create an (empty) serialization context with plenty of buffer space */
-  svn_temp_serializer__context_t *context =
-      svn_temp_serializer__init(NULL, 0, 250, pool);
-
-  /* serialize the id */
-  svn_fs_x__id_serialize(context, &id);
-
-  /* return serialized data */
-  serialized = svn_temp_serializer__get(context);
-  *data = serialized->data;
-  *data_len = serialized->len;
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_fs_x__deserialize_id(void **out,
-                         void *data,
-                         apr_size_t data_len,
-                         apr_pool_t *pool)
-{
-  /* Copy the _full_ buffer as it also contains the sub-structures. */
-  svn_fs_id_t *id = (svn_fs_id_t *)data;
-
-  /* fixup of all pointers etc. */
-  svn_fs_x__id_deserialize(id, &id, pool);
-
-  /* done */
-  *out = id;
-  return SVN_NO_ERROR;
-}
-
 /** Caching node_revision_t objects. **/
 
 svn_error_t *

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.h?rev=1648097&r1=1648096&r2=1648097&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.h (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/temp_serializer.h Sat Dec 27 19:48:45 2014
@@ -23,6 +23,7 @@
 #ifndef SVN_LIBSVN_FS__TEMP_SERIALIZER_H
 #define SVN_LIBSVN_FS__TEMP_SERIALIZER_H
 
+#include "private/svn_temp_serializer.h"
 #include "fs.h"
 
 /**
@@ -146,24 +147,6 @@ svn_fs_x__deserialize_properties(void **
                                  apr_pool_t *pool);
 
 /**
- * Implements #svn_cache__serialize_func_t for #svn_fs_id_t
- */
-svn_error_t *
-svn_fs_x__serialize_id(void **data,
-                       apr_size_t *data_len,
-                       void *in,
-                       apr_pool_t *pool);
-
-/**
- * Implements #svn_cache__deserialize_func_t for #svn_fs_id_t
- */
-svn_error_t *
-svn_fs_x__deserialize_id(void **out,
-                         void *data,
-                         apr_size_t data_len,
-                         apr_pool_t *pool);
-
-/**
  * Implements #svn_cache__serialize_func_t for #node_revision_t
  */
 svn_error_t *