2 * svn_fs_util.h: Declarations for the APIs of libsvn_fs_util to be
3 * consumed by only fs_* libs.
5 * ====================================================================
6 * Licensed to the Apache Software Foundation (ASF) under one
7 * or more contributor license agreements. See the NOTICE file
8 * distributed with this work for additional information
9 * regarding copyright ownership. The ASF licenses this file
10 * to you under the Apache License, Version 2.0 (the
11 * "License"); you may not use this file except in compliance
12 * with the License. You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an
18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 * KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations
22 * ====================================================================
28 #include <apr_pools.h>
30 #include "svn_types.h"
31 #include "svn_error.h"
32 #include "svn_version.h"
37 #endif /* __cplusplus */
39 /* Get libsvn_fs_util version information. */
41 svn_fs_util__version(void);
43 /* Returns whether PATH is in canonical form as defined by
44 svn_fs__canonicalize_abspath().
47 svn_fs__is_canonical_abspath(const char *path);
49 /* Return a canonicalized version of a filesystem PATH, allocated in POOL.
51 While the filesystem API is pretty flexible about the incoming paths
52 (they must be UTF-8 with '/' as separators, but they don't have to
53 begin with '/', and multiple contiguous '/'s are ignored) we want any
54 paths that are physically stored in the underlying database to look
55 consistent. Specifically, absolute filesystem paths should begin with
56 '/', and all redundant and trailing '/' characters be removed.
58 This is similar to svn_fspath__canonicalize() but doesn't treat "."
62 svn_fs__canonicalize_abspath(const char *path, apr_pool_t *pool);
64 /* If EXPECT_OPEN, verify that FS refers to an open database;
65 otherwise, verify that FS refers to an unopened database. Return
66 an appropriate error if the expectation fails to match the
69 svn_fs__check_fs(svn_fs_t *fs, svn_boolean_t expect_open);
71 /* An identifier for FS to be used in the text of error messages.
72 (Not used anywhere but in this header.)
74 Note: we log the UUID, rather than (fs)->path, since some of these
75 errors are marshalled to the client. */
76 #define svn_fs__identifier(fs) ((fs)->uuid)
78 /* Constructing nice error messages for roots. */
80 /* Build an SVN_ERR_FS_NOT_FOUND error, with a detailed error text,
81 for PATH in ROOT. ROOT is of type svn_fs_root_t *. */
82 #define SVN_FS__NOT_FOUND(root, path) ( \
85 (SVN_ERR_FS_NOT_FOUND, 0, \
86 _("File not found: transaction '%s', path '%s'"), \
90 (SVN_ERR_FS_NOT_FOUND, 0, \
91 _("File not found: revision %ld, path '%s'"), \
96 /* Build a detailed `file already exists' message for PATH in ROOT.
97 ROOT is of type svn_fs_root_t *. */
98 #define SVN_FS__ALREADY_EXISTS(root, path_str) ( \
101 (SVN_ERR_FS_ALREADY_EXISTS, 0, \
102 _("File already exists: filesystem '%s', transaction '%s', path '%s'"), \
103 svn_fs__identifier(root->fs), root->txn, path_str) \
106 (SVN_ERR_FS_ALREADY_EXISTS, 0, \
107 _("File already exists: filesystem '%s', revision %ld, path '%s'"), \
108 svn_fs__identifier(root->fs), root->rev, path_str) \
111 /* ROOT is of type svn_fs_root_t *. */
112 #define SVN_FS__NOT_TXN(root) \
114 (SVN_ERR_FS_NOT_TXN_ROOT, NULL, \
115 _("Root object must be a transaction root"))
117 /* SVN_FS__ERR_NOT_MUTABLE: the caller attempted to change a node
118 outside of a transaction. FS is of type "svn_fs_t *". */
119 #define SVN_FS__ERR_NOT_MUTABLE(fs, rev, path_in_repo) \
121 SVN_ERR_FS_NOT_MUTABLE, 0, \
122 _("File is not mutable: filesystem '%s', revision %ld, path '%s'"), \
123 svn_fs__identifier(fs), rev, path_in_repo)
125 /* FS is of type "svn_fs_t *".*/
126 #define SVN_FS__ERR_NOT_DIRECTORY(fs, path_in_repo) \
128 SVN_ERR_FS_NOT_DIRECTORY, 0, \
129 _("'%s' is not a directory in filesystem '%s'"), \
130 path_in_repo, svn_fs__identifier(fs))
132 /* FS is of type "svn_fs_t *". */
133 #define SVN_FS__ERR_NOT_FILE(fs, path_in_repo) \
135 SVN_ERR_FS_NOT_FILE, 0, \
136 _("'%s' is not a file in filesystem '%s'"), \
137 path_in_repo, svn_fs__identifier(fs))
140 /* FS is of type "svn_fs_t *", LOCK is of type "svn_lock_t *". */
141 #define SVN_FS__ERR_PATH_ALREADY_LOCKED(fs, lock) \
143 SVN_ERR_FS_PATH_ALREADY_LOCKED, 0, \
144 _("Path '%s' is already locked by user '%s' in filesystem '%s'"), \
145 (lock)->path, (lock)->owner, svn_fs__identifier(fs))
147 /* FS is of type "svn_fs_t *". */
148 #define SVN_FS__ERR_NO_SUCH_LOCK(fs, path_in_repo) \
150 SVN_ERR_FS_NO_SUCH_LOCK, 0, \
151 _("No lock on path '%s' in filesystem '%s'"), \
152 path_in_repo, svn_fs__identifier(fs))
154 /* FS is of type "svn_fs_t *". */
155 #define SVN_FS__ERR_LOCK_EXPIRED(fs, token) \
157 SVN_ERR_FS_LOCK_EXPIRED, 0, \
158 _("Lock has expired: lock-token '%s' in filesystem '%s'"), \
159 token, svn_fs__identifier(fs))
161 /* FS is of type "svn_fs_t *". */
162 #define SVN_FS__ERR_NO_USER(fs) \
164 SVN_ERR_FS_NO_USER, 0, \
165 _("No username is currently associated with filesystem '%s'"), \
166 svn_fs__identifier(fs))
168 /* SVN_FS__ERR_LOCK_OWNER_MISMATCH: trying to use a lock whose
169 LOCK_OWNER doesn't match the USERNAME associated with FS.
170 FS is of type "svn_fs_t *". */
171 #define SVN_FS__ERR_LOCK_OWNER_MISMATCH(fs, username, lock_owner) \
173 SVN_ERR_FS_LOCK_OWNER_MISMATCH, 0, \
174 _("User '%s' is trying to use a lock owned by '%s' in " \
175 "filesystem '%s'"), \
176 username, lock_owner, svn_fs__identifier(fs))
178 /* Return a NULL-terminated copy of the first component of PATH,
179 allocated in POOL. If path is empty, or consists entirely of
180 slashes, return the empty string.
182 If the component is followed by one or more slashes, we set *NEXT_P
183 to point after the slashes. If the component ends PATH, we set
184 *NEXT_P to zero. This means:
185 - If *NEXT_P is zero, then the component ends the PATH, and there
186 are no trailing slashes in the path.
187 - If *NEXT_P points at PATH's terminating NULL character, then
188 the component returned was the last, and PATH ends with one or more
190 - Otherwise, *NEXT_P points to the beginning of the next component
191 of PATH. You can pass this value to next_entry_name to extract
192 the next component. */
194 svn_fs__next_entry_name(const char **next_p,
198 /* Allocate an svn_fs_path_change2_t structure in POOL, initialize and
201 Set the node_rev_id field of the created struct to NODE_REV_ID, and
202 change_kind to CHANGE_KIND. Set all other fields to their _unknown,
203 NULL or invalid value, respectively. */
204 svn_fs_path_change2_t *
205 svn_fs__path_change_create_internal(const svn_fs_id_t *node_rev_id,
206 svn_fs_path_change_kind_t change_kind,
209 /* Allocate an svn_fs_path_change3_t structure in RESULT_POOL, initialize
212 Set the change_kind to CHANGE_KIND. Set all other fields to their
213 _unknown, NULL or invalid value, respectively. */
214 svn_fs_path_change3_t *
215 svn_fs__path_change_create_internal2(svn_fs_path_change_kind_t change_kind,
216 apr_pool_t *result_pool);
218 /* Append REL_PATH (which may contain slashes) to each path that exists in
219 the mergeinfo INPUT, and return a new mergeinfo in *OUTPUT. Deep
220 copies the values. Perform all allocations in POOL. */
222 svn_fs__append_to_merged_froms(svn_mergeinfo_t *output,
223 svn_mergeinfo_t input,
224 const char *rel_path,
227 /* Given the FS creation options in CONFIG, return the oldest version that
228 we shall be compatible with in *COMPATIBLE_VERSION. The patch level
229 is always set to 0 and the tag to "". Allocate the result in POOL.
231 Note that the result will always be compatible to the current tool
232 version, i.e. will be a version number not more recent than this tool. */
234 svn_fs__compatible_version(svn_version_t **compatible_version,
238 /* Compare the property lists A and B using POOL for temporary allocations.
239 Return true iff both lists contain the same properties with the same
240 values. A and B may be NULL in which case they will be equal to and
243 svn_fs__prop_lists_equal(apr_hash_t *a,
249 #endif /* __cplusplus */
251 #endif /* SVN_FS_UTIL_H */