1/* revs-txns.h : internal interface to revision and transactions operations
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_REVS_TXNS_H
24#define SVN_LIBSVN_FS_REVS_TXNS_H
25
26#define SVN_WANT_BDB
27#include "svn_private_config.h"
28
29#include "svn_fs.h"
30
31#include "fs.h"
32#include "trail.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif /* __cplusplus */
37
38
39
40/*** Revisions ***/
41
42/* Set *ROOT_ID_P to the ID of the root directory of revision REV in FS,
43   as part of TRAIL.  Allocate the ID in POOL.  */
44svn_error_t *svn_fs_base__rev_get_root(const svn_fs_id_t **root_id_p,
45                                       svn_fs_t *fs,
46                                       svn_revnum_t rev,
47                                       trail_t *trail,
48                                       apr_pool_t *pool);
49
50
51/* Set *TXN_ID_P to the ID of the transaction that was committed to
52   create REV in FS, as part of TRAIL.  Allocate the ID in POOL.  */
53svn_error_t *svn_fs_base__rev_get_txn_id(const char **txn_id_p,
54                                         svn_fs_t *fs,
55                                         svn_revnum_t rev,
56                                         trail_t *trail,
57                                         apr_pool_t *pool);
58
59
60/* Set property NAME to VALUE on REV in FS, as part of TRAIL.  */
61svn_error_t *svn_fs_base__set_rev_prop(svn_fs_t *fs,
62                                       svn_revnum_t rev,
63                                       const char *name,
64                                       const svn_string_t *const *old_value_p,
65                                       const svn_string_t *value,
66                                       trail_t *trail,
67                                       apr_pool_t *pool);
68
69
70
71/*** Transactions ***/
72
73/* Convert the unfinished transaction in FS named TXN_NAME to a
74   committed transaction that refers to REVISION as part of TRAIL.
75
76   Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
77   transaction that has already been committed.  */
78svn_error_t *svn_fs_base__txn_make_committed(svn_fs_t *fs,
79                                             const char *txn_name,
80                                             svn_revnum_t revision,
81                                             trail_t *trail,
82                                             apr_pool_t *pool);
83
84
85/* Set *REVISION to the revision which was created when FS transaction
86   TXN_NAME was committed, or to SVN_INVALID_REVNUM if the transaction
87   has not been committed.  Do all of this as part of TRAIL.  */
88svn_error_t *svn_fs_base__txn_get_revision(svn_revnum_t *revision,
89                                           svn_fs_t *fs,
90                                           const char *txn_name,
91                                           trail_t *trail,
92                                           apr_pool_t *pool);
93
94
95/* Retrieve information about the Subversion transaction TXN_NAME from
96   the `transactions' table of FS, as part of TRAIL.
97   Set *ROOT_ID_P to the ID of the transaction's root directory.
98   Set *BASE_ROOT_ID_P to the ID of the root directory of the
99   transaction's base revision.
100
101   If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
102   the error returned.
103
104   Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
105   transaction that has already been committed.
106
107   Allocate *ROOT_ID_P and *BASE_ROOT_ID_P in POOL.  */
108svn_error_t *svn_fs_base__get_txn_ids(const svn_fs_id_t **root_id_p,
109                                      const svn_fs_id_t **base_root_id_p,
110                                      svn_fs_t *fs,
111                                      const char *txn_name,
112                                      trail_t *trail,
113                                      apr_pool_t *pool);
114
115
116/* Set the root directory of the Subversion transaction TXN_NAME in FS
117   to ROOT_ID, as part of TRAIL.  Do any necessary temporary
118   allocation in POOL.
119
120   Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
121   transaction that has already been committed.  */
122svn_error_t *svn_fs_base__set_txn_root(svn_fs_t *fs,
123                                       const char *txn_name,
124                                       const svn_fs_id_t *root_id,
125                                       trail_t *trail,
126                                       apr_pool_t *pool);
127
128
129/* Add COPY_ID to the list of copies made under the Subversion
130   transaction TXN_NAME in FS as part of TRAIL.
131
132   Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
133   transaction that has already been committed.  */
134svn_error_t *svn_fs_base__add_txn_copy(svn_fs_t *fs,
135                                       const char *txn_name,
136                                       const char *copy_id,
137                                       trail_t *trail,
138                                       apr_pool_t *pool);
139
140
141/* Set the base root directory of TXN_NAME in FS to NEW_ID, as part of
142   TRAIL.  Do any necessary temporary allocation in POOL.
143
144   Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
145   transaction that has already been committed.  */
146svn_error_t *svn_fs_base__set_txn_base(svn_fs_t *fs,
147                                       const char *txn_name,
148                                       const svn_fs_id_t *new_id,
149                                       trail_t *trail,
150                                       apr_pool_t *pool);
151
152
153/* Set a property NAME to VALUE on transaction TXN_NAME in FS as part
154   of TRAIL.  Use POOL for any necessary allocations.
155
156   Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
157   transaction that has already been committed.  */
158svn_error_t *svn_fs_base__set_txn_prop(svn_fs_t *fs,
159                                       const char *txn_name,
160                                       const char *name,
161                                       const svn_string_t *value,
162                                       trail_t *trail,
163                                       apr_pool_t *pool);
164
165
166/* These functions implement some of the calls in the FS loader
167   library's fs and txn vtables. */
168
169svn_error_t *svn_fs_base__youngest_rev(svn_revnum_t *youngest_p, svn_fs_t *fs,
170                                       apr_pool_t *pool);
171
172svn_error_t *svn_fs_base__revision_prop(svn_string_t **value_p, svn_fs_t *fs,
173                                        svn_revnum_t rev,
174                                        const char *propname,
175                                        svn_boolean_t refresh,
176                                        apr_pool_t *result_pool,
177                                        apr_pool_t *scratch_pool);
178
179svn_error_t *svn_fs_base__revision_proplist(apr_hash_t **table_p,
180                                            svn_fs_t *fs,
181                                            svn_revnum_t rev,
182                                            svn_boolean_t refresh,
183                                            apr_pool_t *result_pool,
184                                            apr_pool_t *scratch_pool);
185
186svn_error_t *svn_fs_base__change_rev_prop(svn_fs_t *fs, svn_revnum_t rev,
187                                          const char *name,
188                                          const svn_string_t *const *old_value_p,
189                                          const svn_string_t *value,
190                                          apr_pool_t *pool);
191
192svn_error_t *svn_fs_base__begin_txn(svn_fs_txn_t **txn_p, svn_fs_t *fs,
193                                    svn_revnum_t rev, apr_uint32_t flags,
194                                    apr_pool_t *pool);
195
196svn_error_t *svn_fs_base__open_txn(svn_fs_txn_t **txn, svn_fs_t *fs,
197                                   const char *name, apr_pool_t *pool);
198
199svn_error_t *svn_fs_base__purge_txn(svn_fs_t *fs, const char *txn_id,
200                                    apr_pool_t *pool);
201
202svn_error_t *svn_fs_base__list_transactions(apr_array_header_t **names_p,
203                                            svn_fs_t *fs, apr_pool_t *pool);
204
205svn_error_t *svn_fs_base__abort_txn(svn_fs_txn_t *txn, apr_pool_t *pool);
206
207svn_error_t *svn_fs_base__txn_prop(svn_string_t **value_p, svn_fs_txn_t *txn,
208                                   const char *propname, apr_pool_t *pool);
209
210svn_error_t *svn_fs_base__txn_proplist(apr_hash_t **table_p,
211                                       svn_fs_txn_t *txn,
212                                       apr_pool_t *pool);
213
214/* Helper func:  variant of __txn_proplist that uses an existing TRAIL.
215 * TXN_ID identifies the transaction.
216 * *TABLE_P will be non-null upon success.
217 */
218svn_error_t *svn_fs_base__txn_proplist_in_trail(apr_hash_t **table_p,
219                                                const char *txn_id,
220                                                trail_t *trail);
221
222svn_error_t *svn_fs_base__change_txn_prop(svn_fs_txn_t *txn, const char *name,
223                                          const svn_string_t *value,
224                                          apr_pool_t *pool);
225
226svn_error_t *svn_fs_base__change_txn_props(svn_fs_txn_t *txn,
227                                           const apr_array_header_t *props,
228                                           apr_pool_t *pool);
229
230
231#ifdef __cplusplus
232}
233#endif /* __cplusplus */
234
235#endif /* SVN_LIBSVN_FS_REVS_TXNS_H */
236