]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/include/private/svn_fs_util.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / include / private / svn_fs_util.h
1 /*
2  * svn_fs_util.h: Declarations for the APIs of libsvn_fs_util to be
3  * consumed by only fs_* libs.
4  *
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
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
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
21  *    under the License.
22  * ====================================================================
23  */
24
25 #ifndef SVN_FS_UTIL_H
26 #define SVN_FS_UTIL_H
27
28 #include <apr_pools.h>
29
30 #include "svn_types.h"
31 #include "svn_error.h"
32 #include "svn_fs.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
37
38 /* Returns whether PATH is in canonical form as defined by
39    svn_fs__canonicalize_abspath().
40  */
41 svn_boolean_t
42 svn_fs__is_canonical_abspath(const char *path);
43
44 /* Return a canonicalized version of a filesystem PATH, allocated in POOL.
45
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.
52
53    This is similar to svn_fspath__canonicalize() but doesn't treat "."
54    segments as special.
55 */
56 const char *
57 svn_fs__canonicalize_abspath(const char *path, apr_pool_t *pool);
58
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
62    reality.  */
63 svn_error_t *
64 svn_fs__check_fs(svn_fs_t *fs, svn_boolean_t expect_open);
65
66 /* An identifier for FS to be used in the text of error messages.
67    (Not used anywhere but in this header.)
68
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)
72
73 /* Constructing nice error messages for roots.  */
74
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) (                        \
78   root->is_txn_root ?                                          \
79     svn_error_createf                                          \
80       (SVN_ERR_FS_NOT_FOUND, 0,                                \
81        _("File not found: transaction '%s', path '%s'"),       \
82        root->txn, path)                                        \
83   :                                                            \
84     svn_error_createf                                          \
85       (SVN_ERR_FS_NOT_FOUND, 0,                                \
86        _("File not found: revision %ld, path '%s'"),           \
87        root->rev, path)                                        \
88   )
89
90
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) (                               \
94   root->is_txn_root ?                                                          \
95     svn_error_createf                                                          \
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)      \
99   :                                                                            \
100     svn_error_createf                                                          \
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)      \
104   )
105
106 /* ROOT is of type svn_fs_root_t *. */
107 #define SVN_FS__NOT_TXN(root)                         \
108   svn_error_create                                    \
109     (SVN_ERR_FS_NOT_TXN_ROOT, NULL,                   \
110      _("Root object must be a transaction root"))
111
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)                   \
115   svn_error_createf(                                                     \
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)
119
120 /* FS is of type "svn_fs_t *".*/
121 #define SVN_FS__ERR_NOT_DIRECTORY(fs, path_in_repo)               \
122   svn_error_createf(                                              \
123      SVN_ERR_FS_NOT_DIRECTORY, 0,                                 \
124      _("'%s' is not a directory in filesystem '%s'"),             \
125      path_in_repo, svn_fs__identifier(fs))
126
127 /* FS is of type "svn_fs_t *".   */
128 #define SVN_FS__ERR_NOT_FILE(fs, path_in_repo)                    \
129   svn_error_createf(                                              \
130      SVN_ERR_FS_NOT_FILE, 0,                                      \
131      _("'%s' is not a file in filesystem '%s'"),                  \
132      path_in_repo, svn_fs__identifier(fs))
133
134
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)                           \
137   svn_error_createf(                                                        \
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))
141
142 /* FS is of type "svn_fs_t *". */
143 #define SVN_FS__ERR_NO_SUCH_LOCK(fs, path_in_repo)                \
144   svn_error_createf(                                              \
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))
148
149 /* FS is of type "svn_fs_t *". */
150 #define SVN_FS__ERR_LOCK_EXPIRED(fs, token)                      \
151   svn_error_createf(                                             \
152      SVN_ERR_FS_LOCK_EXPIRED, 0,                                 \
153      _("Lock has expired: lock-token '%s' in filesystem '%s'"),  \
154      token, svn_fs__identifier(fs))
155
156 /* FS is of type "svn_fs_t *". */
157 #define SVN_FS__ERR_NO_USER(fs)                                     \
158   svn_error_createf(                                                \
159      SVN_ERR_FS_NO_USER, 0,                                         \
160      _("No username is currently associated with filesystem '%s'"), \
161      svn_fs__identifier(fs))
162
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)       \
167   svn_error_createf(                                                    \
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))
172
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.
176
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
184      slash characters.
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. */
188 char *
189 svn_fs__next_entry_name(const char **next_p,
190                         const char *path,
191                         apr_pool_t *pool);
192
193 /* Allocate an svn_fs_path_change2_t structure in POOL, initialize and
194    return it.
195
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,
202                                     apr_pool_t *pool);
203
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. */
207 svn_error_t *
208 svn_fs__append_to_merged_froms(svn_mergeinfo_t *output,
209                                svn_mergeinfo_t input,
210                                const char *rel_path,
211                                apr_pool_t *pool);
212
213 #ifdef __cplusplus
214 }
215 #endif /* __cplusplus */
216
217 #endif /* SVN_FS_UTIL_H */