1 /* dag_cache.h : Interface to the DAG walker and node cache.
3 * ====================================================================
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
20 * ====================================================================
23 #ifndef SVN_LIBSVN_FS_X_DAG_CACHE_H
24 #define SVN_LIBSVN_FS_X_DAG_CACHE_H
30 #endif /* __cplusplus */
32 /* In RESULT_POOL, create an instance of a DAG node cache. */
33 svn_fs_x__dag_cache_t*
34 svn_fs_x__create_dag_cache(apr_pool_t *result_pool);
36 /* Invalidate cache entries for PATH within ROOT and any of its children. */
38 svn_fs_x__invalidate_dag_cache(svn_fs_root_t *root,
41 /* Flag type used in svn_fs_x__dag_path_t to determine where the
42 respective node got its copy ID from. */
43 typedef enum svn_fs_x__copy_id_inherit_t
45 svn_fs_x__copy_id_inherit_unknown = 0,
46 svn_fs_x__copy_id_inherit_self,
47 svn_fs_x__copy_id_inherit_parent,
48 svn_fs_x__copy_id_inherit_new
50 } svn_fs_x__copy_id_inherit_t;
52 /* Flags for svn_fs_x__get_dag_path. */
53 typedef enum svn_fs_x__dag_path_flags_t {
55 /* The last component of the PATH need not exist. (All parent
56 directories must exist, as usual.) If the last component doesn't
57 exist, simply leave the `node' member of the bottom parent_path
59 svn_fs_x__dag_path_last_optional = 1,
61 /* The caller wants a NULL path object instead of an error if the
62 path cannot be found. */
63 svn_fs_x__dag_path_allow_null = 2
64 } svn_fs_x__dag_path_flags_t;
67 /* A linked list representing the path from a node up to a root
68 directory. We use this for cloning, and for operations that need
69 to deal with both a node and its parent directory. For example, a
70 `delete' operation needs to know that the node actually exists, but
71 also needs to change the parent directory. */
72 typedef struct svn_fs_x__dag_path_t
74 /* A node along the path. This could be the final node, one of its
75 parents, or the root. Every parent path ends with an element for
76 the root directory. */
79 /* The name NODE has in its parent directory. This is zero for the
80 root directory, which (obviously) has no name in its parent. */
83 /* The parent of NODE, or zero if NODE is the root directory. */
84 struct svn_fs_x__dag_path_t *parent;
86 /* The copy ID inheritance style. */
87 svn_fs_x__copy_id_inherit_t copy_inherit;
89 /* If copy ID inheritance style is copy_id_inherit_new, this is the
90 path which should be implicitly copied; otherwise, this is NULL. */
91 const char *copy_src_path;
93 } svn_fs_x__dag_path_t;
95 /* Open the node identified by PATH in ROOT, allocating in RESULT_POOL.
96 Set *DAG_PATH_P to a path from the node up to ROOT. The resulting
97 **DAG_PATH_P value is guaranteed to contain at least one element,
98 for the root directory. PATH must be in canonical form. Allocate
99 temporaries from SCRATCH_POOL.
101 If resulting *PARENT_PATH_P will eventually be made mutable and
102 modified, or if copy ID inheritance information is otherwise needed,
103 IS_TXN_PATH must be set. If IS_TXN_PATH is FALSE, no copy ID
104 inheritance information will be calculated for the *PARENT_PATH_P chain.
106 If FLAGS & svn_fs_x__dag_path_last_optional is zero, return the error
107 SVN_ERR_FS_NOT_FOUND if the node PATH refers to does not exist. If
108 non-zero, require all the parent directories to exist as normal,
109 but if the final path component doesn't exist, simply return a path
110 whose bottom `node' member is zero. This option is useful for
111 callers that create new nodes --- we find the parent directory for
112 them, and tell them whether the entry exists already.
114 If FLAGS & svn_fs_x__dag_path_allow_null is non-zero, set the
115 *PARENT_PATH_P to NULL if any node in the path could not be found.
117 NOTE: Public interfaces which only *read* from the filesystem
118 should not call this function directly, but should instead use
119 svn_fs_x__get_dag_node().
122 svn_fs_x__get_dag_path(svn_fs_x__dag_path_t **dag_path_p,
126 svn_boolean_t is_txn_path,
127 apr_pool_t *result_pool,
128 apr_pool_t *scratch_pool);
130 /* Make the node referred to by PARENT_PATH mutable, if it isn't already,
131 allocating from RESULT_POOL. ROOT must be the root from which
132 PARENT_PATH descends. Clone any parent directories as needed.
133 Adjust the dag nodes in PARENT_PATH to refer to the clones. Use
134 ERROR_PATH in error messages. Use SCRATCH_POOL for temporaries. */
136 svn_fs_x__make_path_mutable(svn_fs_root_t *root,
137 svn_fs_x__dag_path_t *parent_path,
138 const char *error_path,
139 apr_pool_t *result_pool,
140 apr_pool_t *scratch_pool);
142 /* Open the node identified by PATH in ROOT. Set *DAG_NODE_P to a temporary
143 reference to the node we find. That reference will become invalid upon
144 the next access to the DAG cache.
146 Return the error SVN_ERR_FS_NOT_FOUND if this node doesn't exist.
149 svn_fs_x__get_temp_dag_node(dag_node_t **node_p,
152 apr_pool_t *scratch_pool);
154 /* Open the node identified by PATH in ROOT. Set *DAG_NODE_P to the
155 node we find, allocated in RESULT_POOL. Return the error
156 SVN_ERR_FS_NOT_FOUND if this node doesn't exist. Use SCRATCH_POOL
157 for temporary allocations.
160 svn_fs_x__get_dag_node(dag_node_t **dag_node_p,
163 apr_pool_t *result_pool,
164 apr_pool_t *scratch_pool);
166 /* Add / update the NODE in the node cache. */
168 svn_fs_x__update_dag_cache(dag_node_t *node);
172 #endif /* __cplusplus */
174 #endif /* SVN_LIBSVN_FS_X_DAG_CACHE_H */