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__TRANSACTION_H
24
#define SVN_LIBSVN_FS__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_fs__with_write_lock, svn_fs_fs__with_pack_lock,
68
and svn_fs_fs__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. */
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, 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. */
178
svn_fs_x__add_change(svn_fs_t *fs,
179
svn_fs_x__txn_id_t txn_id,
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);
191
/* Return a writable stream in *STREAM, allocated in RESULT_POOL, that
192
allows storing the text representation of node-revision NODEREV in
195
svn_fs_x__set_contents(svn_stream_t **stream,
197
svn_fs_x__noderev_t *noderev,
198
apr_pool_t *result_pool);
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.
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.
207
TXN_ID is the Subversion transaction under which this occurs.
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. */
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);
219
/* Write a new property list PROPLIST for node-revision NODEREV in
220
filesystem FS. Perform any temporary allocations in SCRATCH_POOL. */
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);
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. */
232
svn_fs_x__add_index_data(svn_fs_t *fs,
234
const char *l2p_proto_index,
235
const char *p2l_proto_index,
236
svn_revnum_t revision,
237
apr_pool_t *scratch_pool);
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
244
svn_fs_x__commit(svn_revnum_t *new_rev_p,
247
apr_pool_t *scratch_pool);
249
/* Set *NAMES_P to an array of names which are all the active
250
transactions in filesystem FS. Allocate the array from POOL. */
252
svn_fs_x__list_transactions(apr_array_header_t **names_p,
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
261
svn_fs_x__open_txn(svn_fs_txn_t **txn_p,
266
/* Return the property list from transaction TXN and store it in
267
*PROPLIST. Allocate the property list from POOL. */
269
svn_fs_x__txn_proplist(apr_hash_t **table_p,
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. */
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);
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.
285
If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
288
Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
289
transaction that has already been committed. */
291
svn_fs_x__get_base_rev(svn_revnum_t *revnum,
293
svn_fs_x__txn_id_t txn_id,
294
apr_pool_t *scratch_pool);
296
/* Find the value of the property named PROPNAME in transaction TXN.
297
Return the contents in *VALUE_P. The contents will be allocated
300
svn_fs_x__txn_prop(svn_string_t **value_p,
302
const char *propname,
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. */
309
svn_fs_x__begin_txn(svn_fs_txn_t **txn_p,
313
apr_pool_t *result_pool,
314
apr_pool_t *scratch_pool);