1 /* transaction.h --- transaction-related functions of FSX
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_TRANSACTION_H
24 #define SVN_LIBSVN_FS_X_TRANSACTION_H
28 /* Return the transaction ID of TXN.
31 svn_fs_x__txn_get_id(svn_fs_txn_t *txn);
33 /* Obtain a write lock on the filesystem FS in a subpool of SCRATCH_POOL,
34 call BODY with BATON and that subpool, destroy the subpool (releasing the
35 write lock) and return what BODY returned. */
37 svn_fs_x__with_write_lock(svn_fs_t *fs,
38 svn_error_t *(*body)(void *baton,
39 apr_pool_t *scratch_pool),
41 apr_pool_t *scratch_pool);
43 /* Obtain a pack operation lock on the filesystem FS in a subpool of
44 SCRATCH_POOL, call BODY with BATON and that subpool, destroy the subpool
45 (releasing the write lock) and return what BODY returned. */
47 svn_fs_x__with_pack_lock(svn_fs_t *fs,
48 svn_error_t *(*body)(void *baton,
49 apr_pool_t *scratch_pool),
51 apr_pool_t *scratch_pool);
53 /* Obtain the txn-current file lock on the filesystem FS in a subpool of
54 SCRATCH_POOL, call BODY with BATON and that subpool, destroy the subpool
55 (releasing the write lock) and return what BODY returned. */
57 svn_fs_x__with_txn_current_lock(svn_fs_t *fs,
58 svn_error_t *(*body)(void *baton,
59 apr_pool_t *scratch_pool),
61 apr_pool_t *scratch_pool);
63 /* Obtain all locks on the filesystem FS in a subpool of SCRATCH_POOL,
64 call BODY with BATON and that subpool, destroy the subpool (releasing
65 the locks) and return what BODY returned.
67 This combines svn_fs_x__with_write_lock, svn_fs_x__with_pack_lock,
68 and svn_fs_x__with_txn_current_lock, ensuring correct lock ordering. */
70 svn_fs_x__with_all_locks(svn_fs_t *fs,
71 svn_error_t *(*body)(void *baton,
72 apr_pool_t *scratch_pool),
74 apr_pool_t *scratch_pool);
76 /* Return TRUE, iff NODEREV is the root node of a transaction that has not
77 seen any modifications, yet. */
79 svn_fs_x__is_fresh_txn_root(svn_fs_x__noderev_t *noderev);
81 /* Store NODEREV as the node-revision in the transaction defined by NODEREV's
82 ID within FS. Do any necessary temporary allocation in SCRATCH_POOL. */
84 svn_fs_x__put_node_revision(svn_fs_t *fs,
85 svn_fs_x__noderev_t *noderev,
86 apr_pool_t *scratch_pool);
88 /* Find the paths which were changed in transaction TXN_ID of
89 filesystem FS and store them in *CHANGED_PATHS_P.
90 Get any temporary allocations from SCRATCH_POOL. */
92 svn_fs_x__txn_changes_fetch(apr_hash_t **changed_paths_p,
94 svn_fs_x__txn_id_t txn_id,
95 apr_pool_t *scratch_pool);
97 /* Set the transaction property NAME to the value VALUE in transaction
98 TXN. Perform temporary allocations from SCRATCH_POOL. */
100 svn_fs_x__change_txn_prop(svn_fs_txn_t *txn,
102 const svn_string_t *value,
103 apr_pool_t *scratch_pool);
105 /* Change transaction properties in transaction TXN based on PROPS.
106 Perform temporary allocations from SCRATCH_POOL. */
108 svn_fs_x__change_txn_props(svn_fs_txn_t *txn,
109 const apr_array_header_t *props,
110 apr_pool_t *scratch_pool);
112 /* Store a transaction record in *TXN_P for the transaction identified
113 by TXN_ID in filesystem FS. Allocate everything from POOL. */
115 svn_fs_x__get_txn(svn_fs_x__transaction_t **txn_p,
117 svn_fs_x__txn_id_t txn_id,
120 /* Return the next available copy_id in *COPY_ID for the transaction
121 TXN_ID in filesystem FS. Allocate temporaries in SCRATCH_POOL. */
123 svn_fs_x__reserve_copy_id(svn_fs_x__id_t *copy_id_p,
125 svn_fs_x__txn_id_t txn_id,
126 apr_pool_t *scratch_pool);
128 /* Create an entirely new mutable node in the filesystem FS, whose
129 node-revision is NODEREV. COPY_ID is the copy_id to use in the
130 node revision ID. TXN_ID is the Subversion transaction under
131 which this occurs. Use SCRATCH_POOL for temporary allocations. */
133 svn_fs_x__create_node(svn_fs_t *fs,
134 svn_fs_x__noderev_t *noderev,
135 const svn_fs_x__id_t *copy_id,
136 svn_fs_x__txn_id_t txn_id,
137 apr_pool_t *scratch_pool);
139 /* Remove all references to the transaction TXN_ID from filesystem FS.
140 Temporary allocations are from SCRATCH_POOL. */
142 svn_fs_x__purge_txn(svn_fs_t *fs,
144 apr_pool_t *scratch_pool);
146 /* Abort the existing transaction TXN, performing any temporary
147 allocations in SCRATCH_POOL. */
149 svn_fs_x__abort_txn(svn_fs_txn_t *txn,
150 apr_pool_t *scratch_pool);
152 /* Add or set in filesystem FS, transaction TXN_ID, in directory
153 PARENT_NODEREV a directory entry for NAME pointing to ID of type
154 KIND. The PARENT_NODEREV's DATA_REP will be redirected to the in-txn
155 representation, if it had not been mutable before.
157 If PARENT_NODEREV does not have a DATA_REP, allocate one in RESULT_POOL.
158 Temporary allocations are done in SCRATCH_POOL. */
160 svn_fs_x__set_entry(svn_fs_t *fs,
161 svn_fs_x__txn_id_t txn_id,
162 svn_fs_x__noderev_t *parent_noderev,
164 const svn_fs_x__id_t *id,
165 svn_node_kind_t kind,
166 apr_pool_t *result_pool,
167 apr_pool_t *scratch_pool);
169 /* Add a change to the changes record for filesystem FS in transaction
170 TXN_ID. Mark path PATH as changed according to the type in
171 CHANGE_KIND. If the text representation was changed set TEXT_MOD
172 to TRUE, and likewise for PROP_MOD as well as MERGEINFO_MOD.
173 If this change was the result of a copy, set COPYFROM_REV and
174 COPYFROM_PATH to the revision and path of the copy source, otherwise
175 they should be set to SVN_INVALID_REVNUM and NULL. Perform any
176 temporary allocations from SCRATCH_POOL. */
178 svn_fs_x__add_change(svn_fs_t *fs,
179 svn_fs_x__txn_id_t txn_id,
181 svn_fs_path_change_kind_t change_kind,
182 svn_boolean_t text_mod,
183 svn_boolean_t prop_mod,
184 svn_boolean_t mergeinfo_mod,
185 svn_node_kind_t node_kind,
186 svn_revnum_t copyfrom_rev,
187 const char *copyfrom_path,
188 apr_pool_t *scratch_pool);
190 /* Return a writable stream in *STREAM, allocated in RESULT_POOL, that
191 allows storing the text representation of node-revision NODEREV in
194 svn_fs_x__set_contents(svn_stream_t **stream,
196 svn_fs_x__noderev_t *noderev,
197 apr_pool_t *result_pool);
199 /* Create a node revision in FS which is an immediate successor of
200 NEW_NODEREV's predecessor. Use SCRATCH_POOL for any temporary allocation.
202 COPY_ID, is a key into the `copies' table, and
203 indicates that this new node is being created as the result of a
204 copy operation, and specifically which operation that was.
206 TXN_ID is the Subversion transaction under which this occurs.
208 After this call, the deltification code assumes that the new node's
209 contents will change frequently, and will avoid representing other
210 nodes as deltas against this node's contents. */
212 svn_fs_x__create_successor(svn_fs_t *fs,
213 svn_fs_x__noderev_t *new_noderev,
214 const svn_fs_x__id_t *copy_id,
215 svn_fs_x__txn_id_t txn_id,
216 apr_pool_t *scratch_pool);
218 /* Write a new property list PROPLIST for node-revision NODEREV in
219 filesystem FS. Perform any temporary allocations in SCRATCH_POOL. */
221 svn_fs_x__set_proplist(svn_fs_t *fs,
222 svn_fs_x__noderev_t *noderev,
223 apr_hash_t *proplist,
224 apr_pool_t *scratch_pool);
226 /* Append the L2P and P2L indexes given by their proto index file names
227 * L2P_PROTO_INDEX and P2L_PROTO_INDEX to the revision / pack FILE.
228 * The latter contains revision(s) starting at REVISION in FS.
229 * Use SCRATCH_POOL for temporary allocations. */
231 svn_fs_x__add_index_data(svn_fs_t *fs,
233 const char *l2p_proto_index,
234 const char *p2l_proto_index,
235 svn_revnum_t revision,
236 apr_pool_t *scratch_pool);
238 /* Commit the transaction TXN in filesystem FS and return its new
239 revision number in *REV. If the transaction is out of date, return
240 the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use SCRATCH_POOL for temporary
243 svn_fs_x__commit(svn_revnum_t *new_rev_p,
246 apr_pool_t *scratch_pool);
248 /* Set *NAMES_P to an array of names which are all the active
249 transactions in filesystem FS. Allocate the array from POOL. */
251 svn_fs_x__list_transactions(apr_array_header_t **names_p,
255 /* Open the transaction named NAME in filesystem FS. Set *TXN_P to
256 * the transaction. If there is no such transaction, return
257 ` * SVN_ERR_FS_NO_SUCH_TRANSACTION. Allocate the new transaction in
260 svn_fs_x__open_txn(svn_fs_txn_t **txn_p,
265 /* Return the property list from transaction TXN and store it in
266 *PROPLIST. Allocate the property list from POOL. */
268 svn_fs_x__txn_proplist(apr_hash_t **table_p,
272 /* Delete the mutable node-revision referenced by ID, along with any
273 mutable props or directory contents associated with it. Perform
274 temporary allocations in SCRATCH_POOL. */
276 svn_fs_x__delete_node_revision(svn_fs_t *fs,
277 const svn_fs_x__id_t *id,
278 apr_pool_t *scratch_pool);
280 /* Retrieve information about the Subversion transaction TXN_ID from
281 the `transactions' table of FS, using SCRATCH_POOL for temporary
282 allocations. Set *RENUM to the transaction's base revision.
284 If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
287 Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
288 transaction that has already been committed. */
290 svn_fs_x__get_base_rev(svn_revnum_t *revnum,
292 svn_fs_x__txn_id_t txn_id,
293 apr_pool_t *scratch_pool);
295 /* Find the value of the property named PROPNAME in transaction TXN.
296 Return the contents in *VALUE_P. The contents will be allocated
299 svn_fs_x__txn_prop(svn_string_t **value_p,
301 const char *propname,
304 /* Begin a new transaction in filesystem FS, based on existing
305 revision REV. The new transaction is returned in *TXN_P, allocated
306 in RESULT_POOL. Allocate temporaries from SCRATCH_POOL. */
308 svn_fs_x__begin_txn(svn_fs_txn_t **txn_p,
312 apr_pool_t *result_pool,
313 apr_pool_t *scratch_pool);