In the command-line client, forbid
[svn.git] / subversion / libsvn_fs_fs / fs_fs.h
blob68161ed0584306455d51eff2e32900c1dd60dc13
1 /* fs_fs.h : interface to the native filesystem layer
3 * ====================================================================
4 * Copyright (c) 2000-2007 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
18 #ifndef SVN_LIBSVN_FS__FS_FS_H
19 #define SVN_LIBSVN_FS__FS_FS_H
21 #include "fs.h"
23 /* Open the fsfs filesystem pointed to by PATH and associate it with
24 filesystem object FS. Use POOL for temporary allocations. */
25 svn_error_t *svn_fs_fs__open(svn_fs_t *fs,
26 const char *path,
27 apr_pool_t *pool);
29 /* Copy the fsfs filesystem at SRC_PATH into a new copy at DST_PATH.
30 Use POOL for temporary allocations. */
31 svn_error_t *svn_fs_fs__hotcopy(const char *src_path,
32 const char *dst_path,
33 apr_pool_t *pool);
35 /* Recover the fsfs associated with filesystem FS.
36 Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support.
37 Use POOL for temporary allocations. */
38 svn_error_t *svn_fs_fs__recover(svn_fs_t *fs,
39 svn_cancel_func_t cancel_func,
40 void *cancel_baton,
41 apr_pool_t *pool);
43 /* Set *NODEREV_P to the node-revision for the node ID in FS. Do any
44 allocations in POOL. */
45 svn_error_t *svn_fs_fs__get_node_revision(node_revision_t **noderev_p,
46 svn_fs_t *fs,
47 const svn_fs_id_t *id,
48 apr_pool_t *pool);
50 /* Store NODEREV as the node-revision for the node whose id is ID in
51 FS, after setting its is_fresh_txn_root to FRESH_TXN_ROOT. Do any
52 necessary temporary allocation in POOL. */
53 svn_error_t *svn_fs_fs__put_node_revision(svn_fs_t *fs,
54 const svn_fs_id_t *id,
55 node_revision_t *noderev,
56 svn_boolean_t fresh_txn_root,
57 apr_pool_t *pool);
59 /* Set *YOUNGEST to the youngest revision in filesystem FS. Do any
60 temporary allocation in POOL. */
61 svn_error_t *svn_fs_fs__youngest_rev(svn_revnum_t *youngest,
62 svn_fs_t *fs,
63 apr_pool_t *pool);
65 /* Set *ROOT_ID to the node-id for the root of revision REV in
66 filesystem FS. Do any allocations in POOL. */
67 svn_error_t *svn_fs_fs__rev_get_root(svn_fs_id_t **root_id,
68 svn_fs_t *fs,
69 svn_revnum_t rev,
70 apr_pool_t *pool);
72 /* Set *ENTRIES to an apr_hash_t of dirent structs that contain the
73 directory entries of node-revision NODEREV in filesystem FS. Use
74 POOL for temporary allocations. The returned hash does *not* live
75 in POOL, and becomes invalid on the next call to this function. If
76 you need it to live longer, copy it with
77 svn_fs_fs__copy_dir_entries. */
78 svn_error_t *svn_fs_fs__rep_contents_dir(apr_hash_t **entries,
79 svn_fs_t *fs,
80 node_revision_t *noderev,
81 apr_pool_t *pool);
83 /* Return a copy of the directory hash ENTRIES in POOL. Use this to
84 copy the result of svn_fs_fs__rep_contents_dir into a predictable
85 place so that doesn't become invalid before it's no longer
86 needed. */
87 apr_hash_t *svn_fs_fs__copy_dir_entries(apr_hash_t *entries,
88 apr_pool_t *pool);
90 /* Set *CONTENTS to be a readable svn_stream_t that receives the text
91 representation of node-revision NODEREV as seen in filesystem FS.
92 Use POOL for temporary allocations. */
93 svn_error_t *svn_fs_fs__get_contents(svn_stream_t **contents,
94 svn_fs_t *fs,
95 node_revision_t *noderev,
96 apr_pool_t *pool);
98 /* Set *STREAM_P to a delta stream turning the contents of the file SOURCE into
99 the contents of the file TARGET, allocated in POOL.
100 If SOURCE is null, the empty string will be used. */
101 svn_error_t *svn_fs_fs__get_file_delta_stream(svn_txdelta_stream_t **stream_p,
102 svn_fs_t *fs,
103 node_revision_t *source,
104 node_revision_t *target,
105 apr_pool_t *pool);
107 /* Set *PROPLIST to be an apr_hash_t containing the property list of
108 node-revision NODEREV as seen in filesystem FS. Use POOL for
109 temporary allocations. */
110 svn_error_t *svn_fs_fs__get_proplist(apr_hash_t **proplist,
111 svn_fs_t *fs,
112 node_revision_t *noderev,
113 apr_pool_t *pool);
115 /* Set the revision property list of revision REV in filesystem FS to
116 PROPLIST. Use POOL for temporary allocations. */
117 svn_error_t *svn_fs_fs__set_revision_proplist(svn_fs_t *fs,
118 svn_revnum_t rev,
119 apr_hash_t *proplist,
120 apr_pool_t *pool);
122 /* Set *PROPLIST to be an apr_hash_t containing the property list of
123 revision REV as seen in filesystem FS. Use POOL for temporary
124 allocations. */
125 svn_error_t *svn_fs_fs__revision_proplist(apr_hash_t **proplist,
126 svn_fs_t *fs,
127 svn_revnum_t rev,
128 apr_pool_t *pool);
130 /* Set *LENGTH to the be fulltext length of the node revision
131 specified by NODEREV. Use POOL for temporary allocations. */
132 svn_error_t *svn_fs_fs__file_length(svn_filesize_t *length,
133 node_revision_t *noderev,
134 apr_pool_t *pool);
136 /* Return TRUE if the representation keys in A and B both point to the
137 same representation, else return FALSE. */
138 svn_boolean_t svn_fs_fs__noderev_same_rep_key(representation_t *a,
139 representation_t *b);
142 /* Return a copy of the representation REP allocated from POOL. */
143 representation_t *svn_fs_fs__rep_copy(representation_t *rep,
144 apr_pool_t *pool);
147 /* Return the record MD5 checksum of the text representation of NODREV
148 into DIGEST, allocating from POOL. If no stored checksum is
149 available, put all 0's into DIGEST. */
150 svn_error_t *svn_fs_fs__file_checksum(unsigned char digest[],
151 node_revision_t *noderev,
152 apr_pool_t *pool);
154 /* Find the paths which were changed in revision REV of filesystem FS
155 and store them in *CHANGED_PATHS_P. Cached copyfrom information
156 will be stored in *COPYFROM_CACHE. Get any temporary allocations
157 from POOL. */
158 svn_error_t *svn_fs_fs__paths_changed(apr_hash_t **changed_paths_p,
159 svn_fs_t *fs,
160 svn_revnum_t rev,
161 apr_hash_t *copyfrom_cache,
162 apr_pool_t *pool);
164 /* Create a new transaction in filesystem FS, based on revision REV,
165 and store it in *TXN_P. Allocate all necessary variables from
166 POOL. */
167 svn_error_t *svn_fs_fs__create_txn(svn_fs_txn_t **txn_p,
168 svn_fs_t *fs,
169 svn_revnum_t rev,
170 apr_pool_t *pool);
172 /* Set the transaction property NAME to the value VALUE in transaction
173 TXN. Perform temporary allocations from POOL. */
174 svn_error_t *svn_fs_fs__change_txn_prop(svn_fs_txn_t *txn,
175 const char *name,
176 const svn_string_t *value,
177 apr_pool_t *pool);
179 /* Change transaction properties in transaction TXN based on PROPS.
180 Perform temporary allocations from POOL. */
181 svn_error_t *svn_fs_fs__change_txn_props(svn_fs_txn_t *txn,
182 apr_array_header_t *props,
183 apr_pool_t *pool);
185 /* Set the transaction mergeinfo for NAME to VALUE in transaction TXN.
186 Perform temporary allocations from POOL. */
187 svn_error_t *svn_fs_fs__change_txn_mergeinfo(svn_fs_txn_t *txn,
188 const char *name,
189 const svn_string_t *value,
190 apr_pool_t *pool);
192 /* Store a transaction record in *TXN_P for the transaction identified
193 by TXN_ID in filesystem FS. Allocate everything from POOL. */
194 svn_error_t *svn_fs_fs__get_txn(transaction_t **txn_p,
195 svn_fs_t *fs,
196 const char *txn_id,
197 apr_pool_t *pool);
199 /* Abort the existing transaction TXN, performing any temporary
200 allocations in POOL. */
201 svn_error_t *svn_fs_fs__abort_txn(svn_fs_txn_t *txn, apr_pool_t *pool);
203 /* Create an entirely new mutable node in the filesystem FS, whose
204 node-revision is NODEREV. Set *ID_P to the new node revision's ID.
205 Use POOL for any temporary allocation. COPY_ID is the copy_id to
206 use in the node revision ID. TXN_ID is the Subversion transaction
207 under which this occurs. */
208 svn_error_t *svn_fs_fs__create_node(const svn_fs_id_t **id_p,
209 svn_fs_t *fs,
210 node_revision_t *noderev,
211 const char *copy_id,
212 const char *txn_id,
213 apr_pool_t *pool);
215 /* Remove all references to the transaction TXN_ID from filesystem FS.
216 Temporary allocations are from POOL. */
217 svn_error_t *svn_fs_fs__purge_txn(svn_fs_t *fs,
218 const char *txn_id,
219 apr_pool_t *pool);
221 /* Add or set in filesystem FS, transaction TXN_ID, in directory
222 PARENT_NODEREV a directory entry for NAME pointing to ID of type
223 KIND. Allocations are done in POOL. */
224 svn_error_t *svn_fs_fs__set_entry(svn_fs_t *fs,
225 const char *txn_id,
226 node_revision_t *parent_noderev,
227 const char *name,
228 const svn_fs_id_t *id,
229 svn_node_kind_t kind,
230 apr_pool_t *pool);
232 /* Add a change to the changes record for filesystem FS in transaction
233 TXN_ID. Mark path PATH, having node-id ID, as changed according to
234 the type in CHANGE_KIND. If the text representation was changed
235 set TEXT_MOD to TRUE, and likewise for PROP_MOD. If this change
236 was the result of a copy, set COPYFROM_REV and COPYFROM_PATH to the
237 revision and path of the copy source, otherwise they should be set
238 to SVN_INVALID_REVNUM and NULL. Perform any temporary allocations
239 from POOL. */
240 svn_error_t *svn_fs_fs__add_change(svn_fs_t *fs,
241 const char *txn_id,
242 const char *path,
243 const svn_fs_id_t *id,
244 svn_fs_path_change_kind_t change_kind,
245 svn_boolean_t text_mod,
246 svn_boolean_t prop_mod,
247 svn_revnum_t copyfrom_rev,
248 const char *copyfrom_path,
249 apr_pool_t *pool);
251 /* Return a writable stream in *STREAM that allows storing the text
252 representation of node-revision NODEREV in filesystem FS.
253 Allocations are from POOL. */
254 svn_error_t *svn_fs_fs__set_contents(svn_stream_t **stream,
255 svn_fs_t *fs,
256 node_revision_t *noderev,
257 apr_pool_t *pool);
259 /* Create a node revision in FS which is an immediate successor of
260 OLD_ID, whose contents are NEW_NR. Set *NEW_ID_P to the new node
261 revision's ID. Use POOL for any temporary allocation.
263 COPY_ID, if non-NULL, is a key into the `copies' table, and
264 indicates that this new node is being created as the result of a
265 copy operation, and specifically which operation that was. If
266 COPY_ID is NULL, then re-use the copy ID from the predecessor node.
268 TXN_ID is the Subversion transaction under which this occurs.
270 After this call, the deltification code assumes that the new node's
271 contents will change frequently, and will avoid representing other
272 nodes as deltas against this node's contents. */
273 svn_error_t *svn_fs_fs__create_successor(const svn_fs_id_t **new_id_p,
274 svn_fs_t *fs,
275 const svn_fs_id_t *old_idp,
276 node_revision_t *new_noderev,
277 const char *copy_id,
278 const char *txn_id,
279 apr_pool_t *pool);
281 /* Write a new property list PROPLIST for node-revision NODEREV in
282 filesystem FS. Perform any temporary allocations in POOL. */
283 svn_error_t *svn_fs_fs__set_proplist(svn_fs_t *fs,
284 node_revision_t *noderev,
285 apr_hash_t *proplist,
286 apr_pool_t *pool);
288 /* Commit the transaction TXN in filesystem FS and return its new
289 revision number in *REV. If the transaction is out of date, return
290 the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use POOL for temporary
291 allocations. */
292 svn_error_t *svn_fs_fs__commit(svn_revnum_t *new_rev_p,
293 svn_fs_t *fs,
294 svn_fs_txn_t *txn,
295 apr_pool_t *pool);
297 /* Return the next available copy_id in *COPY_ID for the transaction
298 TXN_ID in filesystem FS. Allocate space in POOL. */
299 svn_error_t *svn_fs_fs__reserve_copy_id(const char **copy_id,
300 svn_fs_t *fs,
301 const char *txn_id,
302 apr_pool_t *pool);
304 /* Create a fs_fs fileysystem referenced by FS at path PATH. Get any
305 temporary allocations from POOL. */
306 svn_error_t *svn_fs_fs__create(svn_fs_t *fs,
307 const char *path,
308 apr_pool_t *pool);
310 /* Store the uuid of the repository FS in *UUID. Allocate space in
311 POOL. */
312 svn_error_t *svn_fs_fs__get_uuid(svn_fs_t *fs,
313 const char **uuid,
314 apr_pool_t *pool);
316 /* Set the uuid of repository FS to UUID, if UUID is not NULL;
317 otherwise, set the uuid of FS to a newly generated UUID. Perform
318 temporary allocations in POOL. */
319 svn_error_t *svn_fs_fs__set_uuid(svn_fs_t *fs,
320 const char *uuid,
321 apr_pool_t *pool);
323 /* Set *NAMES_P to an array of names which are all the active
324 transactions in filesystem FS. Allocate the array from POOL. */
325 svn_error_t *svn_fs_fs__list_transactions(apr_array_header_t **names_p,
326 svn_fs_t *fs,
327 apr_pool_t *pool);
329 /* Open the transaction named NAME in filesystem FS. Set *TXN_P to
330 * the transaction. If there is no such transaction, return
331 ` * SVN_ERR_FS_NO_SUCH_TRANSACTION. Allocate the new transaction in
332 * POOL. */
333 svn_error_t *svn_fs_fs__open_txn(svn_fs_txn_t **txn_p,
334 svn_fs_t *fs,
335 const char *name,
336 apr_pool_t *pool);
338 /* Return the property list from transaction TXN and store it in
339 *PROPLIST. Allocate the property list from POOL. */
340 svn_error_t *svn_fs_fs__txn_proplist(apr_hash_t **proplist,
341 svn_fs_txn_t *txn,
342 apr_pool_t *pool);
344 /* Delete the mutable node-revision referenced by ID, along with any
345 mutable props or directory contents associated with it. Perform
346 temporary allocations in POOL. */
347 svn_error_t *svn_fs_fs__delete_node_revision(svn_fs_t *fs,
348 const svn_fs_id_t *id,
349 apr_pool_t *pool);
352 /* Find the paths which were changed in transaction TXN_ID of
353 filesystem FS and store them in *CHANGED_PATHS_P. Cached copyfrom
354 information will be stored in COPYFROM_CACHE if it is non-NULL.
355 Get any temporary allocations from POOL. */
356 svn_error_t *svn_fs_fs__txn_changes_fetch(apr_hash_t **changes,
357 svn_fs_t *fs,
358 const char *txn_id,
359 apr_hash_t *copyfrom_cache,
360 apr_pool_t *pool);
363 /* Move a file into place from OLD_FILENAME in the transactions
364 directory to its final location NEW_FILENAME in the repository. On
365 Unix, match the permissions of the new file to the permissions of
366 PERMS_REFERENCE. Temporary allocations are from POOL. */
367 svn_error_t *svn_fs_fs__move_into_place(const char *old_filename,
368 const char *new_filename,
369 const char *perms_reference,
370 apr_pool_t *pool);
372 /* Match the perms on FILENAME to the PERMS_REFERENCE file if we're
373 not on a win32 system. On win32, this is a no-op. */
374 svn_error_t *svn_fs_fs__dup_perms(const char *filename,
375 const char *perms_reference,
376 apr_pool_t *pool);
378 /* Return the path to the file containing revision REV in FS.
379 Allocate the new char * from POOL. */
380 const char *svn_fs_fs__path_rev(svn_fs_t *fs,
381 svn_revnum_t rev,
382 apr_pool_t *pool);
384 /* Return the path to the 'current' file in FS.
385 Perform allocation in POOL. */
386 const char *
387 svn_fs_fs__path_current(svn_fs_t *fs, apr_pool_t *pool);
389 /* Obtain a write lock on the filesystem FS in a subpool of POOL, call
390 BODY with BATON and that subpool, destroy the subpool (releasing the write
391 lock) and return what BODY returned. */
392 svn_error_t *
393 svn_fs_fs__with_write_lock(svn_fs_t *fs,
394 svn_error_t *(*body)(void *baton,
395 apr_pool_t *pool),
396 void *baton,
397 apr_pool_t *pool);
399 /* Find the value of the property named PROPNAME in transaction TXN.
400 Return the contents in *VALUE_P. The contents will be allocated
401 from POOL. */
402 svn_error_t *svn_fs_fs__revision_prop(svn_string_t **value_p, svn_fs_t *fs,
403 svn_revnum_t rev,
404 const char *propname,
405 apr_pool_t *pool);
407 /* Change, add, or delete a property on a revision REV in filesystem
408 FS. NAME gives the name of the property, and value, if non-NULL,
409 gives the new contents of the property. If value is NULL, then the
410 property will be deleted. Do any temporary allocation in POOL. */
411 svn_error_t *svn_fs_fs__change_rev_prop(svn_fs_t *fs, svn_revnum_t rev,
412 const char *name,
413 const svn_string_t *value,
414 apr_pool_t *pool);
416 /* Retrieve information about the Subversion transaction SVN_TXN from
417 the `transactions' table of FS, allocating from POOL. Set
418 *ROOT_ID_P to the ID of the transaction's root directory. Set
419 *BASE_ROOT_ID_P to the ID of the root directory of the
420 transaction's base revision.
422 If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
423 the error returned.
425 Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
426 transaction that has already been committed.
428 Allocate *ROOT_ID_P and *BASE_ROOT_ID_P in POOL. */
429 svn_error_t *svn_fs_fs__get_txn_ids(const svn_fs_id_t **root_id_p,
430 const svn_fs_id_t **base_root_id_p,
431 svn_fs_t *fs,
432 const char *txn_name,
433 apr_pool_t *pool);
435 /* Begin a new transaction in filesystem FS, based on existing
436 revision REV. The new transaction is returned in *TXN_P. Allocate
437 the new transaction structure from POOL. */
438 svn_error_t *svn_fs_fs__begin_txn(svn_fs_txn_t **txn_p, svn_fs_t *fs,
439 svn_revnum_t rev, apr_uint32_t flags,
440 apr_pool_t *pool);
442 /* Find the value of the property named PROPNAME in transaction TXN.
443 Return the contents in *VALUE_P. The contents will be allocated
444 from POOL. */
445 svn_error_t *svn_fs_fs__txn_prop(svn_string_t **value_p, svn_fs_txn_t *txn,
446 const char *propname, apr_pool_t *pool);
449 #endif