Change the format of the revprops block sent in svnserve for
[svn.git] / subversion / include / svn_fs.h
blob43638f7ad9ad7a41aa7916c0edc0474f8af87880
1 /**
2 * @copyright
3 * ====================================================================
4 * Copyright (c) 2000-2008 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 * ====================================================================
16 * @endcopyright
18 * @file svn_fs.h
19 * @brief Interface to the Subversion filesystem.
23 #ifndef SVN_FS_H
24 #define SVN_FS_H
26 #include <apr_pools.h>
27 #include <apr_hash.h>
28 #include <apr_tables.h>
29 #include "svn_types.h"
30 #include "svn_error.h"
31 #include "svn_delta.h"
32 #include "svn_io.h"
33 #include "svn_mergeinfo.h"
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
41 /**
42 * Get libsvn_fs version information.
44 * @since New in 1.1.
46 const svn_version_t *svn_fs_version(void);
48 /**
49 * @defgroup fs_handling Filesystem interaction subsystem
50 * @{
53 /* Opening and creating filesystems. */
56 /** An object representing a Subversion filesystem. */
57 typedef struct svn_fs_t svn_fs_t;
60 /**
61 * @name Filesystem configuration options
62 * @{
64 #define SVN_FS_CONFIG_BDB_TXN_NOSYNC "bdb-txn-nosync"
65 #define SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE "bdb-log-autoremove"
67 /* See also svn_fs_type(). */
68 /** @since New in 1.1. */
69 #define SVN_FS_CONFIG_FS_TYPE "fs-type"
70 /** @since New in 1.1. */
71 #define SVN_FS_TYPE_BDB "bdb"
72 /** @since New in 1.1. */
73 #define SVN_FS_TYPE_FSFS "fsfs"
75 /** Create repository format compatible with Subversion versions
76 * earlier than 1.4.
78 * @since New in 1.4.
80 #define SVN_FS_CONFIG_PRE_1_4_COMPATIBLE "pre-1.4-compatible"
82 /** Create repository format compatible with Subversion versions
83 * earlier than 1.5.
85 * @since New in 1.5.
87 #define SVN_FS_CONFIG_PRE_1_5_COMPATIBLE "pre-1.5-compatible"
88 /** @} */
91 /**
92 * Callers should invoke this function to initialize global state in
93 * the FS library before creating FS objects. If this function is
94 * invoked, no FS objects may be created in another thread at the same
95 * time as this invocation, and the provided @a pool must last longer
96 * than any FS object created subsequently.
98 * If this function is not called, the FS library will make a best
99 * effort to bootstrap a mutex for protecting data common to FS
100 * objects; however, there is a small window of failure. Also, a
101 * small amount of data will be leaked if the Subversion FS library is
102 * dynamically unloaded, and using the bdb FS can potentially segfault
103 * or invoke other undefined behavior if this function is not called
104 * with an appropriate pool (such as the pool the module was loaded into)
105 * when loaded dynamically.
107 * If this function is called multiple times before the pool passed to
108 * the first call is destroyed or cleared, the later calls will have
109 * no effect.
111 * @since New in 1.2.
113 svn_error_t *svn_fs_initialize(apr_pool_t *pool);
116 /** The type of a warning callback function. @a baton is the value specified
117 * in the call to svn_fs_set_warning_func(); the filesystem passes it through
118 * to the callback. @a err contains the warning message.
120 * The callback function should not clear the error that is passed to it;
121 * its caller should do that.
123 typedef void (*svn_fs_warning_callback_t)(void *baton, svn_error_t *err);
126 /** Provide a callback function, @a warning, that @a fs should use to
127 * report (non-fatal) errors. To print an error, the filesystem will call
128 * @a warning, passing it @a warning_baton and the error.
130 * By default, this is set to a function that will crash the process.
131 * Dumping to @c stderr or <tt>/dev/tty</tt> is not acceptable default
132 * behavior for server processes, since those may both be equivalent to
133 * <tt>/dev/null</tt>.
135 void
136 svn_fs_set_warning_func(svn_fs_t *fs,
137 svn_fs_warning_callback_t warning,
138 void *warning_baton);
143 * Create a new, empty Subversion filesystem, stored in the directory
144 * @a path, and return a pointer to it in @a *fs_p. @a path must not
145 * currently exist, but its parent must exist. If @a fs_config is not
146 * @c NULL, the options it contains modify the behavior of the
147 * filesystem. The interpretation of @a fs_config is specific to the
148 * filesystem back-end. The new filesystem may be closed by
149 * destroying @a pool.
151 * @note The lifetime of @a fs_config must not be shorter than @a
152 * pool's. It's a good idea to allocate @a fs_config from @a pool or
153 * one of its ancestors.
155 * If @a fs_config contains a value for @c SVN_FS_CONFIG_FS_TYPE, that
156 * value determines the filesystem type for the new filesystem.
157 * Currently defined values are:
159 * SVN_FS_TYPE_BDB Berkeley-DB implementation
160 * SVN_FS_TYPE_FSFS Native-filesystem implementation
162 * If @a fs_config is @c NULL or does not contain a value for
163 * @c SVN_FS_CONFIG_FS_TYPE then the default filesystem type will be used.
164 * This will typically be BDB for version 1.1 and FSFS for later versions,
165 * though the caller should not rely upon any particular default if they
166 * wish to ensure that a filesystem of a specific type is created.
168 * @since New in 1.1.
170 svn_error_t *
171 svn_fs_create(svn_fs_t **fs_p,
172 const char *path,
173 apr_hash_t *fs_config,
174 apr_pool_t *pool);
177 * Open a Subversion filesystem located in the directory @a path, and
178 * return a pointer to it in @a *fs_p. If @a fs_config is not @c
179 * NULL, the options it contains modify the behavior of the
180 * filesystem. The interpretation of @a fs_config is specific to the
181 * filesystem back-end. The opened filesystem may be closed by
182 * destroying @a pool.
184 * @note The lifetime of @a fs_config must not be shorter than @a
185 * pool's. It's a good idea to allocate @a fs_config from @a pool or
186 * one of its ancestors.
188 * Only one thread may operate on any given filesystem object at once.
189 * Two threads may access the same filesystem simultaneously only if
190 * they open separate filesystem objects.
192 * @note You probably don't want to use this directly. Take a look at
193 * svn_repos_open() instead.
195 * @since New in 1.1.
197 svn_error_t *
198 svn_fs_open(svn_fs_t **fs_p,
199 const char *path,
200 apr_hash_t *fs_config,
201 apr_pool_t *pool);
204 * Upgrade the Subversion filesystem located in the directory @a path
205 * to the latest version supported by this library. Return @c
206 * SVN_ERR_FS_UNSUPPORTED_UPGRADE and make no changes to the
207 * filesystem if the requested upgrade is not supported. Use @a pool
208 * for necessary allocations.
210 * @note You probably don't want to use this directly. Take a look at
211 * svn_repos_upgrade() instead.
213 * @since New in 1.5.
215 svn_error_t *
216 svn_fs_upgrade(const char *path,
217 apr_pool_t *pool);
220 * Return, in @a *fs_type, a string identifying the back-end type of
221 * the Subversion filesystem located in @a path. Allocate @a *fs_type
222 * in @a pool.
224 * The string should be equal to one of the @c SVN_FS_TYPE_* defined
225 * constants, unless the filesystem is a new back-end type added in
226 * a later version of Subversion.
228 * In general, the type should make no difference in the filesystem's
229 * semantics, but there are a few situations (such as backups) where
230 * it might matter.
232 * @since New in 1.3.
234 svn_error_t *
235 svn_fs_type(const char **fs_type,
236 const char *path,
237 apr_pool_t *pool);
240 * Return the path to @a fs's repository, allocated in @a pool.
241 * @note This is just what was passed to svn_fs_create() or
242 * svn_fs_open() -- might be absolute, might not.
244 * @since New in 1.1.
246 const char *svn_fs_path(svn_fs_t *fs, apr_pool_t *pool);
249 * Delete the filesystem at @a path.
251 * @since New in 1.1.
253 svn_error_t *svn_fs_delete_fs(const char *path, apr_pool_t *pool);
256 * Copy a possibly live Subversion filesystem from @a src_path to
257 * @a dest_path. If @a clean is @c TRUE, perform cleanup on the
258 * source filesystem as part of the copy operation; currently, this
259 * means deleting copied, unused logfiles for a Berkeley DB source
260 * filesystem.
262 * @since New in 1.1.
264 svn_error_t *
265 svn_fs_hotcopy(const char *src_path,
266 const char *dest_path,
267 svn_boolean_t clean,
268 apr_pool_t *pool);
270 /** Perform any necessary non-catastrophic recovery on the Subversion
271 * filesystem located at @a path.
273 * If @a cancel_func is not @c NULL, it is called periodically with
274 * @a cancel_baton as argument to see if the client wishes to cancel
275 * recovery. BDB filesystems do not currently support cancellation.
277 * Do any necessary allocation within @a pool.
279 * For FSFS filesystems, recovery is currently limited to recreating
280 * the db/current file, and does not require exclusive access.
282 * For BDB filesystems, recovery requires exclusive access, and is
283 * described in detail below.
285 * After an unexpected server exit, due to a server crash or a system
286 * crash, a Subversion filesystem based on Berkeley DB needs to run
287 * recovery procedures to bring the database back into a consistent
288 * state and release any locks that were held by the deceased process.
289 * The recovery procedures require exclusive access to the database
290 * --- while they execute, no other process or thread may access the
291 * database.
293 * In a server with multiple worker processes, like Apache, if a
294 * worker process accessing the filesystem dies, you must stop the
295 * other worker processes, and run recovery. Then, the other worker
296 * processes can re-open the database and resume work.
298 * If the server exited cleanly, there is no need to run recovery, but
299 * there is no harm in it, either, and it take very little time. So
300 * it's a fine idea to run recovery when the server process starts,
301 * before it begins handling any requests.
303 * @since New in 1.5.
305 svn_error_t *
306 svn_fs_recover(const char *path,
307 svn_cancel_func_t cancel_func,
308 void *cancel_baton,
309 apr_pool_t *pool);
312 /** Subversion filesystems based on Berkeley DB.
314 * The following functions are specific to Berkeley DB filesystems.
316 * @defgroup svn_fs_bdb Berkeley DB filesystems
317 * @{
320 /** Register an error handling function for Berkeley DB error messages.
322 * @deprecated Provided for backward compatibility with the 1.2 API.
324 * Despite being first declared deprecated in Subversion 1.3, this API
325 * is redundant in versions 1.1 and 1.2 as well.
327 * Berkeley DB's error codes are seldom sufficiently informative to allow
328 * adequate troubleshooting. Berkeley DB provides extra messages through
329 * a callback function - if an error occurs, the @a handler will be called
330 * with two strings: an error message prefix, which will be zero, and
331 * an error message. @a handler might print it out, log it somewhere,
332 * etc.
334 * Subversion 1.1 and later install their own handler internally, and
335 * wrap the messages from Berkeley DB into the standard svn_error_t object,
336 * making any information gained through this interface redundant.
338 * It is only worth using this function if your program will be used
339 * with Subversion 1.0.
341 * This function connects to the Berkeley DB @c DBENV->set_errcall interface.
342 * Since that interface supports only a single callback, Subversion's internal
343 * callback is registered with Berkeley DB, and will forward notifications to
344 * a user provided callback after performing its own processing.
346 svn_error_t *
347 svn_fs_set_berkeley_errcall(svn_fs_t *fs,
348 void (*handler)(const char *errpfx,
349 char *msg));
351 /** Set @a *logfiles to an array of <tt>const char *</tt> log file names
352 * of Berkeley DB-based Subversion filesystem.
354 * If @a only_unused is @c TRUE, set @a *logfiles to an array which
355 * contains only the names of Berkeley DB log files no longer in use
356 * by the filesystem. Otherwise, all log files (used and unused) are
357 * returned.
359 * This function wraps the Berkeley DB 'log_archive' function
360 * called by the db_archive binary. Repository administrators may
361 * want to run this function periodically and delete the unused log
362 * files, as a way of reclaiming disk space.
364 svn_error_t *
365 svn_fs_berkeley_logfiles(apr_array_header_t **logfiles,
366 const char *path,
367 svn_boolean_t only_unused,
368 apr_pool_t *pool);
372 * The following functions are similar to their generic counterparts.
374 * In Subversion 1.2 and earlier, they only work on Berkeley DB filesystems.
375 * In Subversion 1.3 and later, they perform largely as aliases for their
376 * generic counterparts (with the exception of recover, which only gained
377 * a generic counterpart in 1.5).
379 * @defgroup svn_fs_bdb_deprecated Berkeley DB filesystem compatibility
380 * @{
383 /** @deprecated Provided for backward compatibility with the 1.0 API. */
384 svn_fs_t *svn_fs_new(apr_hash_t *fs_config, apr_pool_t *pool);
386 /** @deprecated Provided for backward compatibility with the 1.0 API. */
387 svn_error_t *svn_fs_create_berkeley(svn_fs_t *fs, const char *path);
389 /** @deprecated Provided for backward compatibility with the 1.0 API. */
390 svn_error_t *svn_fs_open_berkeley(svn_fs_t *fs, const char *path);
392 /** @deprecated Provided for backward compatibility with the 1.0 API. */
393 const char *svn_fs_berkeley_path(svn_fs_t *fs, apr_pool_t *pool);
395 /** @deprecated Provided for backward compatibility with the 1.0 API. */
396 svn_error_t *svn_fs_delete_berkeley(const char *path, apr_pool_t *pool);
398 /** @deprecated Provided for backward compatibility with the 1.0 API. */
399 svn_error_t *
400 svn_fs_hotcopy_berkeley(const char *src_path,
401 const char *dest_path,
402 svn_boolean_t clean_logs,
403 apr_pool_t *pool);
405 /** @deprecated Provided for backward compatibility with the 1.4 API. */
406 svn_error_t *
407 svn_fs_berkeley_recover(const char *path,
408 apr_pool_t *pool);
409 /** @} */
411 /** @} */
414 /** Filesystem Access Contexts.
416 * @since New in 1.2.
418 * At certain times, filesystem functions need access to temporary
419 * user data. For example, which user is changing a file? If the
420 * file is locked, has an appropriate lock-token been supplied?
422 * This temporary user data is stored in an "access context" object,
423 * and the access context is then connected to the filesystem object.
424 * Whenever a filesystem function requires information, it can pull
425 * things out of the context as needed.
427 * @defgroup svn_fs_access_ctx Filesystem access contexts
428 * @{
431 /** An opaque object representing temporary user data. */
432 typedef struct svn_fs_access_t svn_fs_access_t;
435 /** Set @a *access_ctx to a new @c svn_fs_access_t object representing
436 * @a username, allocated in @a pool. @a username is presumed to
437 * have been authenticated by the caller.
439 svn_error_t *
440 svn_fs_create_access(svn_fs_access_t **access_ctx,
441 const char *username,
442 apr_pool_t *pool);
445 /** Associate @a access_ctx with an open @a fs.
447 * This function can be run multiple times on the same open
448 * filesystem, in order to change the filesystem access context for
449 * different filesystem operations. Pass a NULL value for @a
450 * access_ctx to disassociate the current access context from the
451 * filesystem.
453 svn_error_t *
454 svn_fs_set_access(svn_fs_t *fs,
455 svn_fs_access_t *access_ctx);
458 /** Set @a *access_ctx to the current @a fs access context, or NULL if
459 * there is no current fs access context.
461 svn_error_t *
462 svn_fs_get_access(svn_fs_access_t **access_ctx,
463 svn_fs_t *fs);
466 /** Accessors for the access context: */
468 /** Set @a *username to the name represented by @a access_ctx. */
469 svn_error_t *
470 svn_fs_access_get_username(const char **username,
471 svn_fs_access_t *access_ctx);
474 /** Push a lock-token @a token into the context @a access_ctx. The
475 * context remembers all tokens it receives, and makes them available
476 * to fs functions. The token is not duplicated into @a access_ctx's
477 * pool; make sure the token's lifetime is at least as long as @a
478 * access_ctx. */
479 svn_error_t *
480 svn_fs_access_add_lock_token(svn_fs_access_t *access_ctx,
481 const char *token);
483 /** @} */
486 /** Filesystem Nodes.
488 * In a Subversion filesystem, a `node' corresponds roughly to an
489 * `inode' in a Unix filesystem:
490 * - A node is either a file or a directory.
491 * - A node's contents change over time.
492 * - When you change a node's contents, it's still the same node; it's
493 * just been changed. So a node's identity isn't bound to a specific
494 * set of contents.
495 * - If you rename a node, it's still the same node, just under a
496 * different name. So a node's identity isn't bound to a particular
497 * filename.
499 * A `node revision' refers to a node's contents at a specific point in
500 * time. Changing a node's contents always creates a new revision of that
501 * node. Once created, a node revision's contents never change.
503 * When we create a node, its initial contents are the initial revision of
504 * the node. As users make changes to the node over time, we create new
505 * revisions of that same node. When a user commits a change that deletes
506 * a file from the filesystem, we don't delete the node, or any revision
507 * of it --- those stick around to allow us to recreate prior revisions of
508 * the filesystem. Instead, we just remove the reference to the node
509 * from the directory.
511 * @defgroup svn_fs_nodes Filesystem nodes
512 * @{
515 /** An object representing a node-id. */
516 typedef struct svn_fs_id_t svn_fs_id_t;
519 /** Return -1, 0, or 1 if node revisions @a a and @a b are unrelated,
520 * equivalent, or otherwise related (respectively).
522 int svn_fs_compare_ids(const svn_fs_id_t *a, const svn_fs_id_t *b);
526 /** Return non-zero IFF the nodes associated with @a id1 and @a id2 are
527 * related, else return zero.
529 svn_boolean_t
530 svn_fs_check_related(const svn_fs_id_t *id1,
531 const svn_fs_id_t *id2);
535 * @note This function is not guaranteed to work with all filesystem
536 * types. There is currently no un-deprecated equivalent; contact the
537 * Subversion developers if you have a need for it.
539 * @deprecated Provided for backward compatibility with the 1.0 API.
541 svn_fs_id_t *
542 svn_fs_parse_id(const char *data,
543 apr_size_t len,
544 apr_pool_t *pool);
547 /** Return a Subversion string containing the unparsed form of the
548 * node or node revision id @a id. Allocate the string containing the
549 * unparsed form in @a pool.
551 svn_string_t *
552 svn_fs_unparse_id(const svn_fs_id_t *id,
553 apr_pool_t *pool);
555 /** @} */
558 /** Filesystem Transactions.
560 * To make a change to a Subversion filesystem:
561 * - Create a transaction object, using svn_fs_begin_txn().
562 * - Call svn_fs_txn_root(), to get the transaction's root directory.
563 * - Make whatever changes you like in that tree.
564 * - Commit the transaction, using svn_fs_commit_txn().
566 * The filesystem implementation guarantees that your commit will
567 * either:
568 * - succeed completely, so that all of the changes are committed to
569 * create a new revision of the filesystem, or
570 * - fail completely, leaving the filesystem unchanged.
572 * Until you commit the transaction, any changes you make are
573 * invisible. Only when your commit succeeds do they become visible
574 * to the outside world, as a new revision of the filesystem.
576 * If you begin a transaction, and then decide you don't want to make
577 * the change after all (say, because your net connection with the
578 * client disappeared before the change was complete), you can call
579 * svn_fs_abort_txn(), to cancel the entire transaction; this
580 * leaves the filesystem unchanged.
582 * The only way to change the contents of files or directories, or
583 * their properties, is by making a transaction and creating a new
584 * revision, as described above. Once a revision has been committed, it
585 * never changes again; the filesystem interface provides no means to
586 * go back and edit the contents of an old revision. Once history has
587 * been recorded, it is set in stone. Clients depend on this property
588 * to do updates and commits reliably; proxies depend on this property
589 * to cache changes accurately; and so on.
591 * There are two kinds of nodes in the filesystem: mutable, and
592 * immutable. Revisions in the filesystem consist entirely of
593 * immutable nodes, whose contents never change. A transaction in
594 * progress, which the user is still constructing, uses mutable nodes
595 * for those nodes which have been changed so far, and refers to
596 * immutable nodes from existing revisions for portions of the tree
597 * which haven't been changed yet in that transaction.
599 * Immutable nodes, as part of revisions, never refer to mutable
600 * nodes, which are part of uncommitted transactions. Mutable nodes
601 * may refer to immutable nodes, or other mutable nodes.
603 * Note that the terms "immutable" and "mutable" describe whether or
604 * not the nodes have been changed as part of a transaction --- not
605 * the permissions on the nodes they refer to. Even if you aren't
606 * authorized to modify the filesystem's root directory, you might be
607 * authorized to change some descendant of the root; doing so would
608 * create a new mutable copy of the root directory. Mutability refers
609 * to the role of the node: part of an existing revision, or part of a
610 * new one. This is independent of your authorization to make changes
611 * to a given node.
613 * Transactions are actually persistent objects, stored in the
614 * database. You can open a filesystem, begin a transaction, and
615 * close the filesystem, and then a separate process could open the
616 * filesystem, pick up the same transaction, and continue work on it.
617 * When a transaction is successfully committed, it is removed from
618 * the database.
620 * Every transaction is assigned a name. You can open a transaction
621 * by name, and resume work on it, or find out the name of a
622 * transaction you already have open. You can also list all the
623 * transactions currently present in the database.
625 * You may assign properties to transactions; these are name/value
626 * pairs. When you commit a transaction, all of its properties become
627 * unversioned revision properties of the new revision. (There is one
628 * exception: the svn:date property will be automatically set on new
629 * transactions to the date that the transaction was created, and will
630 * be overwritten when the transaction is committed by the current
631 * time; changes to a transaction's svn:date property will not affect
632 * its committed value.)
634 * Transaction names are guaranteed to contain only letters (upper-
635 * and lower-case), digits, `-', and `.', from the ASCII character
636 * set.
638 * The Subversion filesystem will make a best effort to not reuse
639 * transaction names. The Berkeley DB backend generates transaction
640 * names using a sequence, or a counter, which is stored in the BDB
641 * database. Each new transaction increments the counter. The
642 * current value of the counter is not serialized into a filesystem
643 * dump file, so dumping and restoring the repository will reset the
644 * sequence and reuse transaction names. The FSFS backend generates a
645 * transaction name using the hostname, process ID and current time in
646 * microseconds since 00:00:00 January 1, 1970 UTC. So it is
647 * extremely unlikely that a transaction name will be reused.
649 * @defgroup svn_fs_txns Filesystem transactions
650 * @{
653 /** The type of a Subversion transaction object. */
654 typedef struct svn_fs_txn_t svn_fs_txn_t;
657 /** @defgroup svn_fs_begin_txn2_flags Bitmask flags for svn_fs_begin_txn2()
658 * @since New in 1.2.
659 * @{ */
661 /** Do on-the-fly out-of-dateness checks. That is, an fs routine may
662 * throw error if a caller tries to edit an out-of-date item in the
663 * transaction.
665 * @warning ### Not yet implemented.
667 #define SVN_FS_TXN_CHECK_OOD 0x00001
669 /** Do on-the-fly lock checks. That is, an fs routine may throw error
670 * if a caller tries to edit a locked item without having rights to the lock.
672 #define SVN_FS_TXN_CHECK_LOCKS 0x00002
673 /** @} */
676 * Begin a new transaction on the filesystem @a fs, based on existing
677 * revision @a rev. Set @a *txn_p to a pointer to the new transaction.
678 * When committed, this transaction will create a new revision.
680 * Allocate the new transaction in @a pool; when @a pool is freed, the new
681 * transaction will be closed (neither committed nor aborted).
683 * @a flags determines transaction enforcement behaviors, and is composed
684 * from the constants SVN_FS_TXN_* (@c SVN_FS_TXN_CHECK_OOD etc.).
686 * @note If you're building a txn for committing, you probably
687 * don't want to call this directly. Instead, call
688 * svn_repos_fs_begin_txn_for_commit(), which honors the
689 * repository's hook configurations.
691 * @since New in 1.2.
693 svn_error_t *
694 svn_fs_begin_txn2(svn_fs_txn_t **txn_p,
695 svn_fs_t *fs,
696 svn_revnum_t rev,
697 apr_uint32_t flags,
698 apr_pool_t *pool);
702 * Same as svn_fs_begin_txn2(), but with @a flags set to 0.
704 * @deprecated Provided for backward compatibility with the 1.1 API.
706 svn_error_t *
707 svn_fs_begin_txn(svn_fs_txn_t **txn_p,
708 svn_fs_t *fs,
709 svn_revnum_t rev,
710 apr_pool_t *pool);
714 /** Commit @a txn.
716 * @note You usually don't want to call this directly.
717 * Instead, call svn_repos_fs_commit_txn(), which honors the
718 * repository's hook configurations.
720 * If the transaction conflicts with other changes committed to the
721 * repository, return an @c SVN_ERR_FS_CONFLICT error. Otherwise, create
722 * a new filesystem revision containing the changes made in @a txn,
723 * storing that new revision number in @a *new_rev, and return zero.
725 * If @a conflict_p is non-zero, use it to provide details on any
726 * conflicts encountered merging @a txn with the most recent committed
727 * revisions. If a conflict occurs, set @a *conflict_p to the path of
728 * the conflict in @a txn, with the same lifetime as @a txn;
729 * otherwise, set @a *conflict_p to NULL.
731 * If the commit succeeds, @a txn is invalid.
733 * If the commit fails, @a txn is still valid; you can make more
734 * operations to resolve the conflict, or call svn_fs_abort_txn() to
735 * abort the transaction.
737 * @note Success or failure of the commit of @a txn is determined by
738 * examining the value of @a *new_rev upon this function's return. If
739 * the value is a valid revision number, the commit was successful,
740 * even though a non-@c NULL function return value may indicate that
741 * something else went wrong.
743 svn_error_t *
744 svn_fs_commit_txn(const char **conflict_p,
745 svn_revnum_t *new_rev,
746 svn_fs_txn_t *txn,
747 apr_pool_t *pool);
750 /** Abort the transaction @a txn. Any changes made in @a txn are
751 * discarded, and the filesystem is left unchanged. Use @a pool for
752 * any necessary allocations.
754 * @note This function first sets the state of @a txn to "dead", and
755 * then attempts to purge it and any related data from the filesystem.
756 * If some part of the cleanup process fails, @a txn and some portion
757 * of its data may remain in the database after this function returns.
758 * Use svn_fs_purge_txn() to retry the transaction cleanup.
760 svn_error_t *
761 svn_fs_abort_txn(svn_fs_txn_t *txn,
762 apr_pool_t *pool);
765 /** Cleanup the dead transaction in @a fs whose ID is @a txn_id. Use
766 * @a pool for all allocations. If the transaction is not yet dead,
767 * the error @c SVN_ERR_FS_TRANSACTION_NOT_DEAD is returned. (The
768 * caller probably forgot to abort the transaction, or the cleanup
769 * step of that abort failed for some reason.)
771 svn_error_t *
772 svn_fs_purge_txn(svn_fs_t *fs,
773 const char *txn_id,
774 apr_pool_t *pool);
777 /** Set @a *name_p to the name of the transaction @a txn, as a
778 * NULL-terminated string. Allocate the name in @a pool.
780 svn_error_t *
781 svn_fs_txn_name(const char **name_p,
782 svn_fs_txn_t *txn,
783 apr_pool_t *pool);
785 /** Return @a txn's base revision. */
786 svn_revnum_t svn_fs_txn_base_revision(svn_fs_txn_t *txn);
790 /** Open the transaction named @a name in the filesystem @a fs. Set @a *txn
791 * to the transaction.
793 * If there is no such transaction, @c SVN_ERR_FS_NO_SUCH_TRANSACTION is
794 * the error returned.
796 * Allocate the new transaction in @a pool; when @a pool is freed, the new
797 * transaction will be closed (neither committed nor aborted).
799 svn_error_t *
800 svn_fs_open_txn(svn_fs_txn_t **txn,
801 svn_fs_t *fs,
802 const char *name,
803 apr_pool_t *pool);
806 /** Set @a *names_p to an array of <tt>const char *</tt> ids which are the
807 * names of all the currently active transactions in the filesystem @a fs.
808 * Allocate the array in @a pool.
810 svn_error_t *
811 svn_fs_list_transactions(apr_array_header_t **names_p,
812 svn_fs_t *fs,
813 apr_pool_t *pool);
815 /* Transaction properties */
817 /** Set @a *value_p to the value of the property named @a propname on
818 * transaction @a txn. If @a txn has no property by that name, set
819 * @a *value_p to zero. Allocate the result in @a pool.
821 svn_error_t *
822 svn_fs_txn_prop(svn_string_t **value_p,
823 svn_fs_txn_t *txn,
824 const char *propname,
825 apr_pool_t *pool);
828 /** Set @a *table_p to the entire property list of transaction @a txn, as
829 * an APR hash table allocated in @a pool. The resulting table maps property
830 * names to pointers to @c svn_string_t objects containing the property value.
832 svn_error_t *
833 svn_fs_txn_proplist(apr_hash_t **table_p,
834 svn_fs_txn_t *txn,
835 apr_pool_t *pool);
838 /** Change a transactions @a txn's property's value, or add/delete a
839 * property. @a name is the name of the property to change, and @a value
840 * is the new value of the property, or zero if the property should be
841 * removed altogether. Do any necessary temporary allocation in @a pool.
843 svn_error_t *
844 svn_fs_change_txn_prop(svn_fs_txn_t *txn,
845 const char *name,
846 const svn_string_t *value,
847 apr_pool_t *pool);
850 /** Change, add, and/or delete transaction property values in
851 * transaction @a txn. @a props is an array of <tt>svn_prop_t</tt>
852 * elements. This is equivalent to calling svn_fs_change_txp_prop
853 * multiple times with the @c name and @c value fields of each
854 * successive <tt>svn_prop_t</tt>, but may be more efficient.
855 * (Properties not mentioned are left alone.) Do any necessary
856 * temporary allocation in @a pool.
858 * @since New in 1.5.
860 svn_error_t *
861 svn_fs_change_txn_props(svn_fs_txn_t *txn,
862 apr_array_header_t *props,
863 apr_pool_t *pool);
865 /** @} */
868 /** Roots.
870 * An @c svn_fs_root_t object represents the root directory of some
871 * revision or transaction in a filesystem. To refer to particular
872 * node, you provide a root, and a directory path relative that root.
874 * @defgroup svn_fs_roots Filesystem roots
875 * @{
878 /** The Filesystem Root object. */
879 typedef struct svn_fs_root_t svn_fs_root_t;
882 /** Set @a *root_p to the root directory of revision @a rev in filesystem
883 * @a fs. Allocate @a *root_p in @a pool.
885 svn_error_t *
886 svn_fs_revision_root(svn_fs_root_t **root_p,
887 svn_fs_t *fs,
888 svn_revnum_t rev,
889 apr_pool_t *pool);
892 /** Set @a *root_p to the root directory of @a txn. Allocate @a *root_p in
893 * @a pool.
895 svn_error_t *
896 svn_fs_txn_root(svn_fs_root_t **root_p,
897 svn_fs_txn_t *txn,
898 apr_pool_t *pool);
901 /** Free the root directory @a root. Simply clearing or destroying the
902 * pool @a root was allocated in will have the same effect as calling
903 * this function.
905 void svn_fs_close_root(svn_fs_root_t *root);
908 /** Return the filesystem to which @a root belongs. */
909 svn_fs_t *svn_fs_root_fs(svn_fs_root_t *root);
912 /** Return @c TRUE iff @a root is a transaction root. */
913 svn_boolean_t svn_fs_is_txn_root(svn_fs_root_t *root);
915 /** Return @c TRUE iff @a root is a revision root. */
916 svn_boolean_t svn_fs_is_revision_root(svn_fs_root_t *root);
919 /** If @a root is the root of a transaction, return the name of the
920 * transaction, allocated in @a pool; otherwise, return NULL.
922 const char *
923 svn_fs_txn_root_name(svn_fs_root_t *root,
924 apr_pool_t *pool);
926 /** If @a root is the root of a transaction, return the number of the
927 * revision on which is was based when created. Otherwise, return @c
928 * SVN_INVALID_REVNUM.
930 * @since New in 1.5.
932 svn_revnum_t svn_fs_txn_root_base_revision(svn_fs_root_t *root);
934 /** If @a root is the root of a revision, return the revision number.
935 * Otherwise, return @c SVN_INVALID_REVNUM.
937 svn_revnum_t svn_fs_revision_root_revision(svn_fs_root_t *root);
939 /** @} */
942 /** Directory entry names and directory paths.
944 * Here are the rules for directory entry names, and directory paths:
946 * A directory entry name is a Unicode string encoded in UTF-8, and
947 * may not contain the NULL character (U+0000). The name should be in
948 * Unicode canonical decomposition and ordering. No directory entry
949 * may be named '.', '..', or the empty string. Given a directory
950 * entry name which fails to meet these requirements, a filesystem
951 * function returns an SVN_ERR_FS_PATH_SYNTAX error.
953 * A directory path is a sequence of zero or more directory entry
954 * names, separated by slash characters (U+002f), and possibly ending
955 * with slash characters. Sequences of two or more consecutive slash
956 * characters are treated as if they were a single slash. If a path
957 * ends with a slash, it refers to the same node it would without the
958 * slash, but that node must be a directory, or else the function
959 * returns an SVN_ERR_FS_NOT_DIRECTORY error.
961 * A path consisting of the empty string, or a string containing only
962 * slashes, refers to the root directory.
964 * @defgroup svn_fs_directories Filesystem directories
965 * @{
970 /** The kind of change that occurred on the path. */
971 typedef enum
973 /** default value */
974 svn_fs_path_change_modify = 0,
976 /** path added in txn */
977 svn_fs_path_change_add,
979 /** path removed in txn */
980 svn_fs_path_change_delete,
982 /** path removed and re-added in txn */
983 svn_fs_path_change_replace,
985 /** ignore all previous change items for path (internal-use only) */
986 svn_fs_path_change_reset
988 } svn_fs_path_change_kind_t;
990 /** Change descriptor. */
991 typedef struct svn_fs_path_change_t
993 /** node revision id of changed path */
994 const svn_fs_id_t *node_rev_id;
996 /** kind of change */
997 svn_fs_path_change_kind_t change_kind;
999 /** were there text mods? */
1000 svn_boolean_t text_mod;
1002 /** were there property mods? */
1003 svn_boolean_t prop_mod;
1005 } svn_fs_path_change_t;
1008 /** Determine what has changed under a @a root.
1010 * Allocate and return a hash @a *changed_paths_p containing descriptions
1011 * of the paths changed under @a root. The hash is keyed with
1012 * <tt>const char *</tt> paths, and has @c svn_fs_path_change_t * values.
1013 * Use @c pool for all allocations, including the hash and its values.
1015 svn_error_t *
1016 svn_fs_paths_changed(apr_hash_t **changed_paths_p,
1017 svn_fs_root_t *root,
1018 apr_pool_t *pool);
1020 /** @} */
1023 /* Operations appropriate to all kinds of nodes. */
1025 /** Set @a *kind_p to the type of node present at @a path under @a
1026 * root. If @a path does not exist under @a root, set @a *kind_p to @c
1027 * svn_node_none. Use @a pool for temporary allocation.
1029 svn_error_t *
1030 svn_fs_check_path(svn_node_kind_t *kind_p,
1031 svn_fs_root_t *root,
1032 const char *path,
1033 apr_pool_t *pool);
1036 /** An opaque node history object. */
1037 typedef struct svn_fs_history_t svn_fs_history_t;
1040 /** Set @a *history_p to an opaque node history object which
1041 * represents @a path under @a root. @a root must be a revision root.
1042 * Use @a pool for all allocations.
1044 svn_error_t *
1045 svn_fs_node_history(svn_fs_history_t **history_p,
1046 svn_fs_root_t *root,
1047 const char *path,
1048 apr_pool_t *pool);
1051 /** Set @a *prev_history_p to an opaque node history object which
1052 * represents the previous (or "next oldest") interesting history
1053 * location for the filesystem node represented by @a history, or @c
1054 * NULL if no such previous history exists. If @a cross_copies is @c
1055 * FALSE, also return @c NULL if stepping backwards in history to @a
1056 * *prev_history_p would cross a filesystem copy operation.
1058 * @note If this is the first call to svn_fs_history_prev() for the @a
1059 * history object, it could return a history object whose location is
1060 * the same as the original. This will happen if the original
1061 * location was an interesting one (where the node was modified, or
1062 * took place in a copy event). This behavior allows looping callers
1063 * to avoid the calling svn_fs_history_location() on the object
1064 * returned by svn_fs_node_history(), and instead go ahead and begin
1065 * calling svn_fs_history_prev().
1067 * @note This function uses node-id ancestry alone to determine
1068 * modifiedness, and therefore does NOT claim that in any of the
1069 * returned revisions file contents changed, properties changed,
1070 * directory entries lists changed, etc.
1072 * @note The revisions returned for @a path will be older than or
1073 * the same age as the revision of that path in @a root. That is, if
1074 * @a root is a revision root based on revision X, and @a path was
1075 * modified in some revision(s) younger than X, those revisions
1076 * younger than X will not be included for @a path. */
1077 svn_error_t *
1078 svn_fs_history_prev(svn_fs_history_t **prev_history_p,
1079 svn_fs_history_t *history,
1080 svn_boolean_t cross_copies,
1081 apr_pool_t *pool);
1084 /** Set @a *path and @a *revision to the path and revision,
1085 * respectively, of the @a history object. Use @a pool for all
1086 * allocations.
1088 svn_error_t *
1089 svn_fs_history_location(const char **path,
1090 svn_revnum_t *revision,
1091 svn_fs_history_t *history,
1092 apr_pool_t *pool);
1095 /** Set @a *is_dir to @c TRUE iff @a path in @a root is a directory.
1096 * Do any necessary temporary allocation in @a pool.
1098 svn_error_t *
1099 svn_fs_is_dir(svn_boolean_t *is_dir,
1100 svn_fs_root_t *root,
1101 const char *path,
1102 apr_pool_t *pool);
1105 /** Set @a *is_file to @c TRUE iff @a path in @a root is a file.
1106 * Do any necessary temporary allocation in @a pool.
1108 svn_error_t *
1109 svn_fs_is_file(svn_boolean_t *is_file,
1110 svn_fs_root_t *root,
1111 const char *path,
1112 apr_pool_t *pool);
1115 /** Get the id of a node.
1117 * Set @a *id_p to the node revision ID of @a path in @a root, allocated in
1118 * @a pool.
1120 * If @a root is the root of a transaction, keep in mind that other
1121 * changes to the transaction can change which node @a path refers to,
1122 * and even whether the path exists at all.
1124 svn_error_t *
1125 svn_fs_node_id(const svn_fs_id_t **id_p,
1126 svn_fs_root_t *root,
1127 const char *path,
1128 apr_pool_t *pool);
1130 /** Set @a *revision to the revision in which @a path under @a root was
1131 * created. Use @a pool for any temporary allocations. @a *revision will
1132 * be set to @c SVN_INVALID_REVNUM for uncommitted nodes (i.e. modified nodes
1133 * under a transaction root). Note that the root of an unmodified transaction
1134 * is not itself considered to be modified; in that case, return the revision
1135 * upon which the transaction was based.
1137 svn_error_t *
1138 svn_fs_node_created_rev(svn_revnum_t *revision,
1139 svn_fs_root_t *root,
1140 const char *path,
1141 apr_pool_t *pool);
1143 /** Set @a *revision to the revision in which the line of history
1144 * represented by @a path under @a root originated. Use @a pool for
1145 * any temporary allocations. If @a root is a transaction root, @a
1146 * *revision will be set to @c SVN_INVALID_REVNUM for any nodes newly
1147 * added in that transaction (brand new files or directories created
1148 * using @c svn_fs_make_dir or @c svn_fs_make_file).
1150 * @since New in 1.5.
1152 svn_error_t *
1153 svn_fs_node_origin_rev(svn_revnum_t *revision,
1154 svn_fs_root_t *root,
1155 const char *path,
1156 apr_pool_t *pool);
1158 /** Set @a *created_path to the path at which @a path under @a root was
1159 * created. Use @a pool for all allocations. Callers may use this
1160 * function in conjunction with svn_fs_node_created_rev() to perform a
1161 * reverse lookup of the mapping of (path, revision) -> node-id that
1162 * svn_fs_node_id() performs.
1164 svn_error_t *
1165 svn_fs_node_created_path(const char **created_path,
1166 svn_fs_root_t *root,
1167 const char *path,
1168 apr_pool_t *pool);
1171 /** Set @a *value_p to the value of the property named @a propname of
1172 * @a path in @a root. If the node has no property by that name, set
1173 * @a *value_p to zero. Allocate the result in @a pool.
1175 svn_error_t *
1176 svn_fs_node_prop(svn_string_t **value_p,
1177 svn_fs_root_t *root,
1178 const char *path,
1179 const char *propname,
1180 apr_pool_t *pool);
1183 /** Set @a *table_p to the entire property list of @a path in @a root,
1184 * as an APR hash table allocated in @a pool. The resulting table maps
1185 * property names to pointers to @c svn_string_t objects containing the
1186 * property value.
1188 svn_error_t *
1189 svn_fs_node_proplist(apr_hash_t **table_p,
1190 svn_fs_root_t *root,
1191 const char *path,
1192 apr_pool_t *pool);
1195 /** Change a node's property's value, or add/delete a property.
1197 * - @a root and @a path indicate the node whose property should change.
1198 * @a root must be the root of a transaction, not the root of a revision.
1199 * - @a name is the name of the property to change.
1200 * - @a value is the new value of the property, or zero if the property should
1201 * be removed altogether.
1202 * Do any necessary temporary allocation in @a pool.
1204 svn_error_t *
1205 svn_fs_change_node_prop(svn_fs_root_t *root,
1206 const char *path,
1207 const char *name,
1208 const svn_string_t *value,
1209 apr_pool_t *pool);
1212 /** Determine if the properties of two path/root combinations are different.
1214 * Set @a *changed_p to 1 if the properties at @a path1 under @a root1 differ
1215 * from those at @a path2 under @a root2, or set it to 0 if they are the
1216 * same. Both paths must exist under their respective roots, and both
1217 * roots must be in the same filesystem.
1219 svn_error_t *
1220 svn_fs_props_changed(svn_boolean_t *changed_p,
1221 svn_fs_root_t *root1,
1222 const char *path1,
1223 svn_fs_root_t *root2,
1224 const char *path2,
1225 apr_pool_t *pool);
1228 /** Discover a node's copy ancestry, if any.
1230 * If the node at @a path in @a root was copied from some other node, set
1231 * @a *rev_p and @a *path_p to the revision and path of the other node,
1232 * allocating @a *path_p in @a pool.
1234 * Else if there is no copy ancestry for the node, set @a *rev_p to
1235 * @c SVN_INVALID_REVNUM and @a *path_p to NULL.
1237 * If an error is returned, the values of @a *rev_p and @a *path_p are
1238 * undefined, but otherwise, if one of them is set as described above,
1239 * you may assume the other is set correspondingly.
1241 * @a root may be a revision root or a transaction root.
1243 * Notes:
1244 * - Copy ancestry does not descend. After copying directory D to
1245 * E, E will have copy ancestry referring to D, but E's children
1246 * may not. See also svn_fs_copy().
1248 * - Copy ancestry *under* a copy is preserved. That is, if you
1249 * copy /A/D/G/pi to /A/D/G/pi2, and then copy /A/D/G to /G, then
1250 * /G/pi2 will still have copy ancestry pointing to /A/D/G/pi.
1251 * We don't know if this is a feature or a bug yet; if it turns
1252 * out to be a bug, then the fix is to make svn_fs_copied_from()
1253 * observe the following logic, which currently callers may
1254 * choose to follow themselves: if node X has copy history, but
1255 * its ancestor A also has copy history, then you may ignore X's
1256 * history if X's revision-of-origin is earlier than A's --
1257 * because that would mean that X's copy history was preserved in
1258 * a copy-under-a-copy scenario. If X's revision-of-origin is
1259 * the same as A's, then it was copied under A during the same
1260 * transaction that created A. (X's revision-of-origin cannot be
1261 * greater than A's, if X has copy history.) @todo See how
1262 * people like this, it can always be hidden behind the curtain
1263 * if necessary.
1265 * - Copy ancestry is not stored as a regular subversion property
1266 * because it is not inherited. Copying foo to bar results in a
1267 * revision of bar with copy ancestry; but committing a text
1268 * change to bar right after that results in a new revision of
1269 * bar without copy ancestry.
1271 svn_error_t *
1272 svn_fs_copied_from(svn_revnum_t *rev_p,
1273 const char **path_p,
1274 svn_fs_root_t *root,
1275 const char *path,
1276 apr_pool_t *pool);
1279 /** Set @a *root_p and @a *path_p to the revision root and path of the
1280 * destination of the most recent copy event that caused @a path to
1281 * exist where it does in @a root, or to NULL if no such copy exists.
1282 * When non-NULL, allocate @a *root_p and @a *path_p in @a pool.
1284 * @a *path_p might be a parent of @a path, rather than @a path
1285 * itself. However, it will always be the deepest relevant path.
1286 * That is, if a copy occurs underneath another copy in the same txn,
1287 * this function makes sure to set @a *path_p to the longest copy
1288 * destination path that is still a parent of or equal to @a path.
1290 * @since New in 1.3.
1292 svn_error_t *
1293 svn_fs_closest_copy(svn_fs_root_t **root_p,
1294 const char **path_p,
1295 svn_fs_root_t *root,
1296 const char *path,
1297 apr_pool_t *pool);
1300 /** Retrieve mergeinfo for multiple nodes.
1302 * @a *catalog is a catalog for @a paths. It will never be @c NULL,
1303 * but may be empty.
1305 * @a root is revision root to use when looking up paths.
1307 * @a paths are the paths you are requesting information for.
1309 * @a inherit indicates whether to retrieve explicit,
1310 * explicit-or-inherited, or only inherited mergeinfo.
1312 * If @a include_descendants is TRUE, then additionally return the
1313 * mergeinfo for any descendant of any element of @a paths which has
1314 * the @c SVN_PROP_MERGEINFO property explicitly set on it. (Note
1315 * that inheritance is only taken into account for the elements in @a
1316 * paths; descendants of the elements in @a paths which get their
1317 * mergeinfo via inheritance are not included in @a *mergeoutput.)
1319 * Do any necessary temporary allocation in @a pool.
1321 * @since New in 1.5.
1323 svn_error_t *
1324 svn_fs_get_mergeinfo(svn_mergeinfo_catalog_t *catalog,
1325 svn_fs_root_t *root,
1326 const apr_array_header_t *paths,
1327 svn_mergeinfo_inheritance_t inherit,
1328 svn_boolean_t include_descendants,
1329 apr_pool_t *pool);
1331 /** Merge changes between two nodes into a third node.
1333 * Given nodes @a source and @a target, and a common ancestor @a ancestor,
1334 * modify @a target to contain all the changes made between @a ancestor and
1335 * @a source, as well as the changes made between @a ancestor and @a target.
1336 * @a target_root must be the root of a transaction, not a revision.
1338 * @a source, @a target, and @a ancestor are generally directories; this
1339 * function recursively merges the directories' contents. If they are
1340 * files, this function simply returns an error whenever @a source,
1341 * @a target, and @a ancestor are all distinct node revisions.
1343 * If there are differences between @a ancestor and @a source that conflict
1344 * with changes between @a ancestor and @a target, this function returns an
1345 * @c SVN_ERR_FS_CONFLICT error.
1347 * If the merge is successful, @a target is left in the merged state, and
1348 * the base root of @a target's txn is set to the root node of @a source.
1349 * If an error is returned (whether for conflict or otherwise), @a target
1350 * is left unaffected.
1352 * If @a conflict_p is non-NULL, then: a conflict error sets @a *conflict_p
1353 * to the name of the node in @a target which couldn't be merged,
1354 * otherwise, success sets @a *conflict_p to NULL.
1356 * Do any necessary temporary allocation in @a pool.
1358 svn_error_t *
1359 svn_fs_merge(const char **conflict_p,
1360 svn_fs_root_t *source_root,
1361 const char *source_path,
1362 svn_fs_root_t *target_root,
1363 const char *target_path,
1364 svn_fs_root_t *ancestor_root,
1365 const char *ancestor_path,
1366 apr_pool_t *pool);
1370 /* Directories. */
1373 /** The type of a Subversion directory entry. */
1374 typedef struct svn_fs_dirent_t
1377 /** The name of this directory entry. */
1378 const char *name;
1380 /** The node revision ID it names. */
1381 const svn_fs_id_t *id;
1383 /** The node kind. */
1384 svn_node_kind_t kind;
1386 } svn_fs_dirent_t;
1389 /** Set @a *entries_p to a newly allocated APR hash table containing the
1390 * entries of the directory at @a path in @a root. The keys of the table
1391 * are entry names, as byte strings, excluding the final NULL
1392 * character; the table's values are pointers to @c svn_fs_dirent_t
1393 * structures. Allocate the table and its contents in @a pool.
1395 svn_error_t *
1396 svn_fs_dir_entries(apr_hash_t **entries_p,
1397 svn_fs_root_t *root,
1398 const char *path,
1399 apr_pool_t *pool);
1402 /** Create a new directory named @a path in @a root. The new directory has
1403 * no entries, and no properties. @a root must be the root of a transaction,
1404 * not a revision.
1406 * Do any necessary temporary allocation in @a pool.
1408 svn_error_t *
1409 svn_fs_make_dir(svn_fs_root_t *root,
1410 const char *path,
1411 apr_pool_t *pool);
1414 /** Delete the node named @a path in @a root. If the node being deleted is
1415 * a directory, its contents will be deleted recursively. @a root must be
1416 * the root of a transaction, not of a revision. Use @a pool for
1417 * temporary allocation.
1419 * This function may be more efficient than making the equivalent
1420 * series of calls to svn_fs_delete(), because it takes advantage of the
1421 * fact that, to delete an immutable subtree, shared with some
1422 * committed revision, you need only remove the directory entry. The
1423 * dumb algorithm would recurse into the subtree and end up cloning
1424 * each non-empty directory it contains, only to delete it later.
1426 * If return @c SVN_ERR_FS_NO_SUCH_ENTRY, then the basename of @a path is
1427 * missing from its parent, that is, the final target of the deletion
1428 * is missing.
1430 * Attempting to remove the root dir also results in an error,
1431 * @c SVN_ERR_FS_ROOT_DIR, even if the dir is empty.
1433 svn_error_t *
1434 svn_fs_delete(svn_fs_root_t *root,
1435 const char *path,
1436 apr_pool_t *pool);
1439 /** Create a copy of @a from_path in @a from_root named @a to_path in
1440 * @a to_root. If @a from_path in @a from_root is a directory, copy the
1441 * tree it refers to recursively.
1443 * The copy will remember its source; use svn_fs_copied_from() to
1444 * access this information.
1446 * @a to_root must be the root of a transaction; @a from_root must be the
1447 * root of a revision. (Requiring @a from_root to be the root of a
1448 * revision makes the implementation trivial: there is no detectable
1449 * difference (modulo node revision ID's) between copying @a from and
1450 * simply adding a reference to it. So the operation takes place in
1451 * constant time. However, there's no reason not to extend this to
1452 * mutable nodes --- it's just more code.) Further, @a to_root and @a
1453 * from_root must represent the same filesystem.
1455 * @note To do a copy without preserving copy history, use
1456 * svn_fs_revision_link().
1458 * Do any necessary temporary allocation in @a pool.
1460 svn_error_t *
1461 svn_fs_copy(svn_fs_root_t *from_root,
1462 const char *from_path,
1463 svn_fs_root_t *to_root,
1464 const char *to_path,
1465 apr_pool_t *pool);
1468 /** Like svn_fs_copy(), but doesn't record copy history, and preserves
1469 * the PATH. You cannot use svn_fs_copied_from() later to find out
1470 * where this copy came from.
1472 * Use svn_fs_revision_link() in situations where you don't care
1473 * about the copy history, and where @a to_path and @a from_path are
1474 * the same, because it is cheaper than svn_fs_copy().
1476 svn_error_t *
1477 svn_fs_revision_link(svn_fs_root_t *from_root,
1478 svn_fs_root_t *to_root,
1479 const char *path,
1480 apr_pool_t *pool);
1482 /* Files. */
1484 /** Set @a *length_p to the length of the file @a path in @a root, in bytes.
1485 * Do any necessary temporary allocation in @a pool.
1487 svn_error_t *
1488 svn_fs_file_length(svn_filesize_t *length_p,
1489 svn_fs_root_t *root,
1490 const char *path,
1491 apr_pool_t *pool);
1494 /** Put the MD5 checksum of file @a path into @a digest, which points
1495 * to @c APR_MD5_DIGESTSIZE bytes of storage. Use @a pool only for temporary
1496 * allocations.
1498 * If the filesystem does not have a prerecorded checksum for @a path,
1499 * do not calculate a checksum dynamically, just put all 0's into @a
1500 * digest. (By convention, the all-zero checksum is considered to
1501 * match any checksum.)
1503 * Notes:
1505 * You might wonder, why do we only provide this interface for file
1506 * contents, and not for properties or directories?
1508 * The answer is that property lists and directory entry lists are
1509 * essentially data structures, not text. We serialize them for
1510 * transmission, but there is no guarantee that the consumer will
1511 * parse them into the same form, or even the same order, as the
1512 * producer. It's difficult to find a checksumming method that
1513 * reaches the same result given such variation in input. (I suppose
1514 * we could calculate an independent MD5 sum for each propname and
1515 * value, and XOR them together; same with directory entry names.
1516 * Maybe that's the solution?) Anyway, for now we punt. The most
1517 * important data, and the only data that goes through svndiff
1518 * processing, is file contents, so that's what we provide
1519 * checksumming for.
1521 * Internally, of course, the filesystem checksums everything, because
1522 * it has access to the lowest level storage forms: strings behind
1523 * representations.
1525 svn_error_t *
1526 svn_fs_file_md5_checksum(unsigned char digest[],
1527 svn_fs_root_t *root,
1528 const char *path,
1529 apr_pool_t *pool);
1532 /** Set @a *contents to a readable generic stream that will yield the
1533 * contents of the file @a path in @a root. Allocate the stream in
1534 * @a pool. You can only use @a *contents for as long as the underlying
1535 * filesystem is open. If @a path is not a file, return
1536 * @c SVN_ERR_FS_NOT_FILE.
1538 * If @a root is the root of a transaction, it is possible that the
1539 * contents of the file @a path will change between calls to
1540 * svn_fs_file_contents(). In that case, the result of reading from
1541 * @a *contents is undefined.
1543 * ### @todo kff: I am worried about lifetime issues with this pool vs
1544 * the trail created farther down the call stack. Trace this function
1545 * to investigate...
1547 svn_error_t *
1548 svn_fs_file_contents(svn_stream_t **contents,
1549 svn_fs_root_t *root,
1550 const char *path,
1551 apr_pool_t *pool);
1554 /** Create a new file named @a path in @a root. The file's initial contents
1555 * are the empty string, and it has no properties. @a root must be the
1556 * root of a transaction, not a revision.
1558 * Do any necessary temporary allocation in @a pool.
1560 svn_error_t *
1561 svn_fs_make_file(svn_fs_root_t *root,
1562 const char *path,
1563 apr_pool_t *pool);
1566 /** Apply a text delta to the file @a path in @a root. @a root must be the
1567 * root of a transaction, not a revision.
1569 * Set @a *contents_p to a function ready to receive text delta windows
1570 * describing how to change the file's contents, relative to its
1571 * current contents. Set @a *contents_baton_p to a baton to pass to
1572 * @a *contents_p.
1574 * If @a path does not exist in @a root, return an error. (You cannot use
1575 * this routine to create new files; use svn_fs_make_file() to create
1576 * an empty file first.)
1578 * @a base_checksum is the hex MD5 digest for the base text against
1579 * which the delta is to be applied; it is ignored if NULL, and may be
1580 * ignored even if not NULL. If it is not ignored, it must match the
1581 * checksum of the base text against which svndiff data is being
1582 * applied; if not, svn_fs_apply_textdelta() or the @a *contents_p call
1583 * which detects the mismatch will return the error
1584 * @c SVN_ERR_CHECKSUM_MISMATCH (if there is no base text, there may
1585 * still be an error if @a base_checksum is neither NULL nor the
1586 * checksum of the empty string).
1588 * @a result_checksum is the hex MD5 digest for the fulltext that
1589 * results from this delta application. It is ignored if NULL, but if
1590 * not NULL, it must match the checksum of the result; if it does not,
1591 * then the @a *contents_p call which detects the mismatch will return
1592 * the error @c SVN_ERR_CHECKSUM_MISMATCH.
1594 * The caller must send all delta windows including the terminating
1595 * NULL window to @a *contents_p before making further changes to the
1596 * transaction.
1598 * Do temporary allocation in @a pool.
1600 svn_error_t *
1601 svn_fs_apply_textdelta(svn_txdelta_window_handler_t *contents_p,
1602 void **contents_baton_p,
1603 svn_fs_root_t *root,
1604 const char *path,
1605 const char *base_checksum,
1606 const char *result_checksum,
1607 apr_pool_t *pool);
1610 /** Write data directly to the file @a path in @a root. @a root must be the
1611 * root of a transaction, not a revision.
1613 * Set @a *contents_p to a stream ready to receive full textual data.
1614 * When the caller closes this stream, the data replaces the previous
1615 * contents of the file. The caller must write all file data and close
1616 * the stream before making further changes to the transaction.
1618 * If @a path does not exist in @a root, return an error. (You cannot use
1619 * this routine to create new files; use svn_fs_make_file() to create
1620 * an empty file first.)
1622 * @a result_checksum is the hex MD5 digest for the final fulltext
1623 * written to the stream. It is ignored if NULL, but if not null, it
1624 * must match the checksum of the result; if it does not, then the @a
1625 * *contents_p call which detects the mismatch will return the error
1626 * @c SVN_ERR_CHECKSUM_MISMATCH.
1628 * Do any necessary temporary allocation in @a pool.
1630 * ### This is like svn_fs_apply_textdelta(), but takes the text
1631 * straight. It is currently used only by the loader, see
1632 * libsvn_repos/load.c. It should accept a checksum, of course, which
1633 * would come from an (optional) header in the dump file. See
1634 * http://subversion.tigris.org/issues/show_bug.cgi?id=1102 for more.
1636 svn_error_t *
1637 svn_fs_apply_text(svn_stream_t **contents_p,
1638 svn_fs_root_t *root,
1639 const char *path,
1640 const char *result_checksum,
1641 apr_pool_t *pool);
1644 /** Check if the contents of two root/path combos have changed.
1646 * Set @a *changed_p to 1 if the contents at @a path1 under @a root1 differ
1647 * from those at @a path2 under @a root2, or set it to 0 if they are the
1648 * same. Both paths must exist under their respective roots, and both
1649 * roots must be in the same filesystem.
1651 svn_error_t *
1652 svn_fs_contents_changed(svn_boolean_t *changed_p,
1653 svn_fs_root_t *root1,
1654 const char *path1,
1655 svn_fs_root_t *root2,
1656 const char *path2,
1657 apr_pool_t *pool);
1661 /* Filesystem revisions. */
1664 /** Set @a *youngest_p to the number of the youngest revision in filesystem
1665 * @a fs. Use @a pool for all temporary allocation.
1667 * The oldest revision in any filesystem is numbered zero.
1669 svn_error_t *
1670 svn_fs_youngest_rev(svn_revnum_t *youngest_p,
1671 svn_fs_t *fs,
1672 apr_pool_t *pool);
1675 /** Deltify predecessors of paths modified in @a revision in
1676 * filesystem @a fs. Use @a pool for all allocations.
1678 * @note This can be a time-consuming process, depending the breadth
1679 * of the changes made in @a revision, and the depth of the history of
1680 * those changed paths.
1682 svn_error_t *
1683 svn_fs_deltify_revision(svn_fs_t *fs,
1684 svn_revnum_t revision,
1685 apr_pool_t *pool);
1688 /** Set @a *value_p to the value of the property named @a propname on
1689 * revision @a rev in the filesystem @a fs. If @a rev has no property by
1690 * that name, set @a *value_p to zero. Allocate the result in @a pool.
1692 svn_error_t *
1693 svn_fs_revision_prop(svn_string_t **value_p,
1694 svn_fs_t *fs,
1695 svn_revnum_t rev,
1696 const char *propname,
1697 apr_pool_t *pool);
1700 /** Set @a *table_p to the entire property list of revision @a rev in
1701 * filesystem @a fs, as an APR hash table allocated in @a pool. The table
1702 * maps <tt>char *</tt> property names to @c svn_string_t * values; the names
1703 * and values are allocated in @a pool.
1705 svn_error_t *
1706 svn_fs_revision_proplist(apr_hash_t **table_p,
1707 svn_fs_t *fs,
1708 svn_revnum_t rev,
1709 apr_pool_t *pool);
1712 /** Change a revision's property's value, or add/delete a property.
1714 * - @a fs is a filesystem, and @a rev is the revision in that filesystem
1715 * whose property should change.
1716 * - @a name is the name of the property to change.
1717 * - @a value is the new value of the property, or zero if the property should
1718 * be removed altogether.
1720 * Note that revision properties are non-historied --- you can change
1721 * them after the revision has been committed. They are not protected
1722 * via transactions.
1724 * Do any necessary temporary allocation in @a pool.
1726 svn_error_t *
1727 svn_fs_change_rev_prop(svn_fs_t *fs,
1728 svn_revnum_t rev,
1729 const char *name,
1730 const svn_string_t *value,
1731 apr_pool_t *pool);
1735 /* Computing deltas. */
1738 /** Set @a *stream_p to a pointer to a delta stream that will turn the
1739 * contents of the file @a source into the contents of the file @a target.
1740 * If @a source_root is zero, use a file with zero length as the source.
1742 * This function does not compare the two files' properties.
1744 * Allocate @a *stream_p, and do any necessary temporary allocation, in
1745 * @a pool.
1747 svn_error_t *
1748 svn_fs_get_file_delta_stream(svn_txdelta_stream_t **stream_p,
1749 svn_fs_root_t *source_root,
1750 const char *source_path,
1751 svn_fs_root_t *target_root,
1752 const char *target_path,
1753 apr_pool_t *pool);
1757 /* UUID manipulation. */
1759 /** Populate @a *uuid with the UUID associated with @a fs. Allocate
1760 @a *uuid in @a pool. */
1761 svn_error_t *
1762 svn_fs_get_uuid(svn_fs_t *fs,
1763 const char **uuid,
1764 apr_pool_t *pool);
1767 /** If not @c NULL, associate @a *uuid with @a fs. Otherwise (if @a
1768 * uuid is @c NULL), generate a new UUID for @a fs. Use @a pool for
1769 * any scratchwork.
1771 svn_error_t *
1772 svn_fs_set_uuid(svn_fs_t *fs,
1773 const char *uuid,
1774 apr_pool_t *pool);
1777 /* Non-historical properties. */
1779 /* [[Yes, do tell.]] */
1783 /** @defgroup svn_fs_locks Filesystem locks
1784 * @{
1785 * @since New in 1.2. */
1787 /** A lock represents one user's exclusive right to modify a path in a
1788 * filesystem. In order to create or destroy a lock, a username must
1789 * be associated with the filesystem's access context (see @c
1790 * svn_fs_access_t).
1792 * When a lock is created, a 'lock-token' is returned. The lock-token
1793 * is a unique URI that represents the lock (treated as an opaque
1794 * string by the client), and is required to make further use of the
1795 * lock (including removal of the lock.) A lock-token can also be
1796 * queried to return a svn_lock_t structure that describes the details
1797 * of the lock.
1799 * Locks are not secret; anyone can view existing locks in a
1800 * filesystem. Locks are not omnipotent: they can broken and stolen
1801 * by people who don't "own" the lock. (Though admins can tailor a
1802 * custom break/steal policy via libsvn_repos pre-lock hook script.)
1804 * Locks can be created with an optional expiration date. If a lock
1805 * has an expiration date, then the act of fetching/reading it might
1806 * cause it to automatically expire, returning either nothing or an
1807 * expiration error (depending on the API).
1811 /** Lock @a path in @a fs, and set @a *lock to a lock
1812 * representing the new lock, allocated in @a pool.
1814 * @warning You may prefer to use svn_repos_fs_lock() instead,
1815 * which see.
1817 * @a fs must have a username associated with it (see @c
1818 * svn_fs_access_t), else return @c SVN_ERR_FS_NO_USER. Set the
1819 * 'owner' field in the new lock to the fs username.
1821 * @a comment is optional: it's either an xml-escapable UTF8 string
1822 * which describes the lock, or it is @c NULL.
1824 * @a is_dav_comment describes whether the comment was created by a
1825 * generic DAV client; only mod_dav_svn's autoversioning feature needs
1826 * to use it. If in doubt, pass 0.
1828 * If path is already locked, then return @c SVN_ERR_FS_PATH_ALREADY_LOCKED,
1829 * unless @a steal_lock is TRUE, in which case "steal" the existing
1830 * lock, even if the FS access-context's username does not match the
1831 * current lock's owner: delete the existing lock on @a path, and
1832 * create a new one.
1834 * @a token is a lock token such as can be generated using
1835 * svn_fs_generate_lock_token() (indicating that the caller wants to
1836 * dictate the lock token used), or it is @c NULL (indicating that the
1837 * caller wishes to have a new token generated by this function). If
1838 * @a token is not @c NULL, and represents an existing lock, then @a
1839 * path must match the path associated with that existing lock.
1841 * If @a expiration_date is zero, then create a non-expiring lock.
1842 * Else, the lock will expire at @a expiration_date.
1844 * If @a current_rev is a valid revnum, then do an out-of-dateness
1845 * check. If the revnum is less than the last-changed-revision of @a
1846 * path (or if @a path doesn't exist in HEAD), return @c
1847 * SVN_ERR_FS_OUT_OF_DATE.
1849 * @note At this time, only files can be locked.
1851 svn_error_t *
1852 svn_fs_lock(svn_lock_t **lock,
1853 svn_fs_t *fs,
1854 const char *path,
1855 const char *token,
1856 const char *comment,
1857 svn_boolean_t is_dav_comment,
1858 apr_time_t expiration_date,
1859 svn_revnum_t current_rev,
1860 svn_boolean_t steal_lock,
1861 apr_pool_t *pool);
1864 /** Generate a unique lock-token using @a fs. Return in @a *token,
1865 * allocated in @a pool.
1867 * This can be used in to populate lock->token before calling
1868 * svn_fs_attach_lock().
1870 svn_error_t *
1871 svn_fs_generate_lock_token(const char **token,
1872 svn_fs_t *fs,
1873 apr_pool_t *pool);
1876 /** Remove the lock on @a path represented by @a token in @a fs.
1878 * If @a token doesn't point to a lock, return @c SVN_ERR_FS_BAD_LOCK_TOKEN.
1879 * If @a token points to an expired lock, return @c SVN_ERR_FS_LOCK_EXPIRED.
1880 * If @a fs has no username associated with it, return @c SVN_ERR_FS_NO_USER
1881 * unless @a break_lock is specified.
1883 * If @a token points to a lock, but the username of @a fs's access
1884 * context doesn't match the lock's owner, return @c
1885 * SVN_ERR_FS_LOCK_OWNER_MISMATCH. If @a break_lock is TRUE, however, don't
1886 * return error; allow the lock to be "broken" in any case. In the latter
1887 * case, @a token shall be @c NULL.
1889 * Use @a pool for temporary allocations.
1891 svn_error_t *
1892 svn_fs_unlock(svn_fs_t *fs,
1893 const char *path,
1894 const char *token,
1895 svn_boolean_t break_lock,
1896 apr_pool_t *pool);
1899 /** If @a path is locked in @a fs, set @a *lock to an svn_lock_t which
1900 * represents the lock, allocated in @a pool.
1902 * If @a path is not locked, set @a *lock to NULL.
1904 svn_error_t *
1905 svn_fs_get_lock(svn_lock_t **lock,
1906 svn_fs_t *fs,
1907 const char *path,
1908 apr_pool_t *pool);
1911 /** The type of a lock discovery callback function. @a baton is the
1912 * value specified in the call to svn_fs_get_locks(); the filesystem
1913 * passes it through to the callback. @a lock is a lock structure.
1914 * @a pool is a temporary subpool for use by the callback
1915 * implementation -- it is cleared after invocation of the callback.
1917 typedef svn_error_t *(*svn_fs_get_locks_callback_t)(void *baton,
1918 svn_lock_t *lock,
1919 apr_pool_t *pool);
1922 /** Report locks on or below @a path in @a fs using the @a
1923 * get_locks_func / @a get_locks_baton. Use @a pool for necessary
1924 * allocations.
1926 * If the @a get_locks_func callback implementation returns an error,
1927 * lock iteration will terminate and that error will be returned by
1928 * this function.
1930 svn_error_t *
1931 svn_fs_get_locks(svn_fs_t *fs,
1932 const char *path,
1933 svn_fs_get_locks_callback_t get_locks_func,
1934 void *get_locks_baton,
1935 apr_pool_t *pool);
1937 /** @} */
1940 * Append a textual list of all available FS modules to the stringbuf
1941 * @a output.
1943 * @since New in 1.2.
1945 svn_error_t *
1946 svn_fs_print_modules(svn_stringbuf_t *output,
1947 apr_pool_t *pool);
1949 /** @} */
1951 #ifdef __cplusplus
1953 #endif /* __cplusplus */
1955 #endif /* SVN_FS_H */