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 2015/02/10 19:25:02 UTC
svn commit: r1658776 - in
/subversion/branches/fsx-1.10/subversion/libsvn_fs_x: dag_cache.c tree.c
tree.h
Author: stefan2
Date: Tue Feb 10 18:25:02 2015
New Revision: 1658776
URL: http://svn.apache.org/r1658776
Log:
On the fsx-1.10 branch:
Eliminate code duplication between tree.c and dag_cache.c.
* subversion/libsvn_fs_x/tree.h
(svn_fs_x__root_txn_id,
svn_fs_x__root_node): Make these functions private APIs now.
* subversion/libsvn_fs_x/tree.c
(root_txn_id): Rename to ...
(svn_fs_x__root_txn_id): ... this and make it non-static.
(root_node): Rename to ...
(svn_fs_x__root_node): ... this and make it non-static.
Update sub-function call.
(x_change_node_prop,
x_make_dir,
x_delete_node,
copy_helper,
x_make_file,
apply_textdelta,
apply_text,
x_paths_changed,
svn_fs_x__verify_root): Update callers.
* subversion/libsvn_fs_x/dag_cache.c
(fs_txn_root_data_t,
root_txn_id): Remove here.
(root_change_set): Call new private API.
(root_node): Remove here.
(mutable_root_node,
svn_fs_x__get_dag_path,
svn_fs_x__make_path_mutable): Call new private API.
Modified:
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/dag_cache.c
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.c
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.h
Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/dag_cache.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/dag_cache.c?rev=1658776&r1=1658775&r2=1658776&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/dag_cache.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/dag_cache.c Tue Feb 10 18:25:02 2015
@@ -72,41 +72,15 @@
-/* The root structures.
-
- Why do they contain different data? Well, transactions are mutable
- enough that it isn't safe to cache the DAG node for the root
- directory or the hash of copyfrom data: somebody else might modify
- them concurrently on disk! (Why is the DAG node cache safer than
- the root DAG node? When cloning transaction DAG nodes in and out
- of the cache, all of the possibly-mutable data from the
- svn_fs_x__noderev_t inside the dag_node_t is dropped.) Additionally,
- revisions are immutable enough that their DAG node cache can be
- kept in the FS object and shared among multiple revision root
- objects.
-*/
-typedef struct fs_txn_root_data_t
-{
- /* TXN_ID value from the main struct but as a struct instead of a string */
- svn_fs_x__txn_id_t txn_id;
-} fs_txn_root_data_t;
-
-/* Return the transaction ID to a given transaction ROOT. */
-static svn_fs_x__txn_id_t
-root_txn_id(svn_fs_root_t *root)
-{
- fs_txn_root_data_t *frd = root->fsap_data;
- assert(root->is_txn_root);
-
- return frd->txn_id;
-}
/* Return the change set to a given ROOT. */
static svn_fs_x__change_set_t
root_change_set(svn_fs_root_t *root)
{
- return (root->is_txn_root ? svn_fs_x__change_set_by_txn(root_txn_id(root))
- : svn_fs_x__change_set_by_rev(root->rev) );
+ if (root->is_txn_root)
+ return svn_fs_x__change_set_by_txn(svn_fs_x__root_txn_id(root));
+
+ return svn_fs_x__change_set_by_rev(root->rev);
}
@@ -363,31 +337,6 @@ svn_fs_x__invalidate_dag_cache(svn_fs_ro
/* Getting dag nodes for roots. */
-/* Set *NODE_P to a freshly opened dag node referring to the root
- directory of ROOT, allocating from RESULT_POOL. Use SCRATCH_POOL
- for temporary allocations. */
-static svn_error_t *
-root_node(dag_node_t **node_p,
- svn_fs_root_t *root,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- if (root->is_txn_root)
- {
- /* It's a transaction root. Open a fresh copy. */
- return svn_fs_x__dag_txn_root(node_p, root->fs, root_txn_id(root),
- result_pool, scratch_pool);
- }
- else
- {
- /* It's a revision root, so we already have its root directory
- opened. */
- return svn_fs_x__dag_revision_root(node_p, root->fs, root->rev,
- result_pool, scratch_pool);
- }
-}
-
-
/* Set *NODE_P to a mutable root directory for ROOT, cloning if
necessary, allocating in RESULT_POOL. ROOT must be a transaction root.
Use ERROR_PATH in error messages. Use SCRATCH_POOL for temporaries.*/
@@ -401,7 +350,8 @@ mutable_root_node(dag_node_t **node_p,
if (root->is_txn_root)
{
/* It's a transaction root. Open a fresh copy. */
- return svn_fs_x__dag_txn_root(node_p, root->fs, root_txn_id(root),
+ return svn_fs_x__dag_txn_root(node_p, root->fs,
+ svn_fs_x__root_txn_id(root),
result_pool, scratch_pool);
}
else
@@ -665,7 +615,7 @@ svn_fs_x__get_dag_path(svn_fs_x__dag_pat
{
/* Make a parent_path item for the root node, using its own current
copy id. */
- SVN_ERR(root_node(&here, root, pool, iterpool));
+ SVN_ERR(svn_fs_x__root_node(&here, root, pool, iterpool));
rest = path + 1; /* skip the leading '/', it saves in iteration */
}
@@ -797,7 +747,7 @@ svn_fs_x__make_path_mutable(svn_fs_root_
apr_pool_t *scratch_pool)
{
dag_node_t *clone;
- svn_fs_x__txn_id_t txn_id = root_txn_id(root);
+ svn_fs_x__txn_id_t txn_id = svn_fs_x__root_txn_id(root);
/* Is the node mutable already? */
if (svn_fs_x__dag_check_mutable(parent_path->node))
Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.c?rev=1658776&r1=1658775&r2=1658776&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.c Tue Feb 10 18:25:02 2015
@@ -159,8 +159,8 @@ svn_fs_x__revision_root(svn_fs_root_t **
/* Getting dag nodes for roots. */
/* Return the transaction ID to a given transaction ROOT. */
-static svn_fs_x__txn_id_t
-root_txn_id(svn_fs_root_t *root)
+svn_fs_x__txn_id_t
+svn_fs_x__root_txn_id(svn_fs_root_t *root)
{
fs_txn_root_data_t *frd = root->fsap_data;
assert(root->is_txn_root);
@@ -171,16 +171,17 @@ root_txn_id(svn_fs_root_t *root)
/* Set *NODE_P to a freshly opened dag node referring to the root
directory of ROOT, allocating from RESULT_POOL. Use SCRATCH_POOL
for temporary allocations. */
-static svn_error_t *
-root_node(dag_node_t **node_p,
- svn_fs_root_t *root,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
+svn_error_t *
+svn_fs_x__root_node(dag_node_t **node_p,
+ svn_fs_root_t *root,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
if (root->is_txn_root)
{
/* It's a transaction root. Open a fresh copy. */
- return svn_fs_x__dag_txn_root(node_p, root->fs, root_txn_id(root),
+ return svn_fs_x__dag_txn_root(node_p, root->fs,
+ svn_fs_x__root_txn_id(root),
result_pool, scratch_pool);
}
else
@@ -527,7 +528,7 @@ x_change_node_prop(svn_fs_root_t *root,
if (! root->is_txn_root)
return SVN_FS__NOT_TXN(root);
- txn_id = root_txn_id(root);
+ txn_id = svn_fs_x__root_txn_id(root);
path = svn_fs__canonicalize_abspath(path, subpool);
SVN_ERR(svn_fs_x__get_dag_path(&dag_path, root, path, 0, TRUE, subpool));
@@ -1417,7 +1418,7 @@ x_make_dir(svn_fs_root_t *root,
{
svn_fs_x__dag_path_t *dag_path;
dag_node_t *sub_dir;
- svn_fs_x__txn_id_t txn_id = root_txn_id(root);
+ svn_fs_x__txn_id_t txn_id = svn_fs_x__root_txn_id(root);
apr_pool_t *subpool = svn_pool_create(scratch_pool);
path = svn_fs__canonicalize_abspath(path, subpool);
@@ -1477,7 +1478,7 @@ x_delete_node(svn_fs_root_t *root,
if (! root->is_txn_root)
return SVN_FS__NOT_TXN(root);
- txn_id = root_txn_id(root);
+ txn_id = svn_fs_x__root_txn_id(root);
path = svn_fs__canonicalize_abspath(path, subpool);
SVN_ERR(svn_fs_x__get_dag_path(&dag_path, root, path, 0, TRUE, subpool));
kind = svn_fs_x__dag_node_kind(dag_path->node);
@@ -1548,7 +1549,7 @@ copy_helper(svn_fs_root_t *from_root,
{
dag_node_t *from_node;
svn_fs_x__dag_path_t *to_dag_path;
- svn_fs_x__txn_id_t txn_id = root_txn_id(to_root);
+ svn_fs_x__txn_id_t txn_id = svn_fs_x__root_txn_id(to_root);
svn_boolean_t same_p;
/* Use an error check, not an assert, because even the caller cannot
@@ -1759,7 +1760,7 @@ x_make_file(svn_fs_root_t *root,
{
svn_fs_x__dag_path_t *dag_path;
dag_node_t *child;
- svn_fs_x__txn_id_t txn_id = root_txn_id(root);
+ svn_fs_x__txn_id_t txn_id = svn_fs_x__root_txn_id(root);
apr_pool_t *subpool = svn_pool_create(scratch_pool);
path = svn_fs__canonicalize_abspath(path, subpool);
@@ -1946,7 +1947,7 @@ apply_textdelta(void *baton,
{
txdelta_baton_t *tb = (txdelta_baton_t *) baton;
svn_fs_x__dag_path_t *dag_path;
- svn_fs_x__txn_id_t txn_id = root_txn_id(tb->root);
+ svn_fs_x__txn_id_t txn_id = svn_fs_x__root_txn_id(tb->root);
/* Call open_path with no flags, as we want this to return an error
if the node for which we are searching doesn't exist. */
@@ -2113,7 +2114,7 @@ apply_text(void *baton,
{
text_baton_t *tb = baton;
svn_fs_x__dag_path_t *dag_path;
- svn_fs_x__txn_id_t txn_id = root_txn_id(tb->root);
+ svn_fs_x__txn_id_t txn_id = svn_fs_x__root_txn_id(tb->root);
/* Call open_path with no flags, as we want this to return an error
if the node for which we are searching doesn't exist. */
@@ -2305,7 +2306,8 @@ x_paths_changed(apr_hash_t **changed_pat
{
apr_hash_index_t *hi;
SVN_ERR(svn_fs_x__txn_changes_fetch(&changed_paths, root->fs,
- root_txn_id(root), pool));
+ svn_fs_x__root_txn_id(root),
+ pool));
for (hi = apr_hash_first(pool, changed_paths);
hi;
hi = apr_hash_next(hi))
@@ -3446,7 +3448,7 @@ svn_fs_x__verify_root(svn_fs_root_t *roo
When this code is called in the library, we want to ensure we
use the on-disk data --- rather than some data that was read
in the possibly-distance past and cached since. */
- SVN_ERR(root_node(&root_dir, root, scratch_pool, scratch_pool));
+ SVN_ERR(svn_fs_x__root_node(&root_dir, root, scratch_pool, scratch_pool));
/* Recursively verify ROOT_DIR. */
parent_nodes = apr_array_make(scratch_pool, 16, sizeof(dag_node_t *));
Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.h?rev=1658776&r1=1658775&r2=1658776&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.h (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/tree.h Tue Feb 10 18:25:02 2015
@@ -24,6 +24,7 @@
#define SVN_LIBSVN_FS_X_TREE_H
#include "fs.h"
+#include "dag.h"
#ifdef __cplusplus
extern "C" {
@@ -31,6 +32,19 @@ extern "C" {
+/* Return the transaction ID to a given transaction ROOT. */
+svn_fs_x__txn_id_t
+svn_fs_x__root_txn_id(svn_fs_root_t *root);
+
+/* Set *NODE_P to a freshly opened dag node referring to the root
+ directory of ROOT, allocating from RESULT_POOL. Use SCRATCH_POOL
+ for temporary allocations. */
+svn_error_t *
+svn_fs_x__root_node(dag_node_t **node_p,
+ svn_fs_root_t *root,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
/* Set *ROOT_P to the root directory of revision REV in filesystem FS.
Allocate the structure in POOL. */
svn_error_t *