]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/subversion/libsvn_fs_x/transaction.h
MFC r275385 (by bapt):
[FreeBSD/stable/10.git] / contrib / subversion / subversion / libsvn_fs_x / transaction.h
1 /* transaction.h --- transaction-related functions of FSX
2  *
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  *    under the License.
20  * ====================================================================
21  */
22
23 #ifndef SVN_LIBSVN_FS__TRANSACTION_H
24 #define SVN_LIBSVN_FS__TRANSACTION_H
25
26 #include "fs.h"
27
28 /* Return the transaction ID of TXN.
29  */
30 svn_fs_x__txn_id_t
31 svn_fs_x__txn_get_id(svn_fs_txn_t *txn);
32
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. */
36 svn_error_t *
37 svn_fs_x__with_write_lock(svn_fs_t *fs,
38                           svn_error_t *(*body)(void *baton,
39                                                apr_pool_t *scratch_pool),
40                           void *baton,
41                           apr_pool_t *scratch_pool);
42
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. */
46 svn_error_t *
47 svn_fs_x__with_pack_lock(svn_fs_t *fs,
48                          svn_error_t *(*body)(void *baton,
49                                               apr_pool_t *scratch_pool),
50                          void *baton,
51                          apr_pool_t *scratch_pool);
52
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. */
56 svn_error_t *
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),
60                                 void *baton,
61                                 apr_pool_t *scratch_pool);
62
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.
66
67    This combines svn_fs_fs__with_write_lock, svn_fs_fs__with_pack_lock,
68    and svn_fs_fs__with_txn_current_lock, ensuring correct lock ordering. */
69 svn_error_t *
70 svn_fs_x__with_all_locks(svn_fs_t *fs,
71                          svn_error_t *(*body)(void *baton,
72                                               apr_pool_t *scratch_pool),
73                          void *baton,
74                          apr_pool_t *scratch_pool);
75
76 /* Return TRUE, iff NODEREV is the root node of a transaction that has not
77    seen any modifications, yet. */
78 svn_boolean_t
79 svn_fs_x__is_fresh_txn_root(svn_fs_x__noderev_t *noderev);
80
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. */
83 svn_error_t *
84 svn_fs_x__put_node_revision(svn_fs_t *fs,
85                             svn_fs_x__noderev_t *noderev,
86                             apr_pool_t *scratch_pool);
87
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. */
91 svn_error_t *
92 svn_fs_x__txn_changes_fetch(apr_hash_t **changed_paths_p,
93                             svn_fs_t *fs,
94                             svn_fs_x__txn_id_t txn_id,
95                             apr_pool_t *scratch_pool);
96
97 /* Set the transaction property NAME to the value VALUE in transaction
98    TXN.  Perform temporary allocations from SCRATCH_POOL. */
99 svn_error_t *
100 svn_fs_x__change_txn_prop(svn_fs_txn_t *txn,
101                           const char *name,
102                           const svn_string_t *value,
103                           apr_pool_t *scratch_pool);
104
105 /* Change transaction properties in transaction TXN based on PROPS.
106    Perform temporary allocations from SCRATCH_POOL. */
107 svn_error_t *
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);
111
112 /* Store a transaction record in *TXN_P for the transaction identified
113    by TXN_ID in filesystem FS.  Allocate everything from POOL. */
114 svn_error_t *
115 svn_fs_x__get_txn(svn_fs_x__transaction_t **txn_p,
116                   svn_fs_t *fs,
117                   svn_fs_x__txn_id_t txn_id,
118                   apr_pool_t *pool);
119
120 /* Return the next available copy_id in *COPY_ID for the transaction
121    TXN_ID in filesystem FS.  Allocate temporaries in SCRATCH_POOL. */
122 svn_error_t *
123 svn_fs_x__reserve_copy_id(svn_fs_x__id_t *copy_id_p,
124                           svn_fs_t *fs,
125                           svn_fs_x__txn_id_t txn_id,
126                           apr_pool_t *scratch_pool);
127
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. */
132 svn_error_t *
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);
138
139 /* Remove all references to the transaction TXN_ID from filesystem FS.
140    Temporary allocations are from SCRATCH_POOL. */
141 svn_error_t *
142 svn_fs_x__purge_txn(svn_fs_t *fs,
143                     const char *txn_id,
144                     apr_pool_t *scratch_pool);
145
146 /* Abort the existing transaction TXN, performing any temporary
147    allocations in SCRATCH_POOL. */
148 svn_error_t *
149 svn_fs_x__abort_txn(svn_fs_txn_t *txn,
150                     apr_pool_t *scratch_pool);
151
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.
156
157    If PARENT_NODEREV does not have a DATA_REP, allocate one in RESULT_POOL.
158    Temporary allocations are done in SCRATCH_POOL. */
159 svn_error_t *
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,
163                     const char *name,
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);
168
169 /* Add a change to the changes record for filesystem FS in transaction
170    TXN_ID.  Mark path PATH, having noderev-id ID, as changed according to
171    the type in CHANGE_KIND.  If the text representation was changed set
172    TEXT_MOD 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. */
177 svn_error_t *
178 svn_fs_x__add_change(svn_fs_t *fs,
179                      svn_fs_x__txn_id_t txn_id,
180                      const char *path,
181                      const svn_fs_x__id_t *id,
182                      svn_fs_path_change_kind_t change_kind,
183                      svn_boolean_t text_mod,
184                      svn_boolean_t prop_mod,
185                      svn_boolean_t mergeinfo_mod,
186                      svn_node_kind_t node_kind,
187                      svn_revnum_t copyfrom_rev,
188                      const char *copyfrom_path,
189                      apr_pool_t *scratch_pool);
190
191 /* Return a writable stream in *STREAM, allocated in RESULT_POOL, that
192    allows storing the text representation of node-revision NODEREV in
193    filesystem FS. */
194 svn_error_t *
195 svn_fs_x__set_contents(svn_stream_t **stream,
196                        svn_fs_t *fs,
197                        svn_fs_x__noderev_t *noderev,
198                        apr_pool_t *result_pool);
199
200 /* Create a node revision in FS which is an immediate successor of
201    NEW_NODEREV's predecessor.  Use SCRATCH_POOL for any temporary allocation.
202
203    COPY_ID, is a key into the `copies' table, and
204    indicates that this new node is being created as the result of a
205    copy operation, and specifically which operation that was.
206
207    TXN_ID is the Subversion transaction under which this occurs.
208
209    After this call, the deltification code assumes that the new node's
210    contents will change frequently, and will avoid representing other
211    nodes as deltas against this node's contents.  */
212 svn_error_t *
213 svn_fs_x__create_successor(svn_fs_t *fs,
214                            svn_fs_x__noderev_t *new_noderev,
215                            const svn_fs_x__id_t *copy_id,
216                            svn_fs_x__txn_id_t txn_id,
217                            apr_pool_t *scratch_pool);
218
219 /* Write a new property list PROPLIST for node-revision NODEREV in
220    filesystem FS.  Perform any temporary allocations in SCRATCH_POOL. */
221 svn_error_t *
222 svn_fs_x__set_proplist(svn_fs_t *fs,
223                        svn_fs_x__noderev_t *noderev,
224                        apr_hash_t *proplist,
225                        apr_pool_t *scratch_pool);
226
227 /* Append the L2P and P2L indexes given by their proto index file names
228  * L2P_PROTO_INDEX and P2L_PROTO_INDEX to the revision / pack FILE.
229  * The latter contains revision(s) starting at REVISION in FS.
230  * Use SCRATCH_POOL for temporary allocations.  */
231 svn_error_t *
232 svn_fs_x__add_index_data(svn_fs_t *fs,
233                          apr_file_t *file,
234                          const char *l2p_proto_index,
235                          const char *p2l_proto_index,
236                          svn_revnum_t revision,
237                          apr_pool_t *scratch_pool);
238
239 /* Commit the transaction TXN in filesystem FS and return its new
240    revision number in *REV.  If the transaction is out of date, return
241    the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use SCRATCH_POOL for temporary
242    allocations. */
243 svn_error_t *
244 svn_fs_x__commit(svn_revnum_t *new_rev_p,
245                  svn_fs_t *fs,
246                  svn_fs_txn_t *txn,
247                  apr_pool_t *scratch_pool);
248
249 /* Set *NAMES_P to an array of names which are all the active
250    transactions in filesystem FS.  Allocate the array from POOL. */
251 svn_error_t *
252 svn_fs_x__list_transactions(apr_array_header_t **names_p,
253                             svn_fs_t *fs,
254                             apr_pool_t *pool);
255
256 /* Open the transaction named NAME in filesystem FS.  Set *TXN_P to
257  * the transaction. If there is no such transaction, return
258 ` * SVN_ERR_FS_NO_SUCH_TRANSACTION.  Allocate the new transaction in
259  * POOL. */
260 svn_error_t *
261 svn_fs_x__open_txn(svn_fs_txn_t **txn_p,
262                    svn_fs_t *fs,
263                    const char *name,
264                    apr_pool_t *pool);
265
266 /* Return the property list from transaction TXN and store it in
267    *PROPLIST.  Allocate the property list from POOL. */
268 svn_error_t *
269 svn_fs_x__txn_proplist(apr_hash_t **table_p,
270                        svn_fs_txn_t *txn,
271                        apr_pool_t *pool);
272
273 /* Delete the mutable node-revision referenced by ID, along with any
274    mutable props or directory contents associated with it.  Perform
275    temporary allocations in SCRATCH_POOL. */
276 svn_error_t *
277 svn_fs_x__delete_node_revision(svn_fs_t *fs,
278                                const svn_fs_x__id_t *id,
279                                apr_pool_t *scratch_pool);
280
281 /* Retrieve information about the Subversion transaction TXN_ID from
282    the `transactions' table of FS, using SCRATCH_POOL for temporary
283    allocations.  Set *RENUM to the transaction's base revision.
284
285    If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
286    the error returned.
287
288    Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
289    transaction that has already been committed.  */
290 svn_error_t *
291 svn_fs_x__get_base_rev(svn_revnum_t *revnum,
292                        svn_fs_t *fs,
293                        svn_fs_x__txn_id_t txn_id,
294                        apr_pool_t *scratch_pool);
295
296 /* Find the value of the property named PROPNAME in transaction TXN.
297    Return the contents in *VALUE_P.  The contents will be allocated
298    from POOL. */
299 svn_error_t *
300 svn_fs_x__txn_prop(svn_string_t **value_p,
301                    svn_fs_txn_t *txn,
302                    const char *propname,
303                    apr_pool_t *pool);
304
305 /* Begin a new transaction in filesystem FS, based on existing
306    revision REV.  The new transaction is returned in *TXN_P, allocated
307    in RESULT_POOL.  Allocate temporaries from SCRATCH_POOL. */
308 svn_error_t *
309 svn_fs_x__begin_txn(svn_fs_txn_t **txn_p,
310                     svn_fs_t *fs,
311                     svn_revnum_t rev,
312                     apr_uint32_t flags,
313                     apr_pool_t *result_pool,
314                     apr_pool_t *scratch_pool);
315
316 #endif