1251881Speter/**
2251881Speter * @copyright
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter * @endcopyright
22251881Speter *
23251881Speter * @file svn_client_private.h
24251881Speter * @brief Subversion-internal client APIs.
25251881Speter */
26251881Speter
27251881Speter#ifndef SVN_CLIENT_PRIVATE_H
28251881Speter#define SVN_CLIENT_PRIVATE_H
29251881Speter
30251881Speter#include <apr_pools.h>
31251881Speter
32251881Speter#include "svn_ra.h"
33251881Speter#include "svn_client.h"
34251881Speter#include "svn_types.h"
35251881Speter
36251881Speter#ifdef __cplusplus
37251881Speterextern "C" {
38251881Speter#endif /* __cplusplus */
39251881Speter
40251881Speter
41251881Speter/* Return true if KIND is a revision kind that is dependent on the working
42251881Speter * copy. Otherwise, return false. */
43251881Speter#define SVN_CLIENT__REVKIND_NEEDS_WC(kind)                                 \
44251881Speter  ((kind) == svn_opt_revision_base ||                                      \
45251881Speter   (kind) == svn_opt_revision_previous ||                                  \
46251881Speter   (kind) == svn_opt_revision_working ||                                   \
47251881Speter   (kind) == svn_opt_revision_committed)                                   \
48251881Speter
49251881Speter/* Return true if KIND is a revision kind that the WC can supply without
50251881Speter * contacting the repository. Otherwise, return false. */
51251881Speter#define SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(kind)                           \
52251881Speter  ((kind) == svn_opt_revision_base ||                                      \
53251881Speter   (kind) == svn_opt_revision_working ||                                   \
54251881Speter   (kind) == svn_opt_revision_committed)
55251881Speter
56251881Speter/* A location in a repository. */
57251881Spetertypedef struct svn_client__pathrev_t
58251881Speter{
59251881Speter  const char *repos_root_url;
60251881Speter  const char *repos_uuid;
61251881Speter  svn_revnum_t rev;
62251881Speter  const char *url;
63251881Speter} svn_client__pathrev_t;
64251881Speter
65251881Speter/* Return a new path-rev structure, allocated in RESULT_POOL,
66251881Speter * initialized with deep copies of REPOS_ROOT_URL, REPOS_UUID, REV and URL. */
67251881Spetersvn_client__pathrev_t *
68251881Spetersvn_client__pathrev_create(const char *repos_root_url,
69251881Speter                           const char *repos_uuid,
70251881Speter                           svn_revnum_t rev,
71251881Speter                           const char *url,
72251881Speter                           apr_pool_t *result_pool);
73251881Speter
74251881Speter/* Return a new path-rev structure, allocated in RESULT_POOL,
75251881Speter * initialized with deep copies of REPOS_ROOT_URL, REPOS_UUID, and REV,
76251881Speter * and using the repository-relative RELPATH to construct the URL. */
77251881Spetersvn_client__pathrev_t *
78251881Spetersvn_client__pathrev_create_with_relpath(const char *repos_root_url,
79251881Speter                                        const char *repos_uuid,
80251881Speter                                        svn_revnum_t rev,
81251881Speter                                        const char *relpath,
82251881Speter                                        apr_pool_t *result_pool);
83251881Speter
84251881Speter/* Set *PATHREV_P to a new path-rev structure, allocated in RESULT_POOL,
85251881Speter * initialized with deep copies of the repository root URL and UUID from
86251881Speter * RA_SESSION, and of REV and URL. */
87251881Spetersvn_error_t *
88251881Spetersvn_client__pathrev_create_with_session(svn_client__pathrev_t **pathrev_p,
89251881Speter                                        svn_ra_session_t *ra_session,
90251881Speter                                        svn_revnum_t rev,
91251881Speter                                        const char *url,
92251881Speter                                        apr_pool_t *result_pool);
93251881Speter
94251881Speter/* Return a deep copy of PATHREV, allocated in RESULT_POOL. */
95251881Spetersvn_client__pathrev_t *
96251881Spetersvn_client__pathrev_dup(const svn_client__pathrev_t *pathrev,
97251881Speter                        apr_pool_t *result_pool);
98251881Speter
99251881Speter/* Return a deep copy of PATHREV, with a URI-encoded representation of
100251881Speter * RELPATH joined on to the URL.  Allocate the result in RESULT_POOL. */
101251881Spetersvn_client__pathrev_t *
102251881Spetersvn_client__pathrev_join_relpath(const svn_client__pathrev_t *pathrev,
103251881Speter                                 const char *relpath,
104251881Speter                                 apr_pool_t *result_pool);
105251881Speter
106251881Speter/* Return the repository-relative relpath of PATHREV. */
107251881Speterconst char *
108251881Spetersvn_client__pathrev_relpath(const svn_client__pathrev_t *pathrev,
109251881Speter                            apr_pool_t *result_pool);
110251881Speter
111251881Speter/* Return the repository-relative fspath of PATHREV. */
112251881Speterconst char *
113251881Spetersvn_client__pathrev_fspath(const svn_client__pathrev_t *pathrev,
114251881Speter                           apr_pool_t *result_pool);
115251881Speter
116251881Speter/* Given PATH_OR_URL, which contains either a working copy path or an
117251881Speter   absolute URL, a peg revision PEG_REVISION, and a desired revision
118251881Speter   REVISION, create an RA connection to that object as it exists in
119251881Speter   that revision, following copy history if necessary.  If REVISION is
120251881Speter   younger than PEG_REVISION, then PATH_OR_URL will be checked to see
121251881Speter   that it is the same node in both PEG_REVISION and REVISION.  If it
122251881Speter   is not, then @c SVN_ERR_CLIENT_UNRELATED_RESOURCES is returned.
123251881Speter
124251881Speter   BASE_DIR_ABSPATH is the working copy path the ra_session corresponds
125251881Speter   to. If provided it will be used to read and dav props. So if provided
126251881Speter   this directory MUST match the session anchor.
127251881Speter
128251881Speter   If PEG_REVISION->kind is 'unspecified', the peg revision is 'head'
129251881Speter   for a URL or 'working' for a WC path.  If REVISION->kind is
130251881Speter   'unspecified', the operative revision is the peg revision.
131251881Speter
132251881Speter   Store the resulting ra_session in *RA_SESSION_P.  Store the final
133251881Speter   resolved location of the object in *RESOLVED_LOC_P.  RESOLVED_LOC_P
134251881Speter   may be NULL if not wanted.
135251881Speter
136251881Speter   Use authentication baton cached in CTX to authenticate against the
137251881Speter   repository.
138251881Speter
139251881Speter   Use POOL for all allocations. */
140251881Spetersvn_error_t *
141251881Spetersvn_client__ra_session_from_path2(svn_ra_session_t **ra_session_p,
142251881Speter                                 svn_client__pathrev_t **resolved_loc_p,
143251881Speter                                 const char *path_or_url,
144251881Speter                                 const char *base_dir_abspath,
145251881Speter                                 const svn_opt_revision_t *peg_revision,
146251881Speter                                 const svn_opt_revision_t *revision,
147251881Speter                                 svn_client_ctx_t *ctx,
148251881Speter                                 apr_pool_t *pool);
149251881Speter
150251881Speter/* Given PATH_OR_URL, which contains either a working copy path or an
151251881Speter   absolute URL, a peg revision PEG_REVISION, and a desired revision
152251881Speter   REVISION, find the path at which that object exists in REVISION,
153251881Speter   following copy history if necessary.  If REVISION is younger than
154251881Speter   PEG_REVISION, then check that PATH_OR_URL is the same node in both
155251881Speter   PEG_REVISION and REVISION, and return @c
156251881Speter   SVN_ERR_CLIENT_UNRELATED_RESOURCES if it is not the same node.
157251881Speter
158251881Speter   If PEG_REVISION->kind is 'unspecified', the peg revision is 'head'
159251881Speter   for a URL or 'working' for a WC path.  If REVISION->kind is
160251881Speter   'unspecified', the operative revision is the peg revision.
161251881Speter
162251881Speter   Store the actual location of the object in *RESOLVED_LOC_P.
163251881Speter
164251881Speter   RA_SESSION should be an open RA session pointing at the URL of
165251881Speter   PATH_OR_URL, or NULL, in which case this function will open its own
166251881Speter   temporary session.
167251881Speter
168251881Speter   Use authentication baton cached in CTX to authenticate against the
169251881Speter   repository.
170251881Speter
171251881Speter   Use POOL for all allocations. */
172251881Spetersvn_error_t *
173251881Spetersvn_client__resolve_rev_and_url(svn_client__pathrev_t **resolved_loc_p,
174251881Speter                                svn_ra_session_t *ra_session,
175251881Speter                                const char *path_or_url,
176251881Speter                                const svn_opt_revision_t *peg_revision,
177251881Speter                                const svn_opt_revision_t *revision,
178251881Speter                                svn_client_ctx_t *ctx,
179251881Speter                                apr_pool_t *pool);
180251881Speter
181251881Speter/** Return @c SVN_ERR_ILLEGAL_TARGET if TARGETS contains a mixture of
182251881Speter * URLs and paths; otherwise return SVN_NO_ERROR.
183251881Speter *
184251881Speter * @since New in 1.7.
185251881Speter */
186251881Spetersvn_error_t *
187251881Spetersvn_client__assert_homogeneous_target_type(const apr_array_header_t *targets);
188251881Speter
189251881Speter
190251881Speter/* Create a svn_client_status_t structure *CST for LOCAL_ABSPATH, shallow
191251881Speter * copying data from *STATUS wherever possible and retrieving the other values
192251881Speter * where needed. Perform temporary allocations in SCRATCH_POOL and allocate the
193251881Speter * result in RESULT_POOL
194251881Speter */
195251881Spetersvn_error_t *
196251881Spetersvn_client__create_status(svn_client_status_t **cst,
197251881Speter                          svn_wc_context_t *wc_ctx,
198251881Speter                          const char *local_abspath,
199251881Speter                          const svn_wc_status3_t *status,
200251881Speter                          apr_pool_t *result_pool,
201251881Speter                          apr_pool_t *scratch_pool);
202251881Speter
203251881Speter/* Set *ANCESTOR_URL and *ANCESTOR_REVISION to the URL and revision,
204251881Speter * respectively, of the youngest common ancestor of the two locations
205251881Speter * PATH_OR_URL1@REV1 and PATH_OR_URL2@REV2.  Set *ANCESTOR_RELPATH to
206251881Speter * NULL and *ANCESTOR_REVISION to SVN_INVALID_REVNUM if they have no
207251881Speter * common ancestor.  This function assumes that PATH_OR_URL1@REV1 and
208251881Speter * PATH_OR_URL2@REV2 both refer to the same repository.
209251881Speter *
210251881Speter * Use the authentication baton cached in CTX to authenticate against
211251881Speter * the repository.
212251881Speter *
213251881Speter * See also svn_client__get_youngest_common_ancestor().
214251881Speter */
215251881Spetersvn_error_t *
216251881Spetersvn_client__youngest_common_ancestor(const char **ancestor_url,
217251881Speter                                     svn_revnum_t *ancestor_rev,
218251881Speter                                     const char *path_or_url1,
219251881Speter                                     const svn_opt_revision_t *revision1,
220251881Speter                                     const char *path_or_url2,
221251881Speter                                     const svn_opt_revision_t *revision2,
222251881Speter                                     svn_client_ctx_t *ctx,
223251881Speter                                     apr_pool_t *result_pool,
224251881Speter                                     apr_pool_t *scratch_pool);
225251881Speter
226251881Speter/* Get the repository location of the base node at LOCAL_ABSPATH.
227251881Speter *
228251881Speter * A pathrev_t wrapper around svn_wc__node_get_base().
229251881Speter *
230251881Speter * Set *BASE_P to the location that this node was checked out at or last
231251881Speter * updated/switched to, regardless of any uncommitted changes (delete,
232251881Speter * replace and/or copy-here/move-here).
233251881Speter *
234251881Speter * If there is no base node at LOCAL_ABSPATH (such as when there is a
235251881Speter * locally added/copied/moved-here node that is not part of a replace),
236251881Speter * set *BASE_P to NULL.
237251881Speter */
238251881Spetersvn_error_t *
239251881Spetersvn_client__wc_node_get_base(svn_client__pathrev_t **base_p,
240251881Speter                             const char *wc_abspath,
241251881Speter                             svn_wc_context_t *wc_ctx,
242251881Speter                             apr_pool_t *result_pool,
243251881Speter                             apr_pool_t *scratch_pool);
244251881Speter
245251881Speter/* Get the original location of the WC node at LOCAL_ABSPATH.
246251881Speter *
247251881Speter * A pathrev_t wrapper around svn_wc__node_get_origin().
248251881Speter *
249251881Speter * Set *ORIGIN_P to the origin of the WC node at WC_ABSPATH.  If the node
250251881Speter * is a local copy, give the copy-from location.  If the node is locally
251251881Speter * added or deleted, set *ORIGIN_P to NULL.
252251881Speter */
253251881Spetersvn_error_t *
254251881Spetersvn_client__wc_node_get_origin(svn_client__pathrev_t **origin_p,
255251881Speter                               const char *wc_abspath,
256251881Speter                               svn_client_ctx_t *ctx,
257251881Speter                               apr_pool_t *result_pool,
258251881Speter                               apr_pool_t *scratch_pool);
259251881Speter
260251881Speter/* Produce a diff with depth DEPTH between two files or two directories at
261251881Speter * LOCAL_ABSPATH1 and LOCAL_ABSPATH2, using the provided diff callbacks to
262251881Speter * show changes in files. The files and directories involved may be part of
263251881Speter * a working copy or they may be unversioned. For versioned files, show
264251881Speter * property changes, too. */
265251881Spetersvn_error_t *
266251881Spetersvn_client__arbitrary_nodes_diff(const char *local_abspath1,
267251881Speter                                 const char *local_abspath2,
268251881Speter                                 svn_depth_t depth,
269251881Speter                                 const svn_wc_diff_callbacks4_t *callbacks,
270251881Speter                                 void *callback_baton,
271251881Speter                                 svn_client_ctx_t *ctx,
272251881Speter                                 apr_pool_t *scratch_pool);
273251881Speter
274251881Speter/* Copy the file or directory on URL in some repository to DST_ABSPATH,
275251881Speter * copying node information and properties. Resolve URL using PEG_REV and
276251881Speter * REVISION.
277251881Speter *
278251881Speter * If URL specifies a directory, create the copy using depth DEPTH.
279251881Speter *
280251881Speter * If MAKE_PARENTS is TRUE and DST_ABSPATH doesn't have an added parent
281251881Speter * create missing parent directories
282251881Speter */
283251881Spetersvn_error_t *
284251881Spetersvn_client__copy_foreign(const char *url,
285251881Speter                         const char *dst_abspath,
286251881Speter                         svn_opt_revision_t *peg_revision,
287251881Speter                         svn_opt_revision_t *revision,
288251881Speter                         svn_depth_t depth,
289251881Speter                         svn_boolean_t make_parents,
290251881Speter                         svn_boolean_t already_locked,
291251881Speter                         svn_client_ctx_t *ctx,
292251881Speter                         apr_pool_t *scratch_pool);
293251881Speter
294253734Speter/* Same as the public svn_client_mergeinfo_log2 API, except for the addition
295253734Speter * of the TARGET_MERGEINFO_CATALOG and RESULT_POOL parameters.
296253734Speter *
297253734Speter * If TARGET_MERGEINFO_CATALOG is NULL then this acts exactly as the public
298253734Speter * API.  If *TARGET_MERGEINFO_CATALOG is NULL, then *TARGET_MERGEINFO_CATALOG
299253734Speter * is set to the a mergeinfo catalog representing the mergeinfo on
300253734Speter * TARGET_PATH_OR_URL@TARGET_PEG_REVISION at DEPTH, (like the public API only
301253734Speter * depths of svn_depth_empty or svn_depth_infinity are supported) allocated in
302253734Speter * RESULT_POOL.  Finally, if *TARGET_MERGEINFO_CATALOG is non-NULL, then it is
303253734Speter * assumed to be a mergeinfo catalog representing the mergeinfo on
304253734Speter * TARGET_PATH_OR_URL@TARGET_PEG_REVISION at DEPTH.
305253734Speter *
306253734Speter * The keys for the subtree mergeinfo are the repository root-relative
307253734Speter * paths of TARGET_PATH_OR_URL and/or its subtrees, regardless of whether
308253734Speter * TARGET_PATH_OR_URL is a URL or WC path.
309253734Speter */
310253734Spetersvn_error_t *
311253734Spetersvn_client__mergeinfo_log(svn_boolean_t finding_merged,
312253734Speter                          const char *target_path_or_url,
313253734Speter                          const svn_opt_revision_t *target_peg_revision,
314253734Speter                          svn_mergeinfo_catalog_t *target_mergeinfo_catalog,
315253734Speter                          const char *source_path_or_url,
316253734Speter                          const svn_opt_revision_t *source_peg_revision,
317253734Speter                          const svn_opt_revision_t *source_start_revision,
318253734Speter                          const svn_opt_revision_t *source_end_revision,
319253734Speter                          svn_log_entry_receiver_t log_receiver,
320253734Speter                          void *log_receiver_baton,
321253734Speter                          svn_boolean_t discover_changed_paths,
322253734Speter                          svn_depth_t depth,
323253734Speter                          const apr_array_header_t *revprops,
324253734Speter                          svn_client_ctx_t *ctx,
325253734Speter                          apr_pool_t *result_pool,
326253734Speter                          apr_pool_t *scratch_pool);
327251881Speter
328251881Speter#ifdef __cplusplus
329251881Speter}
330251881Speter#endif /* __cplusplus */
331251881Speter
332251881Speter#endif /* SVN_CLIENT_PRIVATE_H */
333