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 21:26:31 UTC

svn commit: r1648108 - in /subversion/branches/fsx-id/subversion/libsvn_fs_x: dag.c fs_id.c fs_id.h id.c id.h tree.c

Author: stefan2
Date: Sat Dec 27 20:26:30 2014
New Revision: 1648108

URL: http://svn.apache.org/r1648108
Log:
On the fsx-id branch:  Split off the FS API ID implementation from the
id.* files that will henceforth only contain the internal ID handling.

* subversion/libsvn_fs_x/fs_id.h
  (svn_fs_x__id_create): The only function we keep here. 

* subversion/libsvn_fs_x/fs_id.c
  (fs_x__id_t): Move here.
  (id_unparse): Same; reimplement using functions from id.h.
  (id_compare,
   id_vtable,
   svn_fs_x__id_create): Move here.

* subversion/libsvn_fs_x/id.h
  (svn_fs_x__id_create): Remove here.

* subversion/libsvn_fs_x/id.c
  (fs_x__id_t,
   id_unparse,
   id_compare,
   id_vtable,
   svn_fs_x__id_create): Remove here.

* subversion/libsvn_fs_x/tree.c
* subversion/libsvn_fs_x/dag.c
  (): Update #includes.

Added:
    subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.c
      - copied, changed from r1648097, subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c
    subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.h
      - copied, changed from r1648097, subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h
Modified:
    subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c
    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/tree.c

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c?rev=1648108&r1=1648107&r2=1648108&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c Sat Dec 27 20:26:30 2014
@@ -31,7 +31,7 @@
 #include "dag.h"
 #include "fs.h"
 #include "fs_x.h"
-#include "id.h"
+#include "fs_id.h"
 #include "cached_data.h"
 #include "transaction.h"
 

Copied: subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.c (from r1648097, subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c)
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.c?p2=subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.c&p1=subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c&r1=1648097&r2=1648108&rev=1648108&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.c Sat Dec 27 20:26:30 2014
@@ -1,4 +1,4 @@
-/* id.c : operations on node-revision IDs
+/* fs_id.c : FSX's implementation of svn_fs_id_t
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -20,16 +20,9 @@
  * ====================================================================
  */
 
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "id.h"
-#include "index.h"
-#include "util.h"
+#include "fs_id.h"
 
 #include "../libsvn_fs/fs-loader.h"
-#include "private/svn_temp_serializer.h"
 #include "private/svn_string_private.h"
 
 
@@ -46,177 +39,17 @@ typedef struct fs_x__id_t
 
 
 
-svn_boolean_t
-svn_fs_x__is_txn(svn_fs_x__change_set_t change_set)
-{
-  return change_set < SVN_FS_X__INVALID_CHANGE_SET;
-}
-
-svn_boolean_t
-svn_fs_x__is_revision(svn_fs_x__change_set_t change_set)
-{
-  return change_set > SVN_FS_X__INVALID_CHANGE_SET;
-}
-
-svn_revnum_t
-svn_fs_x__get_revnum(svn_fs_x__change_set_t change_set)
-{
-  return svn_fs_x__is_revision(change_set)
-       ? (svn_revnum_t)change_set
-       : SVN_INVALID_REVNUM;
-}
-
-apr_int64_t
-svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set)
-{
-  return svn_fs_x__is_txn(change_set)
-       ? -change_set + SVN_FS_X__INVALID_CHANGE_SET -1
-       : SVN_FS_X__INVALID_TXN_ID;
-}
-
-
-svn_fs_x__change_set_t
-svn_fs_x__change_set_by_rev(svn_revnum_t revnum)
-{
-  assert(revnum >= SVN_FS_X__INVALID_CHANGE_SET);
-  return revnum;
-}
-
-svn_fs_x__change_set_t
-svn_fs_x__change_set_by_txn(apr_int64_t txn_id)
-{
-  assert(txn_id >= SVN_FS_X__INVALID_CHANGE_SET);
-  return -txn_id + SVN_FS_X__INVALID_CHANGE_SET -1;
-}
-
-
-/* Parse the NUL-terminated ID part at DATA and write the result into *PART.
- * Return TRUE if no errors were detected. */
-static svn_boolean_t
-part_parse(svn_fs_x__id_part_t *part,
-           const char *data)
-{
-  part->number = svn__base36toui64(&data, data);
-  switch (data[0])
-    {
-      /* txn number? */
-      case '-': part->change_set = -svn__base36toui64(&data, data + 1);
-                return TRUE;
-
-      /* revision number? */
-      case '+': part->change_set = svn__base36toui64(&data, data + 1);
-                return TRUE;
-
-      /* everything else is forbidden */
-      default:  return FALSE;
-    }
-}
-
-/* Write the textual representation of *PART into P and return a pointer
- * to the first position behind that string.
- */
-static char *
-part_unparse(char *p,
-             const svn_fs_x__id_part_t *part)
-{
-  p += svn__ui64tobase36(p, part->number);
-  if (part->change_set >= 0)
-    {
-      *(p++) = '+';
-      p += svn__ui64tobase36(p, part->change_set);
-    }
-  else
-    {
-      *(p++) = '-';
-      p += svn__ui64tobase36(p, -part->change_set);
-    }
-
-  return p;
-}
-
-
-
-/* Operations on ID parts */
-
-svn_boolean_t
-svn_fs_x__id_part_is_root(const svn_fs_x__id_part_t* part)
-{
-  return part->change_set == 0 && part->number == 0;
-}
-
-svn_boolean_t
-svn_fs_x__id_part_eq(const svn_fs_x__id_part_t *lhs,
-                     const svn_fs_x__id_part_t *rhs)
-{
-  return lhs->change_set == rhs->change_set && lhs->number == rhs->number;
-}
-
-svn_error_t *
-svn_fs_x__id_part_parse(svn_fs_x__id_part_t *part,
-                        const char *data)
-{
-  if (!part_parse(part, data))
-    return svn_error_createf(SVN_ERR_FS_MALFORMED_NODEREV_ID, NULL,
-                             "Malformed ID string");
-
-  return SVN_NO_ERROR;
-}
-
-svn_string_t *
-svn_fs_x__id_part_unparse(const svn_fs_x__id_part_t *id,
-                          apr_pool_t *pool)
-{
-  char string[2 * SVN_INT64_BUFFER_SIZE + 1];
-  char *p = part_unparse(string, id);
-
-  return svn_string_ncreate(string, p - string, pool);
-}
-
-void
-svn_fs_x__id_part_reset(svn_fs_x__id_part_t *part)
-{
-  part->change_set = SVN_FS_X__INVALID_CHANGE_SET;
-  part->number = 0;
-}
-
-svn_boolean_t
-svn_fs_x__id_part_used(const svn_fs_x__id_part_t *part)
-{
-  return part->change_set != SVN_FS_X__INVALID_CHANGE_SET;
-}
-
-void
-svn_fs_x__init_txn_root(svn_fs_x__noderev_id_t *noderev_id,
-                        svn_fs_x__txn_id_t txn_id)
-{
-  noderev_id->change_set = svn_fs_x__change_set_by_txn(txn_id);
-  noderev_id->number = SVN_FS_X__ITEM_INDEX_ROOT_NODE;
-}
-
-void
-svn_fs_x__init_rev_root(svn_fs_x__noderev_id_t *noderev_id,
-                        svn_revnum_t rev)
-{
-  noderev_id->change_set = svn_fs_x__change_set_by_rev(rev);
-  noderev_id->number = SVN_FS_X__ITEM_INDEX_ROOT_NODE;
-}
-
-
-
 /* Accessing ID Pieces.  */
 
 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;
+  svn_string_t *node_id = svn_fs_x__id_part_unparse(&id->node_id, pool);
+  svn_string_t *noderev_id = svn_fs_x__id_part_unparse(&id->noderev_id, pool);
 
-  char *p = part_unparse(string, &id->node_id);
-  *(p++) = '.';
-  p = part_unparse(p, &id->noderev_id);
-
-  return svn_string_ncreate(string, p - string, pool);
+  return svn_string_createf(pool, "%s.%s", node_id->data, noderev_id->data);
 }
 
 
@@ -244,19 +77,6 @@ id_compare(const svn_fs_id_t *a,
        : svn_fs_node_unrelated;
 }
 
-int
-svn_fs_x__id_part_compare(const svn_fs_x__id_part_t *a,
-                          const svn_fs_x__id_part_t *b)
-{
-  if (a->change_set < b->change_set)
-    return -1;
-  if (a->change_set > b->change_set)
-    return 1;
-
-  return a->number < b->number ? -1 : a->number == b->number ? 0 : 1;
-}
-
-
 
 /* Creating ID's.  */
 

Copied: subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.h (from r1648097, subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h)
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.h?p2=subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.h&p1=subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h&r1=1648097&r2=1648108&rev=1648108&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_id.h Sat Dec 27 20:26:30 2014
@@ -1,4 +1,4 @@
-/* id.h : interface to node ID functions, private to libsvn_fs_x
+/* fs_id.h : FSX's implementation of svn_fs_id_t
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -20,110 +20,15 @@
  * ====================================================================
  */
 
-#ifndef SVN_LIBSVN_FS_X_ID_H
-#define SVN_LIBSVN_FS_X_ID_H
+#ifndef SVN_LIBSVN_FS_X_FS_ID_H
+#define SVN_LIBSVN_FS_X_FS_ID_H
 
-#include "svn_fs.h"
+#include "id.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-/* Unique identifier for a transaction within the given repository. */
-typedef apr_int64_t svn_fs_x__txn_id_t;
-
-/* svn_fs_x__txn_id_t value for everything that is not a transaction. */
-#define SVN_FS_X__INVALID_TXN_ID ((svn_fs_x__txn_id_t)(-1))
-
-/* Change set is the umbrella term for transaction and revision in FSX.
- * Revision numbers (>=0) map 1:1 onto change sets while txns are mapped
- * onto the negatve value range. */
-typedef apr_int64_t svn_fs_x__change_set_t;
-
-/* Invalid / unused change set number. */
-#define SVN_FS_X__INVALID_CHANGE_SET  ((svn_fs_x__change_set_t)(-1))
-
-/* Return TRUE iff the CHANGE_SET refers to a revision
-   (will return FALSE for SVN_INVALID_REVNUM). */
-svn_boolean_t svn_fs_x__is_revision(svn_fs_x__change_set_t change_set);
-
-/* Return TRUE iff the CHANGE_SET refers to a transaction
-   (will return FALSE for SVN_FS_X__INVALID_TXN_ID). */
-svn_boolean_t svn_fs_x__is_txn(svn_fs_x__change_set_t change_set);
-
-/* Return the revision number that corresponds to CHANGE_SET.
-   Will SVN_INVALID_REVNUM for transactions. */
-svn_revnum_t svn_fs_x__get_revnum(svn_fs_x__change_set_t change_set);
-
-/* Return the transaction ID that corresponds to CHANGE_SET.
-   Will SVN_FS_X__INVALID_TXN_ID for revisions. */
-apr_int64_t svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set);
-
-/* Convert REVNUM into a change set number */
-svn_fs_x__change_set_t svn_fs_x__change_set_by_rev(svn_revnum_t revnum);
-
-/* Convert TXN_ID into a change set number */
-svn_fs_x__change_set_t svn_fs_x__change_set_by_txn(apr_int64_t txn_id);
-
-/* A rev node ID in FSX consists of a 3 of sub-IDs ("parts") that consist
- * of a creation CHANGE_SET number and some revision-local counter value
- * (NUMBER).
- */
-typedef struct svn_fs_x__id_part_t
-{
-  svn_fs_x__change_set_t change_set;
-
-  apr_uint64_t number;
-} svn_fs_x__id_part_t;
-
-/* Noderevs are identified by part IDs like everything else in FSX. */
-typedef svn_fs_x__id_part_t svn_fs_x__noderev_id_t;
-
-
-/*** Operations on ID parts. ***/
-
-/* Return TRUE, if both elements of the PART is 0, i.e. this is the default
- * value if e.g. no copies were made of this node. */
-svn_boolean_t svn_fs_x__id_part_is_root(const svn_fs_x__id_part_t *part);
-
-/* Return TRUE, if all element values of *LHS and *RHS match. */
-svn_boolean_t svn_fs_x__id_part_eq(const svn_fs_x__id_part_t *lhs,
-                                   const svn_fs_x__id_part_t *rhs);
-
-/* Parse the NUL-terminated ID part at DATA and write the result into *PART.
- */
-svn_error_t *
-svn_fs_x__id_part_parse(svn_fs_x__id_part_t *part,
-                        const char *data);
-
-/* Convert ID into string form, allocated in POOL. */
-svn_string_t *
-svn_fs_x__id_part_unparse(const svn_fs_x__id_part_t*id,
-                          apr_pool_t *pool);
-
-/* Set *PART to "unused". */
-void svn_fs_x__id_part_reset(svn_fs_x__id_part_t *part);
-
-/* Return TRUE if *PART is belongs to either a revision or transaction. */
-svn_boolean_t svn_fs_x__id_part_used(const svn_fs_x__id_part_t *part);
-
-/* Return 0 if A and B are equal, 1 if A is "greater than" B, -1 otherwise. */
-int svn_fs_x__id_part_compare(const svn_fs_x__id_part_t *a,
-                              const svn_fs_x__id_part_t *b);
-
-/* Set *NODEREV_ID to the root node ID of transaction TXN_ID. */
-void
-svn_fs_x__init_txn_root(svn_fs_x__noderev_id_t *noderev_id,
-                        svn_fs_x__txn_id_t txn_id);
-
-/* Set *NODEREV_ID to the root node ID of revision REV. */
-void
-svn_fs_x__init_rev_root(svn_fs_x__noderev_id_t *noderev_id,
-                        svn_revnum_t rev);
-
-
-/*** ID accessor functions. ***/
-
 /* 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,
@@ -134,4 +39,4 @@ svn_fs_id_t *svn_fs_x__id_create(const s
 }
 #endif /* __cplusplus */
 
-#endif /* SVN_LIBSVN_FS_X_ID_H */
+#endif /* SVN_LIBSVN_FS_X_FS_ID_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=1648108&r1=1648107&r2=1648108&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 20:26:30 2014
@@ -1,4 +1,4 @@
-/* id.c : operations on node-revision IDs
+/* id.c : implements FSX-internal ID functions
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -21,30 +21,14 @@
  */
 
 #include <assert.h>
-#include <string.h>
-#include <stdlib.h>
 
 #include "id.h"
 #include "index.h"
 #include "util.h"
 
-#include "../libsvn_fs/fs-loader.h"
-#include "private/svn_temp_serializer.h"
 #include "private/svn_string_private.h"
 
 
-typedef struct fs_x__id_t
-{
-  /* API visible part */
-  svn_fs_id_t generic_id;
-
-  /* private members */
-  svn_fs_x__id_part_t node_id;
-  svn_fs_x__id_part_t noderev_id;
-
-} fs_x__id_t;
-
-
 
 svn_boolean_t
 svn_fs_x__is_txn(svn_fs_x__change_set_t change_set)
@@ -201,49 +185,6 @@ svn_fs_x__init_rev_root(svn_fs_x__nodere
   noderev_id->number = SVN_FS_X__ITEM_INDEX_ROOT_NODE;
 }
 
-
-
-/* Accessing ID Pieces.  */
-
-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;
-
-  char *p = part_unparse(string, &id->node_id);
-  *(p++) = '.';
-  p = part_unparse(p, &id->noderev_id);
-
-  return svn_string_ncreate(string, p - string, pool);
-}
-
-
-/*** Comparing node IDs ***/
-
-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;
-
-  /* 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 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
 svn_fs_x__id_part_compare(const svn_fs_x__id_part_t *a,
                           const svn_fs_x__id_part_t *b)
@@ -255,32 +196,3 @@ svn_fs_x__id_part_compare(const svn_fs_x
 
   return a->number < b->number ? -1 : a->number == b->number ? 0 : 1;
 }
-
-
-
-/* Creating ID's.  */
-
-static id_vtable_t id_vtable = {
-  id_unparse,
-  id_compare
-};
-
-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)
-{
-  fs_x__id_t *id;
-  if (!svn_fs_x__id_part_used(noderev_id))
-    return NULL;
-
-  id = apr_pcalloc(pool, sizeof(*id));
-
-  id->node_id = *node_id;
-  id->noderev_id = *noderev_id;
-
-  id->generic_id.vtable = &id_vtable;
-  id->generic_id.fsap_data = id;
-
-  return (svn_fs_id_t *)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=1648108&r1=1648107&r2=1648108&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 20:26:30 2014
@@ -1,4 +1,4 @@
-/* id.h : interface to node ID functions, private to libsvn_fs_x
+/* id.h : interface to FSX-internal ID functions
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -121,15 +121,6 @@ void
 svn_fs_x__init_rev_root(svn_fs_x__noderev_id_t *noderev_id,
                         svn_revnum_t rev);
 
-
-/*** ID accessor functions. ***/
-
-/* 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);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c?rev=1648108&r1=1648107&r2=1648108&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c Sat Dec 27 20:26:30 2014
@@ -56,7 +56,7 @@
 #include "lock.h"
 #include "tree.h"
 #include "fs_x.h"
-#include "id.h"
+#include "fs_id.h"
 #include "temp_serializer.h"
 #include "cached_data.h"
 #include "transaction.h"