2 * svn_fs_util.h: Declarations for the APIs of libsvn_fs_util to be
3 * consumed by only fs_* libs.
5 * ====================================================================
6 * Copyright (c) 2007 CollabNet. All rights reserved.
8 * This software is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution. The terms
10 * are also available at http://subversion.tigris.org/license-1.html.
11 * If newer versions of this license are posted there, you may use a
12 * newer version instead, at your option.
14 * This software consists of voluntary contributions made by many
15 * individuals. For exact contribution history, see the revision
16 * history and logs, available at http://subversion.tigris.org/.
17 * ====================================================================
23 #include "svn_private_config.h"
26 #endif /* __cplusplus */
28 /* Return a canonicalized version of a filesystem PATH, allocated in
29 POOL. While the filesystem API is pretty flexible about the
30 incoming paths (they must be UTF-8 with '/' as separators, but they
31 don't have to begin with '/', and multiple contiguous '/'s are
32 ignored) we want any paths that are physically stored in the
33 underlying database to look consistent. Specifically, absolute
34 filesystem paths should begin with '/', and all redundant and trailing '/'
35 characters be removed. */
37 svn_fs__canonicalize_abspath(const char *path
, apr_pool_t
*pool
);
39 /* If EXPECT_OPEN, verify that FS refers to an open database;
40 otherwise, verify that FS refers to an unopened database. Return
41 an appropriate error if the expecation fails to match the
43 svn_error_t
*svn_fs__check_fs(svn_fs_t
*fs
, svn_boolean_t expect_open
);
45 /* Constructing nice error messages for roots. */
47 /* Build an SVN_ERR_FS_NOT_FOUND error, with a detailed error text,
48 for PATH in ROOT. ROOT is of type svn_fs_root_t *. */
49 #define SVN_FS__NOT_FOUND(root, path) ( \
52 (SVN_ERR_FS_NOT_FOUND, 0, \
53 _("File not found: transaction '%s', path '%s'"), \
57 (SVN_ERR_FS_NOT_FOUND, 0, \
58 _("File not found: revision %ld, path '%s'"), \
63 /* Build a detailed `file already exists' message for PATH in ROOT.
64 ROOT is of type svn_fs_root_t *. */
65 #define SVN_FS__ALREADY_EXISTS(root, path_str) ( \
68 (SVN_ERR_FS_ALREADY_EXISTS, 0, \
69 _("File already exists: filesystem '%s', transaction '%s', path '%s'"), \
70 root->fs->path, root->txn, path_str) \
73 (SVN_ERR_FS_ALREADY_EXISTS, 0, \
74 _("File already exists: filesystem '%s', revision %ld, path '%s'"), \
75 root->fs->path, root->rev, path_str) \
78 /* ROOT is of type svn_fs_root_t *. */
79 #define SVN_FS__NOT_TXN(root) \
81 (SVN_ERR_FS_NOT_TXN_ROOT, NULL, \
82 _("Root object must be a transaction root"))
84 /* SVN_FS__ERR_NOT_MUTABLE: the caller attempted to change a node
85 outside of a transaction. FS is of type "svn_fs_t *". */
86 #define SVN_FS__ERR_NOT_MUTABLE(fs, rev, path_in_repo) \
88 (SVN_ERR_FS_NOT_MUTABLE, 0, \
89 _("File is not mutable: filesystem '%s', revision %ld, path '%s'"), \
90 fs->path, rev, path_in_repo)
92 /* FS is of type "svn fs_t *".*/
93 #define SVN_FS__ERR_NOT_DIRECTORY(fs, path_in_repo) \
95 (SVN_ERR_FS_NOT_DIRECTORY, 0, \
96 _("'%s' is not a directory in filesystem '%s'"), \
97 path_in_repo, fs->path)
99 /* FS is of type "svn fs_t *". */
100 #define SVN_FS__ERR_NOT_FILE(fs, path_in_repo) \
102 (SVN_ERR_FS_NOT_FILE, 0, \
103 _("'%s' is not a file in filesystem '%s'"), \
104 path_in_repo, fs->path)
106 /* FS is of type "svn fs_t *", LOCK is of type "svn_lock_t *". */
107 #define SVN_FS__ERR_PATH_ALREADY_LOCKED(fs, lock) \
109 (SVN_ERR_FS_PATH_ALREADY_LOCKED, 0, \
110 _("Path '%s' is already locked by user '%s' in filesystem '%s'"), \
111 lock->path, lock->owner, fs->path)
113 /* FS is of type "svn fs_t *". */
114 #define SVN_FS__ERR_NO_SUCH_LOCK(fs, path_in_repo) \
116 (SVN_ERR_FS_NO_SUCH_LOCK, 0, \
117 _("No lock on path '%s' in filesystem '%s'"), \
118 path_in_repo, fs->path)
120 /* FS is of type "svn fs_t *". */
121 #define SVN_FS__ERR_LOCK_EXPIRED(fs, token) \
123 (SVN_ERR_FS_LOCK_EXPIRED, 0, \
124 _("Lock has expired: lock-token '%s' in filesystem '%s'"), \
127 /* FS is of type "svn fs_t *". */
128 #define SVN_FS__ERR_NO_USER(fs) \
130 (SVN_ERR_FS_NO_USER, 0, \
131 _("No username is currently associated with filesystem '%s'"), \
134 /* SVN_FS__ERR_LOCK_OWNER_MISMATCH: trying to use a lock whose
135 LOCK_OWNER doesn't match the USERNAME associated with FS.
136 FS is of type "svn fs_t *". */
137 #define SVN_FS__ERR_LOCK_OWNER_MISMATCH(fs, username, lock_owner) \
139 (SVN_ERR_FS_LOCK_OWNER_MISMATCH, 0, \
140 _("User '%s' is trying to use a lock owned by '%s' in " \
141 "filesystem '%s'"), \
142 username, lock_owner, fs->path)
144 /* Return a NULL-terminated copy of the first component of PATH,
145 allocated in POOL. If path is empty, or consists entirely of
146 slashes, return the empty string.
148 If the component is followed by one or more slashes, we set *NEXT_P
149 to point after the slashes. If the component ends PATH, we set
150 *NEXT_P to zero. This means:
151 - If *NEXT_P is zero, then the component ends the PATH, and there
152 are no trailing slashes in the path.
153 - If *NEXT_P points at PATH's terminating NULL character, then
154 the component returned was the last, and PATH ends with one or more
156 - Otherwise, *NEXT_P points to the beginning of the next component
157 of PATH. You can pass this value to next_entry_name to extract
158 the next component. */
160 svn_fs__next_entry_name(const char **next_p
,
166 #endif /* __cplusplus */
168 #endif /* SVN_FS_UTIL_H */