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 /* Same as the public svn_client_mergeinfo_log2 API, except for the addition
285 * of the TARGET_MERGEINFO_CATALOG and RESULT_POOL parameters.
287 * If TARGET_MERGEINFO_CATALOG is NULL then this acts exactly as the public
288 * API. If *TARGET_MERGEINFO_CATALOG is NULL, then *TARGET_MERGEINFO_CATALOG
289 * is set to the a mergeinfo catalog representing the mergeinfo on
290 * TARGET_PATH_OR_URL@TARGET_PEG_REVISION at DEPTH, (like the public API only
291 * depths of svn_depth_empty or svn_depth_infinity are supported) allocated in
292 * RESULT_POOL. Finally, if *TARGET_MERGEINFO_CATALOG is non-NULL, then it is
293 * assumed to be a mergeinfo catalog representing the mergeinfo on
294 * TARGET_PATH_OR_URL@TARGET_PEG_REVISION at DEPTH.
296 * The keys for the subtree mergeinfo are the repository root-relative
297 * paths of TARGET_PATH_OR_URL and/or its subtrees, regardless of whether
298 * TARGET_PATH_OR_URL is a URL or WC path.
300 * If RA_SESSION is not NULL, use it to obtain merge information instead of
301 * opening a new session. The session might be reparented after usage, so
302 * callers should reparent the session back to their original location if
306 svn_client__mergeinfo_log(svn_boolean_t finding_merged,
307 const char *target_path_or_url,
308 const svn_opt_revision_t *target_peg_revision,
309 svn_mergeinfo_catalog_t *target_mergeinfo_catalog,
310 const char *source_path_or_url,
311 const svn_opt_revision_t *source_peg_revision,
312 const svn_opt_revision_t *source_start_revision,
313 const svn_opt_revision_t *source_end_revision,
314 svn_log_entry_receiver_t log_receiver,
315 void *log_receiver_baton,
316 svn_boolean_t discover_changed_paths,
318 const apr_array_header_t *revprops,
319 svn_client_ctx_t *ctx,
320 svn_ra_session_t *ra_session,
321 apr_pool_t *result_pool,
322 apr_pool_t *scratch_pool);
324 /** Return a diff processor that will print a Subversion-style
325 * (not git-style) diff.
327 * @a anchor is optional (may be null), and is the 'anchor' path to prefix
328 * to the diff-processor paths before displaying.
330 * @a orig_path_1 and @a orig_path_2 are the two main root paths to be
331 * diffed; each may be a URL, a local WC path or a local unversioned path.
333 * Other arguments are as for svn_client_diff7() etc.
336 svn_client__get_diff_writer_svn(
337 svn_diff_tree_processor_t **diff_processor,
339 const char *orig_path_1,
340 const char *orig_path_2,
341 const apr_array_header_t *options,
342 const char *relative_to_dir,
343 svn_boolean_t no_diff_added,
344 svn_boolean_t no_diff_deleted,
345 svn_boolean_t show_copies_as_adds,
346 svn_boolean_t ignore_content_type,
347 svn_boolean_t ignore_properties,
348 svn_boolean_t properties_only,
349 svn_boolean_t pretty_print_mergeinfo,
350 const char *header_encoding,
351 svn_stream_t *outstream,
352 svn_stream_t *errstream,
353 svn_client_ctx_t *ctx,
356 /*** Editor for diff summary ***/
358 /* Set *DIFF_PROCESSOR to a diff processor that will report a diff summary
361 SUMMARIZE_FUNC is called with SUMMARIZE_BATON as parameter by the
362 created callbacks for each changed item.
365 svn_client__get_diff_summarize_callbacks(
366 svn_diff_tree_processor_t **diff_processor,
367 svn_client_diff_summarize_func_t summarize_func,
368 void *summarize_baton,
369 apr_pool_t *result_pool,
370 apr_pool_t *scratch_pool);
372 /** Copy a directory tree or a file (according to @a kind) from @a src_url at
373 * @a src_rev, to @a dst_abspath in a WC.
375 * The caller should be holding a WC write lock that allows @a dst_abspath to
376 * be created, such as on the parent of @a dst_abspath.
378 * If not same repositories, then remove any svn:mergeinfo property.
380 * Use @a ra_session to fetch the data. The session may point to any URL
381 * within the source repository.
383 * This API does not process any externals definitions that may be present
384 * on copied directories.
387 svn_client__repos_to_wc_copy_internal(svn_boolean_t *timestamp_sleep,
388 svn_node_kind_t kind,
390 svn_revnum_t src_rev,
391 const char *dst_abspath,
392 svn_ra_session_t *ra_session,
393 svn_client_ctx_t *ctx,
394 apr_pool_t *scratch_pool);
396 /** Copy a directory tree or a file (according to @a kind) from @a src_url at
397 * @a src_rev, to @a dst_abspath in a WC.
399 * The caller should be holding a WC write lock that allows @a dst_abspath to
400 * be created, such as on the parent of @a dst_abspath.
402 * If not same repositories, then remove any svn:mergeinfo property.
404 * Use @a ra_session to fetch the data. The session may point to a different
405 * URL after returning.
407 * This API does not process any externals definitions that may be present
408 * on copied directories.
411 svn_client__repos_to_wc_copy_by_editor(svn_boolean_t *timestamp_sleep,
412 svn_node_kind_t kind,
414 svn_revnum_t src_rev,
415 const char *dst_abspath,
416 svn_ra_session_t *ra_session,
417 svn_client_ctx_t *ctx,
418 apr_pool_t *scratch_pool);
420 /** Return an editor for applying local modifications to a WC.
422 * Return an editor in @a *editor_p, @a *edit_baton_p that will apply
423 * local modifications to the WC subdirectory at @a dst_abspath.
425 * The @a path arguments to the editor methods shall be local WC paths,
426 * relative to @a dst_abspath. The @a copyfrom_path arguments to the
427 * editor methods shall be URLs.
429 * Send notifications via @a notify_func / @a notify_baton.
432 * @a ra_session is used to fetch the original content for copies.
434 * Ignore changes to non-regular property (entry-props, DAV/WC-props).
436 * Acquire the WC write lock in 'open_root' and release it in
437 * 'close_edit', in 'abort_edit', or when @a result_pool is cleared.
440 svn_client__wc_editor(const svn_delta_editor_t **editor_p,
442 const char *dst_abspath,
443 svn_wc_notify_func2_t notify_func,
445 svn_ra_session_t *ra_session,
446 svn_client_ctx_t *ctx,
447 apr_pool_t *result_pool);
449 /* Return an editor for applying local modifications to a WC.
451 * Like svn_client__wc_editor() but with additional options.
453 * If @a root_dir_add is true, then create and schedule for addition
454 * the root directory of this edit, else assume it is already a versioned,
455 * existing directory.
457 * If @a ignore_mergeinfo_changes is true, ignore any incoming changes
458 * to the 'svn:mergeinfo' property.
460 * If @a manage_wc_write_lock is true, acquire the WC write lock in
461 * 'open_root' and release it in 'close_edit', in 'abort_edit', or
462 * when @a result_pool is cleared.
465 svn_client__wc_editor_internal(const svn_delta_editor_t **editor_p,
467 const char *dst_abspath,
468 svn_boolean_t root_dir_add,
469 svn_boolean_t ignore_mergeinfo_changes,
470 svn_boolean_t manage_wc_write_lock,
471 svn_wc_notify_func2_t notify_func,
473 svn_ra_session_t *ra_session,
474 svn_client_ctx_t *ctx,
475 apr_pool_t *result_pool);
477 /** Send committable changes found in the WC to a delta-editor.
479 * Committable changes are found in TARGETS:DEPTH:CHANGELISTS.
481 * Send the changes to @a editor:@a edit_baton. The @a path arguments
482 * to the editor methods are URL-paths relative to the URL of
485 * ### We will presumably need to change this so that the @a path
486 * arguments to the editor will be local WC relpaths, in order
487 * to handle switched paths.
489 * The @a copyfrom_path arguments to the editor methods are URLs. As the
490 * WC does not store copied-from-foreign-repository metadata, the URL will
491 * be in the same repository as the URL of its parent path.
493 * Compared with svn_client__do_commit(), this (like svn_client_commit6)
495 * - condense targets and find committable paths
496 * - checking only one repository is involved
498 * Compared with svn_client_commit6(), this does not handle:
502 * - checking the commit includes both halves of each local move
503 * - changing the copy revision of each local move to ~HEAD
505 * - bumping revisions in WC
506 * - removing locks and changelists in WC
509 svn_client__wc_replay(const char *src_wc_abspath,
510 const apr_array_header_t *targets,
512 const apr_array_header_t *changelists,
513 const svn_delta_editor_t *editor,
515 svn_wc_notify_func2_t notify_func,
517 svn_client_ctx_t *ctx,
518 apr_pool_t *scratch_pool);
520 /** Copy local modifications from one WC subtree to another.
522 * Find local modifications under @a src_wc_abspath, in the same way as
525 * Edit the WC at @a dst_wc_abspath, applying those modifications to the
526 * current working state to produce a new working state.
528 * The source and destination may be in the same WC or in different WCs.
531 svn_client__wc_copy_mods(const char *src_wc_abspath,
532 const char *dst_wc_abspath,
533 svn_wc_notify_func2_t notify_func,
535 svn_client_ctx_t *ctx,
536 apr_pool_t *scratch_pool);
540 #endif /* __cplusplus */
542 #endif /* SVN_CLIENT_PRIVATE_H */