3 * ====================================================================
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
20 * ====================================================================
23 * @file svn_client_private.h
24 * @brief Subversion-internal client APIs.
27 #ifndef SVN_CLIENT_PRIVATE_H
28 #define SVN_CLIENT_PRIVATE_H
30 #include <apr_pools.h>
33 #include "svn_client.h"
34 #include "svn_types.h"
36 #include "private/svn_diff_tree.h"
40 #endif /* __cplusplus */
43 /* Set *REVNUM to the revision number identified by REVISION.
45 If REVISION->kind is svn_opt_revision_number, just use
46 REVISION->value.number, ignoring LOCAL_ABSPATH and RA_SESSION.
48 Else if REVISION->kind is svn_opt_revision_committed,
49 svn_opt_revision_previous, or svn_opt_revision_base, or
50 svn_opt_revision_working, then the revision can be identified
51 purely based on the working copy's administrative information for
52 LOCAL_ABSPATH, so RA_SESSION is ignored. If LOCAL_ABSPATH is not
53 under revision control, return SVN_ERR_UNVERSIONED_RESOURCE, or if
54 LOCAL_ABSPATH is null, return SVN_ERR_CLIENT_VERSIONED_PATH_REQUIRED.
56 Else if REVISION->kind is svn_opt_revision_date or
57 svn_opt_revision_head, then RA_SESSION is used to retrieve the
58 revision from the repository (using REVISION->value.date in the
59 former case), and LOCAL_ABSPATH is ignored. If RA_SESSION is null,
60 return SVN_ERR_CLIENT_RA_ACCESS_REQUIRED.
62 Else if REVISION->kind is svn_opt_revision_unspecified, set
63 *REVNUM to SVN_INVALID_REVNUM.
65 If YOUNGEST_REV is non-NULL, it is an in/out parameter. If
66 *YOUNGEST_REV is valid, use it as the youngest revision in the
67 repository (regardless of reality) -- don't bother to lookup the
68 true value for HEAD, and don't return any value in *REVNUM greater
69 than *YOUNGEST_REV. If *YOUNGEST_REV is not valid, and a HEAD
70 lookup is required to populate *REVNUM, then also populate
71 *YOUNGEST_REV with the result. This is useful for making multiple
72 serialized calls to this function with a basically static view of
73 the repository, avoiding race conditions which could occur between
74 multiple invocations with HEAD lookup requests.
76 Else return SVN_ERR_CLIENT_BAD_REVISION.
78 Use SCRATCH_POOL for any temporary allocation. */
80 svn_client__get_revision_number(svn_revnum_t *revnum,
81 svn_revnum_t *youngest_rev,
82 svn_wc_context_t *wc_ctx,
83 const char *local_abspath,
84 svn_ra_session_t *ra_session,
85 const svn_opt_revision_t *revision,
86 apr_pool_t *scratch_pool);
88 /* Return true if KIND is a revision kind that is dependent on the working
89 * copy. Otherwise, return false. */
90 #define SVN_CLIENT__REVKIND_NEEDS_WC(kind) \
91 ((kind) == svn_opt_revision_base || \
92 (kind) == svn_opt_revision_previous || \
93 (kind) == svn_opt_revision_working || \
94 (kind) == svn_opt_revision_committed) \
96 /* Return true if KIND is a revision kind that the WC can supply without
97 * contacting the repository. Otherwise, return false. */
98 #define SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(kind) \
99 ((kind) == svn_opt_revision_base || \
100 (kind) == svn_opt_revision_working || \
101 (kind) == svn_opt_revision_committed)
103 /* A location in a repository. */
104 typedef struct svn_client__pathrev_t
106 const char *repos_root_url;
107 const char *repos_uuid;
110 } svn_client__pathrev_t;
112 /* Return a new path-rev structure, allocated in RESULT_POOL,
113 * initialized with deep copies of REPOS_ROOT_URL, REPOS_UUID, REV and URL. */
114 svn_client__pathrev_t *
115 svn_client__pathrev_create(const char *repos_root_url,
116 const char *repos_uuid,
119 apr_pool_t *result_pool);
121 /* Return a new path-rev structure, allocated in RESULT_POOL,
122 * initialized with deep copies of REPOS_ROOT_URL, REPOS_UUID, and REV,
123 * and using the repository-relative RELPATH to construct the URL. */
124 svn_client__pathrev_t *
125 svn_client__pathrev_create_with_relpath(const char *repos_root_url,
126 const char *repos_uuid,
129 apr_pool_t *result_pool);
131 /* Set *PATHREV_P to a new path-rev structure, allocated in RESULT_POOL,
132 * initialized with deep copies of the repository root URL and UUID from
133 * RA_SESSION, and of REV and URL. */
135 svn_client__pathrev_create_with_session(svn_client__pathrev_t **pathrev_p,
136 svn_ra_session_t *ra_session,
139 apr_pool_t *result_pool);
141 /* Return a deep copy of PATHREV, allocated in RESULT_POOL. */
142 svn_client__pathrev_t *
143 svn_client__pathrev_dup(const svn_client__pathrev_t *pathrev,
144 apr_pool_t *result_pool);
146 /* Return a deep copy of PATHREV, with a URI-encoded representation of
147 * RELPATH joined on to the URL. Allocate the result in RESULT_POOL. */
148 svn_client__pathrev_t *
149 svn_client__pathrev_join_relpath(const svn_client__pathrev_t *pathrev,
151 apr_pool_t *result_pool);
153 /* Return the repository-relative relpath of PATHREV. */
155 svn_client__pathrev_relpath(const svn_client__pathrev_t *pathrev,
156 apr_pool_t *result_pool);
158 /* Return the repository-relative fspath of PATHREV. */
160 svn_client__pathrev_fspath(const svn_client__pathrev_t *pathrev,
161 apr_pool_t *result_pool);
163 /* Given PATH_OR_URL, which contains either a working copy path or an
164 absolute URL, a peg revision PEG_REVISION, and a desired revision
165 REVISION, create an RA connection to that object as it exists in
166 that revision, following copy history if necessary. If REVISION is
167 younger than PEG_REVISION, then PATH_OR_URL will be checked to see
168 that it is the same node in both PEG_REVISION and REVISION. If it
169 is not, then @c SVN_ERR_CLIENT_UNRELATED_RESOURCES is returned.
171 BASE_DIR_ABSPATH is the working copy path the ra_session corresponds
172 to. If provided it will be used to read and dav props. So if provided
173 this directory MUST match the session anchor.
175 If PEG_REVISION->kind is 'unspecified', the peg revision is 'head'
176 for a URL or 'working' for a WC path. If REVISION->kind is
177 'unspecified', the operative revision is the peg revision.
179 Store the resulting ra_session in *RA_SESSION_P. Store the final
180 resolved location of the object in *RESOLVED_LOC_P. RESOLVED_LOC_P
181 may be NULL if not wanted.
183 Use authentication baton cached in CTX to authenticate against the
186 Use POOL for all allocations. */
188 svn_client__ra_session_from_path2(svn_ra_session_t **ra_session_p,
189 svn_client__pathrev_t **resolved_loc_p,
190 const char *path_or_url,
191 const char *base_dir_abspath,
192 const svn_opt_revision_t *peg_revision,
193 const svn_opt_revision_t *revision,
194 svn_client_ctx_t *ctx,
197 /* Given PATH_OR_URL, which contains either a working copy path or an
198 absolute URL, a peg revision PEG_REVISION, and a desired revision
199 REVISION, find the path at which that object exists in REVISION,
200 following copy history if necessary. If REVISION is younger than
201 PEG_REVISION, then check that PATH_OR_URL is the same node in both
202 PEG_REVISION and REVISION, and return @c
203 SVN_ERR_CLIENT_UNRELATED_RESOURCES if it is not the same node.
205 If PEG_REVISION->kind is 'unspecified', the peg revision is 'head'
206 for a URL or 'working' for a WC path. If REVISION->kind is
207 'unspecified', the operative revision is the peg revision.
209 Store the actual location of the object in *RESOLVED_LOC_P.
211 RA_SESSION should be an open RA session pointing at the URL of
212 PATH_OR_URL, or NULL, in which case this function will open its own
215 Use authentication baton cached in CTX to authenticate against the
218 Use POOL for all allocations. */
220 svn_client__resolve_rev_and_url(svn_client__pathrev_t **resolved_loc_p,
221 svn_ra_session_t *ra_session,
222 const char *path_or_url,
223 const svn_opt_revision_t *peg_revision,
224 const svn_opt_revision_t *revision,
225 svn_client_ctx_t *ctx,
228 /** Return @c SVN_ERR_ILLEGAL_TARGET if TARGETS contains a mixture of
229 * URLs and paths; otherwise return SVN_NO_ERROR.
234 svn_client__assert_homogeneous_target_type(const apr_array_header_t *targets);
237 /* Create a svn_client_status_t structure *CST for LOCAL_ABSPATH, shallow
238 * copying data from *STATUS wherever possible and retrieving the other values
239 * where needed. Perform temporary allocations in SCRATCH_POOL and allocate the
240 * result in RESULT_POOL
243 svn_client__create_status(svn_client_status_t **cst,
244 svn_wc_context_t *wc_ctx,
245 const char *local_abspath,
246 const svn_wc_status3_t *status,
247 apr_pool_t *result_pool,
248 apr_pool_t *scratch_pool);
250 /* Get the repository location of the base node at LOCAL_ABSPATH.
252 * A pathrev_t wrapper around svn_wc__node_get_base().
254 * Set *BASE_P to the location that this node was checked out at or last
255 * updated/switched to, regardless of any uncommitted changes (delete,
256 * replace and/or copy-here/move-here).
258 * If there is no base node at LOCAL_ABSPATH (such as when there is a
259 * locally added/copied/moved-here node that is not part of a replace),
260 * set *BASE_P to NULL.
263 svn_client__wc_node_get_base(svn_client__pathrev_t **base_p,
264 const char *wc_abspath,
265 svn_wc_context_t *wc_ctx,
266 apr_pool_t *result_pool,
267 apr_pool_t *scratch_pool);
269 /* Get the original location of the WC node at LOCAL_ABSPATH.
271 * A pathrev_t wrapper around svn_wc__node_get_origin().
273 * Set *ORIGIN_P to the origin of the WC node at WC_ABSPATH. If the node
274 * is a local copy, give the copy-from location. If the node is locally
275 * added or deleted, set *ORIGIN_P to NULL.
278 svn_client__wc_node_get_origin(svn_client__pathrev_t **origin_p,
279 const char *wc_abspath,
280 svn_client_ctx_t *ctx,
281 apr_pool_t *result_pool,
282 apr_pool_t *scratch_pool);
284 /* Copy the file or directory on URL in some repository to DST_ABSPATH,
285 * copying node information and properties. Resolve URL using PEG_REV and
288 * If URL specifies a directory, create the copy using depth DEPTH.
290 * If MAKE_PARENTS is TRUE and DST_ABSPATH doesn't have an added parent
291 * create missing parent directories
294 svn_client__copy_foreign(const char *url,
295 const char *dst_abspath,
296 svn_opt_revision_t *peg_revision,
297 svn_opt_revision_t *revision,
299 svn_boolean_t make_parents,
300 svn_boolean_t already_locked,
301 svn_client_ctx_t *ctx,
302 apr_pool_t *scratch_pool);
304 /* Same as the public svn_client_mergeinfo_log2 API, except for the addition
305 * of the TARGET_MERGEINFO_CATALOG and RESULT_POOL parameters.
307 * If TARGET_MERGEINFO_CATALOG is NULL then this acts exactly as the public
308 * API. If *TARGET_MERGEINFO_CATALOG is NULL, then *TARGET_MERGEINFO_CATALOG
309 * is set to the a mergeinfo catalog representing the mergeinfo on
310 * TARGET_PATH_OR_URL@TARGET_PEG_REVISION at DEPTH, (like the public API only
311 * depths of svn_depth_empty or svn_depth_infinity are supported) allocated in
312 * RESULT_POOL. Finally, if *TARGET_MERGEINFO_CATALOG is non-NULL, then it is
313 * assumed to be a mergeinfo catalog representing the mergeinfo on
314 * TARGET_PATH_OR_URL@TARGET_PEG_REVISION at DEPTH.
316 * The keys for the subtree mergeinfo are the repository root-relative
317 * paths of TARGET_PATH_OR_URL and/or its subtrees, regardless of whether
318 * TARGET_PATH_OR_URL is a URL or WC path.
320 * If RA_SESSION is not NULL, use it to obtain merge information instead of
321 * opening a new session. The session might be reparented after usage, so
322 * callers should reparent the session back to their original location if
326 svn_client__mergeinfo_log(svn_boolean_t finding_merged,
327 const char *target_path_or_url,
328 const svn_opt_revision_t *target_peg_revision,
329 svn_mergeinfo_catalog_t *target_mergeinfo_catalog,
330 const char *source_path_or_url,
331 const svn_opt_revision_t *source_peg_revision,
332 const svn_opt_revision_t *source_start_revision,
333 const svn_opt_revision_t *source_end_revision,
334 svn_log_entry_receiver_t log_receiver,
335 void *log_receiver_baton,
336 svn_boolean_t discover_changed_paths,
338 const apr_array_header_t *revprops,
339 svn_client_ctx_t *ctx,
340 svn_ra_session_t *ra_session,
341 apr_pool_t *result_pool,
342 apr_pool_t *scratch_pool);
346 #endif /* __cplusplus */
348 #endif /* SVN_CLIENT_PRIVATE_H */