2 * client.h : shared stuff internal to the client library.
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
26 #ifndef SVN_LIBSVN_CLIENT_H
27 #define SVN_LIBSVN_CLIENT_H
30 #include <apr_pools.h>
32 #include "svn_types.h"
34 #include "svn_string.h"
35 #include "svn_error.h"
37 #include "svn_client.h"
39 #include "private/svn_magic.h"
40 #include "private/svn_client_private.h"
41 #include "private/svn_diff_tree.h"
42 #include "private/svn_editor.h"
46 #endif /* __cplusplus */
49 /* Private client context.
51 * This is what is actually allocated by svn_client_create_context2(),
52 * which then returns the address of the public_ctx member. */
53 typedef struct svn_client__private_ctx_t
55 /* Reserved field, always zero, to detect misuse of the private
56 context as a public client context. */
57 apr_uint64_t magic_null;
59 /* Reserved field, always set to a known magic number, to identify
60 this struct as the private client context. */
61 apr_uint64_t magic_id;
63 /* Total number of bytes transferred over network across all RA sessions. */
64 apr_off_t total_progress;
66 /* The public context. */
67 svn_client_ctx_t public_ctx;
68 } svn_client__private_ctx_t;
71 /* Given a public client context CTX, return the private context
72 within which it is allocated. */
73 svn_client__private_ctx_t *
74 svn_client__get_private_ctx(svn_client_ctx_t *ctx);
76 /* Set *ORIGINAL_REPOS_RELPATH and *ORIGINAL_REVISION to the original location
77 that served as the source of the copy from which PATH_OR_URL at REVISION was
78 created, or NULL and SVN_INVALID_REVNUM (respectively) if PATH_OR_URL at
79 REVISION was not the result of a copy operation.
81 If RA_SESSION is not NULL it is an existing session to the repository that
82 might be reparented temporarily to obtain the information.
85 svn_client__get_copy_source(const char **original_repos_relpath,
86 svn_revnum_t *original_revision,
87 const char *path_or_url,
88 const svn_opt_revision_t *revision,
89 svn_ra_session_t *ra_session,
90 svn_client_ctx_t *ctx,
91 apr_pool_t *result_pool,
92 apr_pool_t *scratch_pool);
94 /* Set *START_URL and *START_REVISION (and maybe *END_URL
95 and *END_REVISION) to the revisions and repository URLs of one
96 (or two) points of interest along a particular versioned resource's
97 line of history. PATH as it exists in "peg revision"
98 REVISION identifies that line of history, and START and END
99 specify the point(s) of interest (typically the revisions referred
100 to as the "operative range" for a given operation) along that history.
102 START_REVISION and/or END_REVISION may be NULL if not wanted.
103 END may be NULL or of kind svn_opt_revision_unspecified (in either case
104 END_URL and END_REVISION are not touched by the function);
105 START and REVISION may not.
107 If PATH is a WC path and REVISION is of kind svn_opt_revision_working,
108 then look at the PATH's copy-from URL instead of its base URL.
110 RA_SESSION should be an open RA session pointing at the URL of PATH,
111 or NULL, in which case this function will open its own temporary session.
113 A NOTE ABOUT FUTURE REPORTING:
115 If either START or END are greater than REVISION, then do a
116 sanity check (since we cannot search future history yet): verify
117 that PATH in the future revision(s) is the "same object" as the
118 one pegged by REVISION. In other words, all three objects must
119 be connected by a single line of history which exactly passes
120 through PATH at REVISION. If this sanity check fails, return
121 SVN_ERR_CLIENT_UNRELATED_RESOURCES. If PATH doesn't exist in the future
122 revision, SVN_ERR_FS_NOT_FOUND may also be returned.
124 CTX is the client context baton.
126 Use POOL for all allocations. */
128 svn_client__repos_locations(const char **start_url,
129 svn_revnum_t *start_revision,
130 const char **end_url,
131 svn_revnum_t *end_revision,
132 svn_ra_session_t *ra_session,
134 const svn_opt_revision_t *revision,
135 const svn_opt_revision_t *start,
136 const svn_opt_revision_t *end,
137 svn_client_ctx_t *ctx,
140 /* Trace a line of history of a particular versioned resource back to a
143 * Set *OP_LOC_P to the location that the object PEG_LOC had in
144 * revision OP_REVNUM.
146 * RA_SESSION is an open RA session to the correct repository; it may be
147 * temporarily reparented inside this function. */
149 svn_client__repos_location(svn_client__pathrev_t **op_loc_p,
150 svn_ra_session_t *ra_session,
151 const svn_client__pathrev_t *peg_loc,
152 svn_revnum_t op_revnum,
153 svn_client_ctx_t *ctx,
154 apr_pool_t *result_pool,
155 apr_pool_t *scratch_pool);
158 /* Set *SEGMENTS to an array of svn_location_segment_t * objects, each
159 representing a reposition location segment for the history of URL
161 between END_REVISION and START_REVISION, ordered from oldest
162 segment to youngest. *SEGMENTS may be empty but it will never
165 This is basically a thin de-stream-ifying wrapper around the
166 svn_ra_get_location_segments() interface, which see for the rules
167 governing PEG_REVISION, START_REVISION, and END_REVISION.
169 RA_SESSION is an RA session open to the repository of URL; it may be
170 temporarily reparented within this function.
172 CTX is the client context baton.
174 Use POOL for all allocations. */
176 svn_client__repos_location_segments(apr_array_header_t **segments,
177 svn_ra_session_t *ra_session,
179 svn_revnum_t peg_revision,
180 svn_revnum_t start_revision,
181 svn_revnum_t end_revision,
182 svn_client_ctx_t *ctx,
186 /* Find the common ancestor of two locations in a repository.
187 Ancestry is determined by the 'copy-from' relationship and the normal
188 successor relationship.
190 Set *ANCESTOR_P to the location of the youngest common ancestor of
191 LOC1 and LOC2. If the locations have no common ancestor (including if
192 they don't have the same repository root URL), set *ANCESTOR_P to NULL.
194 If SESSION is not NULL, use it for retrieving the common ancestor instead
195 of creating a new session.
197 Use the authentication baton cached in CTX to authenticate against
198 the repository. Use POOL for all allocations.
200 See also svn_client__calc_youngest_common_ancestor() to find youngest
201 common ancestor for already fetched history-as-mergeinfo information.
205 svn_client__get_youngest_common_ancestor(svn_client__pathrev_t **ancestor_p,
206 const svn_client__pathrev_t *loc1,
207 const svn_client__pathrev_t *loc2,
208 svn_ra_session_t *session,
209 svn_client_ctx_t *ctx,
210 apr_pool_t *result_pool,
211 apr_pool_t *scratch_pool);
213 /* Find the common ancestor of two locations in a repository using already
214 fetched history-as-mergeinfo information.
216 Ancestry is determined by the 'copy-from' relationship and the normal
217 successor relationship.
219 Set *ANCESTOR_P to the location of the youngest common ancestor of
220 LOC1 and LOC2. If the locations have no common ancestor (including if
221 they don't have the same repository root URL), set *ANCESTOR_P to NULL.
223 HISTORY1, HAS_REV_ZERO_HISTORY1, HISTORY2, HAS_REV_ZERO_HISTORY2 are
224 history-as-mergeinfo information as returned by
225 svn_client__get_history_as_mergeinfo() for LOC1 and LOC2 respectively.
227 See also svn_client__get_youngest_common_ancestor().
231 svn_client__calc_youngest_common_ancestor(svn_client__pathrev_t **ancestor_p,
232 const svn_client__pathrev_t *loc1,
233 apr_hash_t *history1,
234 svn_boolean_t has_rev_zero_history1,
235 const svn_client__pathrev_t *loc2,
236 apr_hash_t *history2,
237 svn_boolean_t has_rev_zero_history2,
238 apr_pool_t *result_pool,
239 apr_pool_t *scratch_pool);
241 /* Ensure that RA_SESSION's session URL matches SESSION_URL,
242 reparenting that session if necessary.
243 Store the previous session URL in *OLD_SESSION_URL (so that if the
244 reparenting is meant to be temporary, the caller can reparent the
245 session back to where it was).
247 If SESSION_URL is NULL, treat this as a magic value meaning "point
248 the RA session to the root of the repository".
250 NOTE: The typical usage pattern for this functions is:
252 const char *old_session_url;
253 SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url,
260 SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
263 svn_client__ensure_ra_session_url(const char **old_session_url,
264 svn_ra_session_t *ra_session,
265 const char *session_url,
268 /* ---------------------------------------------------------------- */
271 /*** RA callbacks ***/
274 /* CTX is of type "svn_client_ctx_t *". */
275 #define SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx) \
276 ((ctx)->log_msg_func3 || (ctx)->log_msg_func2 || (ctx)->log_msg_func)
278 /* Open an RA session, returning it in *RA_SESSION or a corrected URL
279 in *CORRECTED_URL. (This function mirrors svn_ra_open4(), which
280 see, regarding the interpretation and handling of these two parameters.)
282 The root of the session is specified by BASE_URL and BASE_DIR_ABSPATH.
284 Additional control parameters:
286 - COMMIT_ITEMS is an array of svn_client_commit_item_t *
287 structures, present only for working copy commits, NULL otherwise.
289 - WRITE_DAV_PROPS indicates that the RA layer can clear and write
290 the DAV properties in the working copy of BASE_DIR_ABSPATH.
292 - READ_DAV_PROPS indicates that the RA layer should not attempt to
293 modify the WC props directly, but is still allowed to read them.
295 BASE_DIR_ABSPATH may be NULL if the RA operation does not correspond to a
296 working copy (in which case, WRITE_DAV_PROPS and READ_DAV_PROPS must be
299 If WRITE_DAV_PROPS and READ_DAV_PROPS are both FALSE the working copy may
300 still be used for locating pristine files via their SHA1.
302 The calling application's authentication baton is provided in CTX,
303 and allocations related to this session are performed in POOL.
305 NOTE: The reason for the _internal suffix of this function's name is to
306 avoid confusion with the public API svn_client_open_ra_session(). */
308 svn_client__open_ra_session_internal(svn_ra_session_t **ra_session,
309 const char **corrected_url,
310 const char *base_url,
311 const char *base_dir_abspath,
312 const apr_array_header_t *commit_items,
313 svn_boolean_t write_dav_props,
314 svn_boolean_t read_dav_props,
315 svn_client_ctx_t *ctx,
316 apr_pool_t *result_pool,
317 apr_pool_t *scratch_pool);
321 svn_client__ra_provide_base(svn_stream_t **contents,
322 svn_revnum_t *revision,
324 const char *repos_relpath,
325 apr_pool_t *result_pool,
326 apr_pool_t *scratch_pool);
330 svn_client__ra_provide_props(apr_hash_t **props,
331 svn_revnum_t *revision,
333 const char *repos_relpath,
334 apr_pool_t *result_pool,
335 apr_pool_t *scratch_pool);
339 svn_client__ra_get_copysrc_kind(svn_node_kind_t *kind,
341 const char *repos_relpath,
342 svn_revnum_t src_revision,
343 apr_pool_t *scratch_pool);
347 svn_client__ra_make_cb_baton(svn_wc_context_t *wc_ctx,
348 apr_hash_t *relpath_map,
349 apr_pool_t *result_pool);
351 /* ---------------------------------------------------------------- */
356 /* If AUTOPROPS is not null: Then read automatic properties matching PATH
357 from AUTOPROPS. AUTOPROPS is is a hash as per
358 svn_client__get_all_auto_props. Set *PROPERTIES to a hash containing
359 propname/value pairs (const char * keys mapping to svn_string_t * values).
361 If AUTOPROPS is null then set *PROPERTIES to an empty hash.
363 If *MIMETYPE is null or "application/octet-stream" then check AUTOPROPS
364 for a matching svn:mime-type. If AUTOPROPS is null or no match is found
365 and MAGIC_COOKIE is not NULL, then then try to detect the mime-type with
366 libmagic. If a mimetype is found then add it to *PROPERTIES and set
367 *MIMETYPE to the mimetype value or NULL otherwise.
369 Allocate the *PROPERTIES and its contents as well as *MIMETYPE, in
370 RESULT_POOL. Use SCRATCH_POOL for temporary allocations. */
371 svn_error_t *svn_client__get_paths_auto_props(
372 apr_hash_t **properties,
373 const char **mimetype,
375 svn_magic__cookie_t *magic_cookie,
376 apr_hash_t *autoprops,
377 svn_client_ctx_t *ctx,
378 apr_pool_t *result_pool,
379 apr_pool_t *scratch_pool);
381 /* Gather all auto-props from CTX->config (or none if auto-props are
382 disabled) and all svn:auto-props explicitly set on or inherited
385 If PATH_OR_URL is an unversioned WC path then gather the
386 svn:auto-props inherited by PATH_OR_URL's nearest versioned
389 If PATH_OR_URL is a URL ask for the properties @HEAD, if it is a WC
390 path as sfor the working properties.
392 Store both types of auto-props in *AUTOPROPS, a hash mapping const
393 char * file patterns to another hash which maps const char * property
394 names to const char *property values.
396 If a given property name exists for the same pattern in both the config
397 file and in an a svn:auto-props property, the latter overrides the
398 former. If a given property name exists for the same pattern in two
399 different inherited svn:auto-props, then the closer path-wise
400 property overrides the more distant. svn:auto-props explicitly set
401 on PATH_OR_URL have the highest precedence and override inherited props
402 and config file settings.
404 Allocate *AUTOPROPS in RESULT_POOL. Use SCRATCH_POOL for temporary
406 svn_error_t *svn_client__get_all_auto_props(apr_hash_t **autoprops,
407 const char *path_or_url,
408 svn_client_ctx_t *ctx,
409 apr_pool_t *result_pool,
410 apr_pool_t *scratch_pool);
412 /* The main logic for client deletion from a working copy. Deletes PATH
413 from CTX->WC_CTX. If PATH (or any item below a directory PATH) is
414 modified the delete will fail and return an error unless FORCE or KEEP_LOCAL
417 If KEEP_LOCAL is TRUE then PATH is only scheduled from deletion from the
418 repository and a local copy of PATH will be kept in the working copy.
420 If DRY_RUN is TRUE all the checks are made to ensure that the delete can
421 occur, but the working copy is not modified. If NOTIFY_FUNC is not
422 null, it is called with NOTIFY_BATON for each file or directory deleted. */
424 svn_client__wc_delete(const char *local_abspath,
426 svn_boolean_t dry_run,
427 svn_boolean_t keep_local,
428 svn_wc_notify_func2_t notify_func,
430 svn_client_ctx_t *ctx,
434 /* Like svn_client__wc_delete(), but deletes multiple TARGETS efficiently. */
436 svn_client__wc_delete_many(const apr_array_header_t *targets,
438 svn_boolean_t dry_run,
439 svn_boolean_t keep_local,
440 svn_wc_notify_func2_t notify_func,
442 svn_client_ctx_t *ctx,
446 /* Make LOCAL_ABSPATH and add it to the working copy, optionally making all
447 the intermediate parent directories if MAKE_PARENTS is TRUE. */
449 svn_client__make_local_parents(const char *local_abspath,
450 svn_boolean_t make_parents,
451 svn_client_ctx_t *ctx,
454 /* ---------------------------------------------------------------- */
457 /*** Checkout, update and switch ***/
459 /* Update a working copy LOCAL_ABSPATH to REVISION, and (if not NULL) set
460 RESULT_REV to the update revision.
462 If DEPTH is svn_depth_unknown, then use whatever depth is already
463 set for LOCAL_ABSPATH, or @c svn_depth_infinity if LOCAL_ABSPATH does
466 Else if DEPTH is svn_depth_infinity, then update fully recursively
467 (resetting the existing depth of the working copy if necessary).
468 Else if DEPTH is svn_depth_files, update all files under LOCAL_ABSPATH (if
469 any), but exclude any subdirectories. Else if DEPTH is
470 svn_depth_immediates, update all files and include immediate
471 subdirectories (at svn_depth_empty). Else if DEPTH is
472 svn_depth_empty, just update LOCAL_ABSPATH; if LOCAL_ABSPATH is a
473 directory, that means touching only its properties not its entries.
475 If DEPTH_IS_STICKY is set and DEPTH is not svn_depth_unknown, then
476 in addition to updating LOCAL_ABSPATH, also set its sticky ambient depth
479 If IGNORE_EXTERNALS is true, do no externals processing.
481 Set *TIMESTAMP_SLEEP to TRUE if a sleep is required; otherwise do not
482 change *TIMESTAMP_SLEEP. The output will be valid even if the function
485 If ALLOW_UNVER_OBSTRUCTIONS is TRUE, unversioned children of LOCAL_ABSPATH
486 that obstruct items added from the repos are tolerated; if FALSE,
487 these obstructions cause the update to fail.
489 If ADDS_AS_MODIFICATION is TRUE, local additions are handled as
490 modifications on added nodes.
492 If INNERUPDATE is true, no anchor check is performed on the update target.
494 If MAKE_PARENTS is true, allow the update to calculate and checkout
495 (with depth=empty) any parent directories of the requested update
496 target which are missing from the working copy.
498 If RA_SESSION is NOT NULL, it may be used to avoid creating a new
499 session. The session may point to a different URL after returning.
501 NOTE: You may not specify both INNERUPDATE and MAKE_PARENTS as true.
504 svn_client__update_internal(svn_revnum_t *result_rev,
505 svn_boolean_t *timestamp_sleep,
506 const char *local_abspath,
507 const svn_opt_revision_t *revision,
509 svn_boolean_t depth_is_sticky,
510 svn_boolean_t ignore_externals,
511 svn_boolean_t allow_unver_obstructions,
512 svn_boolean_t adds_as_modification,
513 svn_boolean_t make_parents,
514 svn_boolean_t innerupdate,
515 svn_ra_session_t *ra_session,
516 svn_client_ctx_t *ctx,
519 /* Checkout into LOCAL_ABSPATH a working copy of URL at REVISION, and (if not
520 NULL) set RESULT_REV to the checked out revision.
522 If DEPTH is svn_depth_infinity, then check out fully recursively.
523 Else if DEPTH is svn_depth_files, checkout all files under LOCAL_ABSPATH (if
524 any), but not subdirectories. Else if DEPTH is
525 svn_depth_immediates, check out all files and include immediate
526 subdirectories (at svn_depth_empty). Else if DEPTH is
527 svn_depth_empty, just check out LOCAL_ABSPATH, with none of its entries.
529 DEPTH must be a definite depth, not (e.g.) svn_depth_unknown.
531 If IGNORE_EXTERNALS is true, do no externals processing.
533 Set *TIMESTAMP_SLEEP to TRUE if a sleep is required; otherwise do not
534 change *TIMESTAMP_SLEEP. The output will be valid even if the function
537 If ALLOW_UNVER_OBSTRUCTIONS is TRUE,
538 unversioned children of LOCAL_ABSPATH that obstruct items added from
539 the repos are tolerated; if FALSE, these obstructions cause the checkout
542 If RA_SESSION is NOT NULL, it may be used to avoid creating a new
543 session. The session may point to a different URL after returning.
546 svn_client__checkout_internal(svn_revnum_t *result_rev,
547 svn_boolean_t *timestamp_sleep,
549 const char *local_abspath,
550 const svn_opt_revision_t *peg_revision,
551 const svn_opt_revision_t *revision,
553 svn_boolean_t ignore_externals,
554 svn_boolean_t allow_unver_obstructions,
555 svn_ra_session_t *ra_session,
556 svn_client_ctx_t *ctx,
559 /* Switch a working copy PATH to URL@PEG_REVISION at REVISION, and (if not
560 NULL) set RESULT_REV to the switch revision. A write lock will be
561 acquired and released if not held. Only switch as deeply as DEPTH
564 Set *TIMESTAMP_SLEEP to TRUE if a sleep is required; otherwise do not
565 change *TIMESTAMP_SLEEP. The output will be valid even if the function
568 If IGNORE_EXTERNALS is true, don't process externals.
570 If ALLOW_UNVER_OBSTRUCTIONS is TRUE, unversioned children of PATH
571 that obstruct items added from the repos are tolerated; if FALSE,
572 these obstructions cause the switch to fail.
574 DEPTH and DEPTH_IS_STICKY behave as for svn_client__update_internal().
576 If IGNORE_ANCESTRY is true, don't perform a common ancestry check
577 between the PATH and URL; otherwise, do, and return
578 SVN_ERR_CLIENT_UNRELATED_RESOURCES if they aren't related.
581 svn_client__switch_internal(svn_revnum_t *result_rev,
584 const svn_opt_revision_t *peg_revision,
585 const svn_opt_revision_t *revision,
587 svn_boolean_t depth_is_sticky,
588 svn_boolean_t ignore_externals,
589 svn_boolean_t allow_unver_obstructions,
590 svn_boolean_t ignore_ancestry,
591 svn_boolean_t *timestamp_sleep,
592 svn_client_ctx_t *ctx,
595 /* ---------------------------------------------------------------- */
598 /*** Inheritable Properties ***/
600 /* Convert any svn_prop_inherited_item_t elements in INHERITED_PROPS which
601 have repository root relative path PATH_OR_URL structure members to URLs
602 using REPOS_ROOT_URL. Changes to the contents of INHERITED_PROPS are
603 allocated in RESULT_POOL. SCRATCH_POOL is used for temporary
606 svn_client__iprop_relpaths_to_urls(apr_array_header_t *inherited_props,
607 const char *repos_root_url,
608 apr_pool_t *result_pool,
609 apr_pool_t *scratch_pool);
611 /* Fetch the inherited properties for the base of LOCAL_ABSPATH as well
612 as any WC roots under LOCAL_ABSPATH (as limited by DEPTH) using
613 RA_SESSION. Store the results in *WCROOT_IPROPS, a hash mapping
614 const char * absolute working copy paths to depth-first ordered arrays
615 of svn_prop_inherited_item_t * structures.
617 Any svn_prop_inherited_item_t->path_or_url members returned in
618 *WCROOT_IPROPS are repository relative paths.
620 If LOCAL_ABSPATH has no base then do nothing.
622 RA_SESSION should be an open RA session pointing at the URL of PATH,
623 or NULL, in which case this function will use its own temporary session.
625 Allocate *WCROOT_IPROPS in RESULT_POOL, use SCRATCH_POOL for temporary
628 If one or more of the paths are not available in the repository at the
629 specified revision, these paths will not be added to the hashtable.
632 svn_client__get_inheritable_props(apr_hash_t **wcroot_iprops,
633 const char *local_abspath,
634 svn_revnum_t revision,
636 svn_ra_session_t *ra_session,
637 svn_client_ctx_t *ctx,
638 apr_pool_t *result_pool,
639 apr_pool_t *scratch_pool);
641 /* ---------------------------------------------------------------- */
644 /*** Editor for repository diff ***/
646 /* Create an editor for a pure repository comparison, i.e. comparing one
647 repository version against the other.
649 DIFF_CALLBACKS/DIFF_CMD_BATON represent the callback that implements
652 DEPTH is the depth to recurse.
654 RA_SESSION is an RA session through which this editor may fetch
655 properties, file contents and directory listings of the 'old' side of the
656 diff. It is a separate RA session from the one through which this editor
657 is being driven. REVISION is the revision number of the 'old' side of
660 If TEXT_DELTAS is FALSE, then do not expect text deltas from the edit
661 drive, nor send the 'before' and 'after' texts to the diff callbacks;
662 instead, send empty files to the diff callbacks if there was a change.
663 This must be FALSE if the edit producer is not sending text deltas,
664 otherwise the file content checksum comparisons will fail.
666 EDITOR/EDIT_BATON return the newly created editor and baton.
671 svn_client__get_diff_editor2(const svn_delta_editor_t **editor,
673 svn_ra_session_t *ra_session,
675 svn_revnum_t revision,
676 svn_boolean_t text_deltas,
677 const svn_diff_tree_processor_t *processor,
678 svn_cancel_func_t cancel_func,
680 apr_pool_t *result_pool);
682 /* ---------------------------------------------------------------- */
685 /*** Editor for diff summary ***/
687 /* Set *DIFF_PROCESSOR to a diff processor that will report a diff summary
690 P_ROOT_RELPATH will return a pointer to a string that must be set to
691 the root of the operation before the processor is called.
693 ORIGINAL_PATH specifies the original path and will be used with
694 **ANCHOR_PATH to create paths as the user originally provided them
695 to the diff function.
697 SUMMARIZE_FUNC is called with SUMMARIZE_BATON as parameter by the
698 created callbacks for each changed item.
701 svn_client__get_diff_summarize_callbacks(
702 const svn_diff_tree_processor_t **diff_processor,
703 const char ***p_root_relpath,
704 svn_client_diff_summarize_func_t summarize_func,
705 void *summarize_baton,
706 const char *original_target,
707 apr_pool_t *result_pool,
708 apr_pool_t *scratch_pool);
710 /* ---------------------------------------------------------------- */
715 /* This structure is used to associate a specific copy or move SRC with a
716 specific copy or move destination. It also contains information which
717 various helper functions may need. Not every copy function uses every
720 typedef struct svn_client__copy_pair_t
722 /* The absolute source path or url. */
723 const char *src_abspath_or_url;
725 /* The base name of the object. It should be the same for both src
727 const char *base_name;
729 /* The node kind of the source */
730 svn_node_kind_t src_kind;
732 /* The original source name. (Used when the source gets overwritten by a
733 peg revision lookup.) */
734 const char *src_original;
736 /* The source operational revision. */
737 svn_opt_revision_t src_op_revision;
739 /* The source peg revision. */
740 svn_opt_revision_t src_peg_revision;
742 /* The source revision number. */
743 svn_revnum_t src_revnum;
745 /* The absolute destination path or url */
746 const char *dst_abspath_or_url;
748 /* The absolute source path or url of the destination's parent. */
749 const char *dst_parent_abspath;
750 } svn_client__copy_pair_t;
752 /* ---------------------------------------------------------------- */
755 /*** Commit Stuff ***/
757 /* WARNING: This is all new, untested, un-peer-reviewed conceptual
760 The day that 'svn switch' came into existence, our old commit
761 crawler (svn_wc_crawl_local_mods) became obsolete. It relied far
762 too heavily on the on-disk hierarchy of files and directories, and
763 simply had no way to support disjoint working copy trees or nest
764 working copies. The primary reason for this is that commit
765 process, in order to guarantee atomicity, is a single drive of a
766 commit editor which is based not on working copy paths, but on
767 URLs. With the completion of 'svn switch', it became all too
768 likely that the on-disk working copy hierarchy would no longer be
769 guaranteed to map to a similar in-repository hierarchy.
771 Aside from this new brokenness of the old system, an unrelated
772 feature request had cropped up -- the ability to know in advance of
773 your commit, exactly what would be committed (so that log messages
774 could be initially populated with this information). Since the old
775 crawler discovered commit candidates while in the process of
776 committing, it was impossible to harvest this information upfront.
777 As a workaround, svn_wc_statuses() was used to stat the whole
778 working copy for changes before the commit started...and then the
779 commit would again stat the whole tree for changes.
781 Enter the new system.
783 The primary goal of this system is very straightforward: harvest
784 all commit candidate information up front, and cache enough info in
785 the process to use this to drive a URL-sorted commit.
787 *** END-OF-KNOWLEDGE ***
789 The prototypes below are still in development. In general, the
790 idea is that commit-y processes ('svn mkdir URL', 'svn delete URL',
791 'svn commit', 'svn copy WC_PATH URL', 'svn copy URL1 URL2', 'svn
792 move URL1 URL2', others?) generate the cached commit candidate
793 information, and hand this information off to a consumer which is
794 responsible for driving the RA layer's commit editor in a
795 URL-depth-first fashion and reporting back the post-commit
800 /* Structure that contains an apr_hash_t * hash of apr_array_header_t *
801 arrays of svn_client_commit_item3_t * structures; keyed by the
802 canonical repository URLs. For faster lookup, it also provides
803 an hash index keyed by the local absolute path. */
804 typedef struct svn_client__committables_t
806 /* apr_array_header_t array of svn_client_commit_item3_t structures
807 keyed by canonical repository URL */
808 apr_hash_t *by_repository;
810 /* svn_client_commit_item3_t structures keyed by local absolute path
811 (path member in the respective structures).
813 This member is for fast lookup only, i.e. whether there is an
814 entry for the given path or not, but it will only allow for one
815 entry per absolute path (in case of duplicate entries in the
816 above arrays). The "canonical" data storage containing all item
820 } svn_client__committables_t;
822 /* Callback for the commit harvester to check if a node exists at the specified
824 typedef svn_error_t *(*svn_client__check_url_kind_t)(void *baton,
825 svn_node_kind_t *kind,
827 svn_revnum_t revision,
828 apr_pool_t *scratch_pool);
830 /* Recursively crawl a set of working copy paths (BASE_DIR_ABSPATH + each
831 item in the TARGETS array) looking for commit candidates, locking
832 working copy directories as the crawl progresses. For each
835 - create svn_client_commit_item3_t for the candidate.
837 - add the structure to an apr_array_header_t array of commit
838 items that are in the same repository, creating a new array if
841 - add (or update) a reference to this array to the by_repository
842 hash within COMMITTABLES and update the by_path member as well-
844 - if the candidate has a lock token, add it to the LOCK_TOKENS hash.
846 - if the candidate is a directory scheduled for deletion, crawl
847 the directories children recursively for any lock tokens and
848 add them to the LOCK_TOKENS array.
850 At the successful return of this function, COMMITTABLES will point
851 a new svn_client__committables_t*. LOCK_TOKENS will point to a hash
852 table with const char * lock tokens, keyed on const char * URLs.
854 If DEPTH is specified, descend (or not) into each target in TARGETS
855 as specified by DEPTH; the behavior is the same as that described
856 for svn_client_commit4().
858 If DEPTH_EMPTY_START is >= 0, all targets after index DEPTH_EMPTY_START
859 in TARGETS are handled as having svn_depth_empty.
861 If JUST_LOCKED is TRUE, treat unmodified items with lock tokens as
864 If CHANGELISTS is non-NULL, it is an array of const char *
865 changelist names used as a restrictive filter
866 when harvesting committables; that is, don't add a path to
867 COMMITTABLES unless it's a member of one of those changelists.
869 If CTX->CANCEL_FUNC is non-null, it will be called with
870 CTX->CANCEL_BATON while harvesting to determine if the client has
871 cancelled the operation. */
873 svn_client__harvest_committables(svn_client__committables_t **committables,
874 apr_hash_t **lock_tokens,
875 const char *base_dir_abspath,
876 const apr_array_header_t *targets,
877 int depth_empty_start,
879 svn_boolean_t just_locked,
880 const apr_array_header_t *changelists,
881 svn_client__check_url_kind_t check_url_func,
882 void *check_url_baton,
883 svn_client_ctx_t *ctx,
884 apr_pool_t *result_pool,
885 apr_pool_t *scratch_pool);
888 /* Recursively crawl each absolute working copy path SRC in COPY_PAIRS,
889 harvesting commit_items into a COMMITABLES structure as if every entry
890 at or below the SRC was to be committed as a set of adds (mostly with
891 history) to a new repository URL (DST in COPY_PAIRS).
893 If CTX->CANCEL_FUNC is non-null, it will be called with
894 CTX->CANCEL_BATON while harvesting to determine if the client has
895 cancelled the operation. */
897 svn_client__get_copy_committables(svn_client__committables_t **committables,
898 const apr_array_header_t *copy_pairs,
899 svn_client__check_url_kind_t check_url_func,
900 void *check_url_baton,
901 svn_client_ctx_t *ctx,
902 apr_pool_t *result_pool,
903 apr_pool_t *scratch_pool);
905 /* Rewrite the COMMIT_ITEMS array to be sorted by URL. Also, discover
906 a common *BASE_URL for the items in the array, and rewrite those
907 items' URLs to be relative to that *BASE_URL.
909 COMMIT_ITEMS is an array of (svn_client_commit_item3_t *) items.
911 Afterwards, some of the items in COMMIT_ITEMS may contain data
912 allocated in POOL. */
914 svn_client__condense_commit_items(const char **base_url,
915 apr_array_header_t *commit_items,
918 /* Commit the items in the COMMIT_ITEMS array using EDITOR/EDIT_BATON
919 to describe the committed local mods. Prior to this call,
920 COMMIT_ITEMS should have been run through (and BASE_URL generated
921 by) svn_client__condense_commit_items().
923 COMMIT_ITEMS is an array of (svn_client_commit_item3_t *) items.
925 CTX->NOTIFY_FUNC/CTX->BATON will be called as the commit progresses, as
926 a way of describing actions to the application layer (if non NULL).
928 NOTIFY_PATH_PREFIX will be passed to CTX->notify_func2() as the
929 common absolute path prefix of the committed paths. It can be NULL.
931 If SHA1_CHECKSUMS is not NULL, set *SHA1_CHECKSUMS to a hash containing,
932 for each file transmitted, a mapping from the commit-item's (const
933 char *) path to the (const svn_checksum_t *) SHA1 checksum of its new text
936 Use RESULT_POOL for all allocating the resulting hashes and SCRATCH_POOL
937 for temporary allocations.
940 svn_client__do_commit(const char *base_url,
941 const apr_array_header_t *commit_items,
942 const svn_delta_editor_t *editor,
944 const char *notify_path_prefix,
945 apr_hash_t **sha1_checksums,
946 svn_client_ctx_t *ctx,
947 apr_pool_t *result_pool,
948 apr_pool_t *scratch_pool);
953 /*** Externals (Modules) ***/
955 /* Handle changes to the svn:externals property described by EXTERNALS_NEW,
956 and AMBIENT_DEPTHS. The tree's top level directory
957 is at TARGET_ABSPATH which has a root URL of REPOS_ROOT_URL.
958 A write lock should be held.
960 For each changed value of the property, discover the nature of the
961 change and behave appropriately -- either check a new "external"
962 subdir, or call svn_wc_remove_from_revision_control() on an
963 existing one, or both.
965 TARGET_ABSPATH is the root of the driving operation and
966 REQUESTED_DEPTH is the requested depth of the driving operation
967 (e.g., update, switch, etc). If it is neither svn_depth_infinity
968 nor svn_depth_unknown, then changes to svn:externals will have no
969 effect. If REQUESTED_DEPTH is svn_depth_unknown, then the ambient
970 depth of each working copy directory holding an svn:externals value
971 will determine whether that value is interpreted there (the ambient
972 depth must be svn_depth_infinity). If REQUESTED_DEPTH is
973 svn_depth_infinity, then it is presumed to be expanding any
974 shallower ambient depth, so changes to svn:externals values will be
977 Pass NOTIFY_FUNC with NOTIFY_BATON along to svn_client_checkout().
979 Set *TIMESTAMP_SLEEP to TRUE if a sleep is required; otherwise do not
980 change *TIMESTAMP_SLEEP. The output will be valid even if the function
983 If RA_SESSION is NOT NULL, it may be used to avoid creating a new
984 session. The session may point to a different URL after returning.
986 Use POOL for temporary allocation. */
988 svn_client__handle_externals(apr_hash_t *externals_new,
989 apr_hash_t *ambient_depths,
990 const char *repos_root_url,
991 const char *target_abspath,
992 svn_depth_t requested_depth,
993 svn_boolean_t *timestamp_sleep,
994 svn_ra_session_t *ra_session,
995 svn_client_ctx_t *ctx,
999 /* Export externals definitions described by EXTERNALS, a hash of the
1000 form returned by svn_wc_edited_externals() (which see). The external
1001 items will be exported instead of checked out -- they will have no
1002 administrative subdirectories.
1004 The checked out or exported tree's top level directory is at
1005 TO_ABSPATH and corresponds to FROM_URL URL in the repository, which
1006 has a root URL of REPOS_ROOT_URL.
1008 REQUESTED_DEPTH is the requested_depth of the driving operation; it
1009 behaves as for svn_client__handle_externals(), except that ambient
1010 depths are presumed to be svn_depth_infinity.
1012 NATIVE_EOL is the value passed as NATIVE_EOL when exporting.
1014 Use POOL for temporary allocation. */
1016 svn_client__export_externals(apr_hash_t *externals,
1017 const char *from_url,
1018 const char *to_abspath,
1019 const char *repos_root_url,
1020 svn_depth_t requested_depth,
1021 const char *native_eol,
1022 svn_boolean_t ignore_keywords,
1023 svn_client_ctx_t *ctx,
1026 /* Baton for svn_client__dirent_fetcher */
1027 struct svn_client__dirent_fetcher_baton_t
1029 svn_ra_session_t *ra_session;
1030 svn_revnum_t target_revision;
1031 const char *anchor_url;
1034 /* Implements svn_wc_dirents_func_t for update and switch handling. Assumes
1035 a struct svn_client__dirent_fetcher_baton_t * baton */
1037 svn_client__dirent_fetcher(void *baton,
1038 apr_hash_t **dirents,
1039 const char *repos_root_url,
1040 const char *repos_relpath,
1041 apr_pool_t *result_pool,
1042 apr_pool_t *scratch_pool);
1044 /* Retrieve log messages using the first provided (non-NULL) callback
1045 in the set of *CTX->log_msg_func3, CTX->log_msg_func2, or
1046 CTX->log_msg_func. Other arguments same as
1047 svn_client_get_commit_log3_t. */
1049 svn_client__get_log_msg(const char **log_msg,
1050 const char **tmp_file,
1051 const apr_array_header_t *commit_items,
1052 svn_client_ctx_t *ctx,
1055 /* Return the revision properties stored in REVPROP_TABLE_IN, adding
1056 LOG_MSG as SVN_PROP_REVISION_LOG in *REVPROP_TABLE_OUT, allocated in
1057 POOL. *REVPROP_TABLE_OUT will map const char * property names to
1058 svn_string_t values. If REVPROP_TABLE_IN is non-NULL, check that
1059 it doesn't contain any of the standard Subversion properties. In
1060 that case, return SVN_ERR_CLIENT_PROPERTY_NAME. */
1062 svn_client__ensure_revprop_table(apr_hash_t **revprop_table_out,
1063 const apr_hash_t *revprop_table_in,
1064 const char *log_msg,
1065 svn_client_ctx_t *ctx,
1068 /* Return a potentially translated version of local file LOCAL_ABSPATH
1069 in NORMAL_STREAM. REVISION must be one of the following: BASE, COMMITTED,
1072 EXPAND_KEYWORDS operates as per the EXPAND argument to
1073 svn_subst_stream_translated, which see. If NORMALIZE_EOLS is TRUE and
1074 LOCAL_ABSPATH requires translation, then normalize the line endings in
1077 Uses SCRATCH_POOL for temporary allocations. */
1079 svn_client__get_normalized_stream(svn_stream_t **normal_stream,
1080 svn_wc_context_t *wc_ctx,
1081 const char *local_abspath,
1082 const svn_opt_revision_t *revision,
1083 svn_boolean_t expand_keywords,
1084 svn_boolean_t normalize_eols,
1085 svn_cancel_func_t cancel_func,
1087 apr_pool_t *result_pool,
1088 apr_pool_t *scratch_pool);
1090 /* Return a set of callbacks to use with the Ev2 shims. */
1091 svn_delta_shim_callbacks_t *
1092 svn_client__get_shim_callbacks(svn_wc_context_t *wc_ctx,
1093 apr_hash_t *relpath_map,
1094 apr_pool_t *result_pool);
1096 /* Return REVISION unless its kind is 'unspecified' in which case return
1097 * a pointer to a statically allocated revision structure of kind 'head'
1098 * if PATH_OR_URL is a URL or 'base' if it is a WC path. */
1099 const svn_opt_revision_t *
1100 svn_cl__rev_default_to_head_or_base(const svn_opt_revision_t *revision,
1101 const char *path_or_url);
1103 /* Return REVISION unless its kind is 'unspecified' in which case return
1104 * a pointer to a statically allocated revision structure of kind 'head'
1105 * if PATH_OR_URL is a URL or 'working' if it is a WC path. */
1106 const svn_opt_revision_t *
1107 svn_cl__rev_default_to_head_or_working(const svn_opt_revision_t *revision,
1108 const char *path_or_url);
1110 /* Return REVISION unless its kind is 'unspecified' in which case return
1112 const svn_opt_revision_t *
1113 svn_cl__rev_default_to_peg(const svn_opt_revision_t *revision,
1114 const svn_opt_revision_t *peg_revision);
1116 /* Call the conflict resolver callback in CTX for each conflict recorded
1117 * in CONFLICTED_PATHS (const char *abspath keys; ignored values). If
1118 * CONFLICTS_REMAIN is not NULL, then set *CONFLICTS_REMAIN to true if
1119 * there are any conflicts among CONFLICTED_PATHS remaining unresolved
1120 * at the end of this operation, else set it to false.
1123 svn_client__resolve_conflicts(svn_boolean_t *conflicts_remain,
1124 apr_hash_t *conflicted_paths,
1125 svn_client_ctx_t *ctx,
1126 apr_pool_t *scratch_pool);
1128 /* Produce a diff with depth DEPTH between two files or two directories at
1129 * LEFT_ABSPATH1 and RIGHT_ABSPATH, using the provided diff callbacks to
1130 * show changes in files. The files and directories involved may be part of
1131 * a working copy or they may be unversioned. For versioned files, show
1132 * property changes, too.
1134 * If ANCHOR_ABSPATH is not null, set it to the anchor of the diff before
1135 * the first processor call. (The anchor is LEFT_ABSPATH or an ancestor of it)
1138 svn_client__arbitrary_nodes_diff(const char **root_relpath,
1139 svn_boolean_t *root_is_dir,
1140 const char *left_abspath,
1141 const char *right_abspath,
1143 const svn_diff_tree_processor_t *diff_processor,
1144 svn_client_ctx_t *ctx,
1145 apr_pool_t *result_pool,
1146 apr_pool_t *scratch_pool);
1149 /* Helper for the remote case of svn_client_propget.
1151 * If PROPS is not null, then get the value of property PROPNAME in
1152 * REVNUM, using RA_SESSION. Store the value ('svn_string_t *') in
1153 * PROPS, under the path key "TARGET_PREFIX/TARGET_RELATIVE"
1156 * If INHERITED_PROPS is not null, then set *INHERITED_PROPS to a
1157 * depth-first ordered array of svn_prop_inherited_item_t * structures
1158 * representing the PROPNAME properties inherited by the target. If
1159 * INHERITABLE_PROPS in not null and no inheritable properties are found,
1160 * then set *INHERITED_PROPS to an empty array.
1162 * Recurse according to DEPTH, similarly to svn_client_propget3().
1164 * KIND is the kind of the node at "TARGET_PREFIX/TARGET_RELATIVE".
1165 * Yes, caller passes this; it makes the recursion more efficient :-).
1167 * Allocate PROPS and *INHERITED_PROPS in RESULT_POOL, but do all temporary
1168 * work in SCRATCH_POOL. The two pools can be the same; recursive
1169 * calls may use a different SCRATCH_POOL, however.
1172 svn_client__remote_propget(apr_hash_t *props,
1173 apr_array_header_t **inherited_props,
1174 const char *propname,
1175 const char *target_prefix,
1176 const char *target_relative,
1177 svn_node_kind_t kind,
1178 svn_revnum_t revnum,
1179 svn_ra_session_t *ra_session,
1181 apr_pool_t *result_pool,
1182 apr_pool_t *scratch_pool);
1186 #endif /* __cplusplus */
1188 #endif /* SVN_LIBSVN_CLIENT_H */