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"
36 #endif /* __cplusplus */
38 /* Returns whether PATH is in canonical form as defined by
39 svn_fs__canonicalize_abspath().
42 svn_fs__is_canonical_abspath(const char *path);
44 /* Return a canonicalized version of a filesystem PATH, allocated in POOL.
46 While the filesystem API is pretty flexible about the incoming paths
47 (they must be UTF-8 with '/' as separators, but they don't have to
48 begin with '/', and multiple contiguous '/'s are ignored) we want any
49 paths that are physically stored in the underlying database to look
50 consistent. Specifically, absolute filesystem paths should begin with
51 '/', and all redundant and trailing '/' characters be removed.
53 This is similar to svn_fspath__canonicalize() but doesn't treat "."
57 svn_fs__canonicalize_abspath(const char *path, apr_pool_t *pool);
59 /* If EXPECT_OPEN, verify that FS refers to an open database;
60 otherwise, verify that FS refers to an unopened database. Return
61 an appropriate error if the expectation fails to match the
64 svn_fs__check_fs(svn_fs_t *fs, svn_boolean_t expect_open);
66 /* An identifier for FS to be used in the text of error messages.
67 (Not used anywhere but in this header.)
69 Note: we log the UUID, rather than (fs)->path, since some of these
70 errors are marshalled to the client. */
71 #define svn_fs__identifier(fs) ((fs)->uuid)
73 /* Constructing nice error messages for roots. */
75 /* Build an SVN_ERR_FS_NOT_FOUND error, with a detailed error text,
76 for PATH in ROOT. ROOT is of type svn_fs_root_t *. */
77 #define SVN_FS__NOT_FOUND(root, path) ( \
80 (SVN_ERR_FS_NOT_FOUND, 0, \
81 _("File not found: transaction '%s', path '%s'"), \
85 (SVN_ERR_FS_NOT_FOUND, 0, \
86 _("File not found: revision %ld, path '%s'"), \
91 /* Build a detailed `file already exists' message for PATH in ROOT.
92 ROOT is of type svn_fs_root_t *. */
93 #define SVN_FS__ALREADY_EXISTS(root, path_str) ( \
96 (SVN_ERR_FS_ALREADY_EXISTS, 0, \
97 _("File already exists: filesystem '%s', transaction '%s', path '%s'"), \
98 svn_fs__identifier(root->fs), root->txn, path_str) \
101 (SVN_ERR_FS_ALREADY_EXISTS, 0, \
102 _("File already exists: filesystem '%s', revision %ld, path '%s'"), \
103 svn_fs__identifier(root->fs), root->rev, path_str) \
106 /* ROOT is of type svn_fs_root_t *. */
107 #define SVN_FS__NOT_TXN(root) \
109 (SVN_ERR_FS_NOT_TXN_ROOT, NULL, \
110 _("Root object must be a transaction root"))
112 /* SVN_FS__ERR_NOT_MUTABLE: the caller attempted to change a node
113 outside of a transaction. FS is of type "svn_fs_t *". */
114 #define SVN_FS__ERR_NOT_MUTABLE(fs, rev, path_in_repo) \
116 SVN_ERR_FS_NOT_MUTABLE, 0, \
117 _("File is not mutable: filesystem '%s', revision %ld, path '%s'"), \
118 svn_fs__identifier(fs), rev, path_in_repo)
120 /* FS is of type "svn_fs_t *".*/
121 #define SVN_FS__ERR_NOT_DIRECTORY(fs, path_in_repo) \
123 SVN_ERR_FS_NOT_DIRECTORY, 0, \
124 _("'%s' is not a directory in filesystem '%s'"), \
125 path_in_repo, svn_fs__identifier(fs))
127 /* FS is of type "svn_fs_t *". */
128 #define SVN_FS__ERR_NOT_FILE(fs, path_in_repo) \
130 SVN_ERR_FS_NOT_FILE, 0, \
131 _("'%s' is not a file in filesystem '%s'"), \
132 path_in_repo, svn_fs__identifier(fs))
135 /* FS is of type "svn_fs_t *", LOCK is of type "svn_lock_t *". */
136 #define SVN_FS__ERR_PATH_ALREADY_LOCKED(fs, lock) \
138 SVN_ERR_FS_PATH_ALREADY_LOCKED, 0, \
139 _("Path '%s' is already locked by user '%s' in filesystem '%s'"), \
140 (lock)->path, (lock)->owner, svn_fs__identifier(fs))
142 /* FS is of type "svn_fs_t *". */
143 #define SVN_FS__ERR_NO_SUCH_LOCK(fs, path_in_repo) \
145 SVN_ERR_FS_NO_SUCH_LOCK, 0, \
146 _("No lock on path '%s' in filesystem '%s'"), \
147 path_in_repo, svn_fs__identifier(fs))
149 /* FS is of type "svn_fs_t *". */
150 #define SVN_FS__ERR_LOCK_EXPIRED(fs, token) \
152 SVN_ERR_FS_LOCK_EXPIRED, 0, \
153 _("Lock has expired: lock-token '%s' in filesystem '%s'"), \
154 token, svn_fs__identifier(fs))
156 /* FS is of type "svn_fs_t *". */
157 #define SVN_FS__ERR_NO_USER(fs) \
159 SVN_ERR_FS_NO_USER, 0, \
160 _("No username is currently associated with filesystem '%s'"), \
161 svn_fs__identifier(fs))
163 /* SVN_FS__ERR_LOCK_OWNER_MISMATCH: trying to use a lock whose
164 LOCK_OWNER doesn't match the USERNAME associated with FS.
165 FS is of type "svn_fs_t *". */
166 #define SVN_FS__ERR_LOCK_OWNER_MISMATCH(fs, username, lock_owner) \
168 SVN_ERR_FS_LOCK_OWNER_MISMATCH, 0, \
169 _("User '%s' is trying to use a lock owned by '%s' in " \
170 "filesystem '%s'"), \
171 username, lock_owner, svn_fs__identifier(fs))
173 /* Return a NULL-terminated copy of the first component of PATH,
174 allocated in POOL. If path is empty, or consists entirely of
175 slashes, return the empty string.
177 If the component is followed by one or more slashes, we set *NEXT_P
178 to point after the slashes. If the component ends PATH, we set
179 *NEXT_P to zero. This means:
180 - If *NEXT_P is zero, then the component ends the PATH, and there
181 are no trailing slashes in the path.
182 - If *NEXT_P points at PATH's terminating NULL character, then
183 the component returned was the last, and PATH ends with one or more
185 - Otherwise, *NEXT_P points to the beginning of the next component
186 of PATH. You can pass this value to next_entry_name to extract
187 the next component. */
189 svn_fs__next_entry_name(const char **next_p,
193 /* Allocate an svn_fs_path_change2_t structure in POOL, initialize and
196 Set the node_rev_id field of the created struct to NODE_REV_ID, and
197 change_kind to CHANGE_KIND. Set all other fields to their _unknown,
198 NULL or invalid value, respectively. */
199 svn_fs_path_change2_t *
200 svn_fs__path_change_create_internal(const svn_fs_id_t *node_rev_id,
201 svn_fs_path_change_kind_t change_kind,
204 /* Append REL_PATH (which may contain slashes) to each path that exists in
205 the mergeinfo INPUT, and return a new mergeinfo in *OUTPUT. Deep
206 copies the values. Perform all allocations in POOL. */
208 svn_fs__append_to_merged_froms(svn_mergeinfo_t *output,
209 svn_mergeinfo_t input,
210 const char *rel_path,
215 #endif /* __cplusplus */
217 #endif /* SVN_FS_UTIL_H */