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/15 14:31:26 UTC
svn commit: r1645655 - in
/subversion/branches/fsx-id/subversion/libsvn_fs_x: cached_data.c
cached_data.h dag.c dag.h id.c id.h transaction.c
Author: stefan2
Date: Mon Dec 15 13:31:26 2014
New Revision: 1645655
URL: http://svn.apache.org/r1645655
Log:
On the fsx-id branch: Begin to isolate our internal ID usage from
FS API ID by storing only the noderev ID inside the DAG node.
We introduce two new DAG accessor functions, svn_fs_x__dag_get_fs_id
and the temporary svn_fs_x__dag_get_noderev_id. The latter will
later be renamed to and replace svn_fs_x__dag_get_id.
To be able to update the DAG function implementations, we need two
new ID helpers and must switch other internal API functions to the
new noderev ID.
* subversion/libsvn_fs_x/id.h
(svn_fs_x__id_part_reset,
svn_fs_x__id_part_used): Declare new internal API functions.
* subversion/libsvn_fs_x/id.c
(svn_fs_x__id_part_reset,
svn_fs_x__id_part_used): Implement.
* subversion/libsvn_fs_x/cached_data.h
(svn_fs_x__rev_get_root): Switch signature our internal ID type and
drop the result pool. The caller now
provides the ID struct.
* subversion/libsvn_fs_x/cached_data.c
(svn_fs_x__rev_get_root): Update Implementation.
* subversion/libsvn_fs_x/transaction.c
(create_new_txn_noderev_from_rev): Switch to our internal ID type.
(svn_fs_x__create_txn): Update caller.
* subversion/libsvn_fs_x/dag.h
(svn_fs_x__dag_get_id): The node parameter is now, temporarily, mutable.
This will later be replaced by ...
(svn_fs_x__dag_get_noderev_id): ... this new function.
(svn_fs_x__dag_get_fs_id): New function. To be used where we actually
want an FS API level ID.
* subversion/libsvn_fs_x/dag.c
(dag_node_t): Switch members to our internal ID type.
(svn_fs_x__dag_get_id): Reimplement to temporary backward compat.
Will eventually be replaced by ...
(svn_fs_x__dag_get_noderev_id): ... this new code.
(get_node_revision): Update and simplify.
(svn_fs_x__dag_get_fs_id): Implement new function.
(svn_fs_x__dag_check_mutable,
svn_fs_x__dag_get_node,
svn_fs_x__dag_get_revision,
svn_fs_x__dag_set_proplist,
svn_fs_x__dag_increment_mergeinfo_count,
svn_fs_x__dag_set_has_mergeinfo,
svn_fs_x__dag_revision_root,
svn_fs_x__dag_clone_child,
svn_fs_x__dag_dup): Update struct accessors and API callers.
(svn_fs_x__dag_serialize,
svn_fs_x__dag_deserialize): Update and simplify.
(svn_fs_x__dag_update_ancestry): For now, use the ID provided in
the noderev struct.
Modified:
subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.c
subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.h
subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c
subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h
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/transaction.c
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.c?rev=1645655&r1=1645654&r2=1645655&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.c Mon Dec 15 13:31:26 2014
@@ -449,14 +449,15 @@ svn_fs_x__get_mergeinfo_count(apr_int64_
svn_error_t *
-svn_fs_x__rev_get_root(svn_fs_id_t **root_id_p,
+svn_fs_x__rev_get_root(svn_fs_x__id_part_t *root_id,
svn_fs_t *fs,
svn_revnum_t rev,
- apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
SVN_ERR(svn_fs_x__ensure_revision_exists(rev, fs, scratch_pool));
- *root_id_p = svn_fs_x__id_create_root(rev, result_pool);
+
+ root_id->change_set = svn_fs_x__change_set_by_rev(rev);
+ root_id->number = SVN_FS_X__ITEM_INDEX_ROOT_NODE;
return SVN_NO_ERROR;
}
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.h?rev=1645655&r1=1645654&r2=1645655&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.h (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/cached_data.h Mon Dec 15 13:31:26 2014
@@ -48,13 +48,12 @@ svn_fs_x__get_mergeinfo_count(apr_int64_
const svn_fs_x__noderev_id_t *id,
apr_pool_t *pool);
-/* Set *ROOT_ID to the node-id for the root of revision REV in
- filesystem FS. Do any allocations in POOL. */
+/* Set *ROOT_ID to the noderev ID for the root of revision REV in
+ filesystem FS. Do temporary allocations in SCRATCH_POOL. */
svn_error_t *
-svn_fs_x__rev_get_root(svn_fs_id_t **root_id,
+svn_fs_x__rev_get_root(svn_fs_x__id_part_t *root_id,
svn_fs_t *fs,
svn_revnum_t rev,
- apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Verify that representation REP in FS can be accessed.
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=1645655&r1=1645654&r2=1645655&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c Mon Dec 15 13:31:26 2014
@@ -50,14 +50,14 @@ struct dag_node_t
/* The filesystem this dag node came from. */
svn_fs_t *fs;
- /* The node revision ID for this dag node, allocated in POOL. */
- svn_fs_id_t *id;
+ /* The node revision ID for this dag node. */
+ svn_fs_x__noderev_id_t id;
/* In the special case that this node is the root of a transaction
that has not yet been modified, the node revision ID for this dag
node's predecessor; otherwise NULL. (Used in
svn_fs_node_created_rev.) */
- const svn_fs_id_t *fresh_root_predecessor_id;
+ svn_fs_x__noderev_id_t fresh_root_predecessor_id;
/* The node's type (file, dir, etc.) */
svn_node_kind_t kind;
@@ -88,9 +88,24 @@ svn_node_kind_t svn_fs_x__dag_node_kind(
const svn_fs_id_t *
-svn_fs_x__dag_get_id(const dag_node_t *node)
+svn_fs_x__dag_get_id(dag_node_t *node)
+{
+ const svn_fs_id_t *id;
+ svn_error_t *err = svn_fs_x__dag_get_fs_id(&id, node, node->node_pool);
+ if (err)
+ {
+ svn_error_clear(err);
+ SVN_ERR_MALFUNCTION_NO_RETURN();
+ }
+
+ return id;
+}
+
+
+const svn_fs_x__noderev_id_t *
+svn_fs_x__dag_get_noderev_id(const dag_node_t *node)
{
- return node->id;
+ return &node->id;
}
@@ -160,12 +175,10 @@ get_node_revision(node_revision_t **node
if (! node->node_revision)
{
node_revision_t *noderev;
- const svn_fs_x__id_part_t *noderev_id = svn_fs_x__id_noderev_id(node->id);
apr_pool_t *scratch_pool = svn_pool_create(node->node_pool);
- SVN_ERR(svn_fs_x__get_node_revision(&noderev, node->fs,
- noderev_id, node->node_pool,
- scratch_pool));
+ SVN_ERR(svn_fs_x__get_node_revision(&noderev, node->fs, &node->id,
+ node->node_pool, scratch_pool));
node->node_revision = noderev;
svn_pool_destroy(scratch_pool);
}
@@ -176,9 +189,22 @@ get_node_revision(node_revision_t **node
}
+svn_error_t *
+svn_fs_x__dag_get_fs_id(const svn_fs_id_t **id,
+ dag_node_t *node,
+ apr_pool_t *result_pool)
+{
+ node_revision_t *noderev;
+ SVN_ERR(get_node_revision(&noderev, node));
+ *id = svn_fs_x__id_copy(noderev->id, result_pool);
+
+ return SVN_NO_ERROR;
+}
+
+
svn_boolean_t svn_fs_x__dag_check_mutable(const dag_node_t *node)
{
- return svn_fs_x__id_is_txn(svn_fs_x__dag_get_id(node));
+ return svn_fs_x__is_txn(svn_fs_x__dag_get_noderev_id(node)->change_set);
}
@@ -194,7 +220,7 @@ svn_fs_x__dag_get_node(dag_node_t **node
/* Construct the node. */
new_node = apr_pcalloc(pool, sizeof(*new_node));
new_node->fs = fs;
- new_node->id = svn_fs_x__id_copy(id, pool);
+ new_node->id = *svn_fs_x__id_noderev_id(id);
/* Grab the contents so we can inspect the node's kind and created path. */
new_node->node_pool = pool;
@@ -205,9 +231,10 @@ svn_fs_x__dag_get_node(dag_node_t **node
new_node->created_path = apr_pstrdup(pool, noderev->created_path);
if (noderev->is_fresh_txn_root)
- new_node->fresh_root_predecessor_id = noderev->predecessor_id;
+ new_node->fresh_root_predecessor_id
+ = *svn_fs_x__id_noderev_id(noderev->predecessor_id);
else
- new_node->fresh_root_predecessor_id = NULL;
+ svn_fs_x__id_part_reset(&new_node->fresh_root_predecessor_id);
/* Return a fresh new node */
*node = new_node;
@@ -223,11 +250,13 @@ svn_fs_x__dag_get_revision(svn_revnum_t
/* In the special case that this is an unmodified transaction root,
we need to actually get the revision of the noderev's predecessor
(the revision root); see Issue #2608. */
- const svn_fs_id_t *correct_id = node->fresh_root_predecessor_id
- ? node->fresh_root_predecessor_id : node->id;
+ const svn_fs_x__noderev_id_t *correct_id
+ = svn_fs_x__id_part_used(&node->fresh_root_predecessor_id)
+ ? &node->fresh_root_predecessor_id
+ : &node->id;
/* Look up the committed revision from the Node-ID. */
- *rev = svn_fs_x__id_rev(correct_id);
+ *rev = svn_fs_x__get_revnum(correct_id->change_set);
return SVN_NO_ERROR;
}
@@ -509,7 +538,7 @@ svn_fs_x__dag_set_proplist(dag_node_t *n
/* Sanity check: this node better be mutable! */
if (! svn_fs_x__dag_check_mutable(node))
{
- svn_string_t *idstr = svn_fs_x__id_unparse(node->id, pool);
+ svn_string_t *idstr = svn_fs_x__noderev_id_unparse(&node->id, pool);
return svn_error_createf
(SVN_ERR_FS_NOT_MUTABLE, NULL,
"Can't set proplist on *immutable* node-revision %s",
@@ -534,7 +563,7 @@ svn_fs_x__dag_increment_mergeinfo_count(
/* Sanity check: this node better be mutable! */
if (! svn_fs_x__dag_check_mutable(node))
{
- svn_string_t *idstr = svn_fs_x__id_unparse(node->id, pool);
+ svn_string_t *idstr = svn_fs_x__noderev_id_unparse(&node->id, pool);
return svn_error_createf
(SVN_ERR_FS_NOT_MUTABLE, NULL,
"Can't increment mergeinfo count on *immutable* node-revision %s",
@@ -550,7 +579,7 @@ svn_fs_x__dag_increment_mergeinfo_count(
noderev->mergeinfo_count += increment;
if (noderev->mergeinfo_count < 0)
{
- svn_string_t *idstr = svn_fs_x__id_unparse(node->id, pool);
+ svn_string_t *idstr = svn_fs_x__noderev_id_unparse(&node->id, pool);
return svn_error_createf
(SVN_ERR_FS_CORRUPT, NULL,
apr_psprintf(pool,
@@ -561,7 +590,7 @@ svn_fs_x__dag_increment_mergeinfo_count(
}
if (noderev->mergeinfo_count > 1 && noderev->kind == svn_node_file)
{
- svn_string_t *idstr = svn_fs_x__id_unparse(node->id, pool);
+ svn_string_t *idstr = svn_fs_x__noderev_id_unparse(&node->id, pool);
return svn_error_createf
(SVN_ERR_FS_CORRUPT, NULL,
apr_psprintf(pool,
@@ -586,7 +615,7 @@ svn_fs_x__dag_set_has_mergeinfo(dag_node
/* Sanity check: this node better be mutable! */
if (! svn_fs_x__dag_check_mutable(node))
{
- svn_string_t *idstr = svn_fs_x__id_unparse(node->id, pool);
+ svn_string_t *idstr = svn_fs_x__noderev_id_unparse(&node->id, pool);
return svn_error_createf
(SVN_ERR_FS_NOT_MUTABLE, NULL,
"Can't set mergeinfo flag on *immutable* node-revision %s",
@@ -617,7 +646,8 @@ svn_fs_x__dag_revision_root(dag_node_t *
/* Construct the node. */
new_node = apr_pcalloc(pool, sizeof(*new_node));
new_node->fs = fs;
- SVN_ERR(svn_fs_x__rev_get_root(&new_node->id, fs, rev, pool, pool));
+ SVN_ERR(svn_fs_x__rev_get_root(&new_node->id, fs, rev, pool));
+ svn_fs_x__id_part_reset(&new_node->fresh_root_predecessor_id);
/* Grab the contents so we can inspect the node's kind and created path. */
new_node->node_pool = pool;
@@ -625,7 +655,6 @@ svn_fs_x__dag_revision_root(dag_node_t *
/* Initialize the KIND and CREATED_PATH attributes */
new_node->kind = svn_node_dir;
new_node->created_path = "/";
- new_node->fresh_root_predecessor_id = NULL;
/* Return a fresh new node */
*node_p = new_node;
@@ -698,7 +727,7 @@ svn_fs_x__dag_clone_child(dag_node_t **c
if (svn_fs_x__dag_check_mutable(cur_entry))
{
/* This has already been cloned */
- new_node_id = cur_entry->id;
+ new_node_id = svn_fs_x__dag_get_id(cur_entry);
}
else
{
@@ -718,13 +747,15 @@ svn_fs_x__dag_clone_child(dag_node_t **c
noderev->copyfrom_path = NULL;
noderev->copyfrom_rev = SVN_INVALID_REVNUM;
- noderev->predecessor_id = svn_fs_x__id_copy(cur_entry->id, pool);
+ SVN_ERR(svn_fs_x__dag_get_fs_id(&noderev->predecessor_id, cur_entry,
+ pool));
if (noderev->predecessor_count != -1)
noderev->predecessor_count++;
noderev->created_path = svn_fspath__join(parent_path, name, pool);
- SVN_ERR(svn_fs_x__create_successor(&new_node_id, fs, cur_entry->id,
- noderev, copy_id, txn_id, pool));
+ SVN_ERR(svn_fs_x__create_successor(&new_node_id, fs,
+ noderev->predecessor_id,
+ noderev, copy_id, txn_id, pool));
/* Replace the ID in the parent's ENTRY list with the ID which
refers to the mutable clone of this child. */
@@ -1078,11 +1109,7 @@ svn_fs_x__dag_dup(const dag_node_t *node
apr_pool_t *pool)
{
/* Allocate our new node. */
- dag_node_t *new_node = apr_pcalloc(pool, sizeof(*new_node));
-
- new_node->fs = node->fs;
- new_node->id = svn_fs_x__id_copy(node->id, pool);
- new_node->kind = node->kind;
+ dag_node_t *new_node = apr_pmemdup(pool, node, sizeof(*new_node));
new_node->created_path = apr_pstrdup(pool, node->created_path);
/* Only copy cached node_revision_t for immutable nodes. */
@@ -1127,8 +1154,6 @@ svn_fs_x__dag_serialize(void **data,
(const void * const *)&node->node_pool);
/* serialize other sub-structures */
- svn_fs_x__id_serialize(context, (const svn_fs_id_t **)&node->id);
- svn_fs_x__id_serialize(context, &node->fresh_root_predecessor_id);
svn_temp_serializer__add_string(context, &node->created_path);
/* return serialized data */
@@ -1154,10 +1179,6 @@ svn_fs_x__dag_deserialize(void **out,
node->fs = NULL;
/* fixup all references to sub-structures */
- svn_fs_x__id_deserialize(node, &node->id, pool);
- svn_fs_x__id_deserialize(node,
- (svn_fs_id_t **)&node->fresh_root_predecessor_id,
- pool);
svn_fs_x__noderev_deserialize(node, &node->node_revision, pool);
node->node_pool = pool;
@@ -1355,11 +1376,11 @@ svn_fs_x__dag_update_ancestry(dag_node_t
SVN_ERR(get_node_revision(&source_noderev, source));
SVN_ERR(get_node_revision(&target_noderev, target));
- target_noderev->predecessor_id = source->id;
+ target_noderev->predecessor_id = source_noderev->id;
target_noderev->predecessor_count = source_noderev->predecessor_count;
if (target_noderev->predecessor_count != -1)
target_noderev->predecessor_count++;
- return svn_fs_x__put_node_revision(target->fs, target->id, target_noderev,
- FALSE, pool);
+ return svn_fs_x__put_node_revision(target->fs, target_noderev->id,
+ target_noderev, FALSE, pool);
}
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h?rev=1645655&r1=1645654&r2=1645655&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h Mon Dec 15 13:31:26 2014
@@ -114,8 +114,19 @@ svn_error_t *svn_fs_x__dag_get_revision(
/* Return the node revision ID of NODE. The value returned is shared
with NODE, and will be deallocated when NODE is. */
-const svn_fs_id_t *svn_fs_x__dag_get_id(const dag_node_t *node);
+const svn_fs_id_t *svn_fs_x__dag_get_id(dag_node_t *node);
+/* Return the node revision ID of NODE. The value returned is shared
+ with NODE, and will be deallocated when NODE is. */
+const svn_fs_x__noderev_id_t *
+svn_fs_x__dag_get_noderev_id(const dag_node_t *node);
+
+/* Return the FS API node revision ID of NODE in *ID, allocated in
+ RESULT_POOL. */
+svn_error_t *
+svn_fs_x__dag_get_fs_id(const svn_fs_id_t **id,
+ dag_node_t *node,
+ apr_pool_t *result_pool);
/* Return the created path of NODE. The value returned is shared
with NODE, and will be deallocated when NODE is. */
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=1645655&r1=1645654&r2=1645655&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/id.c Mon Dec 15 13:31:26 2014
@@ -163,6 +163,18 @@ svn_fs_x__noderev_id_unparse(const svn_f
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;
+}
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=1645655&r1=1645654&r2=1645655&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/id.h Mon Dec 15 13:31:26 2014
@@ -95,6 +95,12 @@ svn_string_t *
svn_fs_x__noderev_id_unparse(const svn_fs_x__noderev_id_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);
+
/*** ID accessor functions. ***/
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c?rev=1645655&r1=1645654&r2=1645655&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c Mon Dec 15 13:31:26 2014
@@ -1154,13 +1154,11 @@ svn_fs_x__paths_changed(apr_hash_t **cha
static svn_error_t *
create_new_txn_noderev_from_rev(svn_fs_t *fs,
svn_fs_x__txn_id_t txn_id,
- svn_fs_id_t *src,
+ svn_fs_x__id_part_t *src,
apr_pool_t *pool)
{
node_revision_t *noderev;
- const svn_fs_x__id_part_t *src_id = svn_fs_x__id_noderev_id(src);
-
- SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, src_id, pool, pool));
+ SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, src, pool, pool));
/* This must be a root node. */
SVN_ERR_ASSERT( svn_fs_x__id_node_id(noderev->id)->number == 0
@@ -1257,7 +1255,7 @@ svn_fs_x__create_txn(svn_fs_txn_t **txn_
{
svn_fs_txn_t *txn;
fs_txn_data_t *ftd;
- svn_fs_id_t *root_id;
+ svn_fs_x__id_part_t root_id;
txn = apr_pcalloc(pool, sizeof(*txn));
ftd = apr_pcalloc(pool, sizeof(*ftd));
@@ -1273,8 +1271,8 @@ svn_fs_x__create_txn(svn_fs_txn_t **txn_
*txn_p = txn;
/* Create a new root node for this transaction. */
- SVN_ERR(svn_fs_x__rev_get_root(&root_id, fs, rev, pool, pool));
- SVN_ERR(create_new_txn_noderev_from_rev(fs, ftd->txn_id, root_id, pool));
+ SVN_ERR(svn_fs_x__rev_get_root(&root_id, fs, rev, pool));
+ SVN_ERR(create_new_txn_noderev_from_rev(fs, ftd->txn_id, &root_id, pool));
/* Create an empty rev file. */
SVN_ERR(svn_io_file_create_empty(