In the command-line client, forbid
[svn.git] / subversion / libsvn_client / client.h
blob058187e3b293720dec96f69f6a056409e4063b3f
1 /*
2 * client.h : shared stuff internal to the client library.
4 * ====================================================================
5 * Copyright (c) 2000-2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
20 #ifndef SVN_LIBSVN_CLIENT_H
21 #define SVN_LIBSVN_CLIENT_H
24 #include <apr_pools.h>
26 #include "svn_types.h"
27 #include "svn_opt.h"
28 #include "svn_string.h"
29 #include "svn_error.h"
30 #include "svn_ra.h"
31 #include "svn_client.h"
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
39 /* Set *URL and *PEG_REVNUM (the latter is ignored if NULL) to the
40 repository URL of PATH_OR_URL. If PATH_OR_URL is a WC path and
41 PEG_REVISION->kind is svn_opt_revision_working, use the
42 corresponding entry's copyfrom info. RA_SESSION and ADM_ACCESS may
43 be NULL, regardless of whether PATH_OR_URL is a URL. Use CTX for
44 cancellation (ignored if NULL), and POOL for all allocations. */
45 svn_error_t *
46 svn_client__derive_location(const char **url,
47 svn_revnum_t *peg_revnum,
48 const char *path_or_url,
49 const svn_opt_revision_t *peg_revision,
50 const svn_ra_session_t *ra_session,
51 svn_wc_adm_access_t *adm_access,
52 svn_client_ctx_t *ctx,
53 apr_pool_t *pool);
55 /* Get the repository URL and revision number for WC entry ENTRY,
56 which is sometimes the entry's copyfrom info rather than its actual
57 URL and revision. */
58 svn_error_t *
59 svn_client__entry_location(const char **url,
60 svn_revnum_t *revnum,
61 const char *path_or_url,
62 enum svn_opt_revision_kind peg_rev_kind,
63 const svn_wc_entry_t *entry,
64 apr_pool_t *pool);
66 /* Set *REVNUM to the revision number identified by REVISION.
68 If REVISION->kind is svn_opt_revision_number, just use
69 REVISION->value.number, ignoring PATH and RA_SESSION.
71 Else if REVISION->kind is svn_opt_revision_committed,
72 svn_opt_revision_previous, or svn_opt_revision_base, or
73 svn_opt_revision_working, then the revision can be identified
74 purely based on the working copy's administrative information for
75 PATH, so RA_SESSION is ignored. If PATH is not under revision
76 control, return SVN_ERR_UNVERSIONED_RESOURCE, or if PATH is null,
77 return SVN_ERR_CLIENT_VERSIONED_PATH_REQUIRED.
79 Else if REVISION->kind is svn_opt_revision_date or
80 svn_opt_revision_head, then RA_SESSION is used to retrieve the
81 revision from the repository (using REVISION->value.date in the
82 former case), and PATH is ignored. If RA_SESSION is null,
83 return SVN_ERR_CLIENT_RA_ACCESS_REQUIRED.
85 Else if REVISION->kind is svn_opt_revision_unspecified, set
86 *REVNUM to SVN_INVALID_REVNUM.
88 If YOUNGEST_REV is non-NULL, it is an in/out parameter. If
89 *YOUNGEST_REV is valid, use it as the youngest revision in the
90 repository (regardless of reality) -- don't bother to lookup the
91 true value for HEAD, and don't return any value in *REVNUM greater
92 than *YOUNGEST_REV. If *YOUNGEST_REV is not valid, and a HEAD
93 lookup is required to populate *REVNUM, then also populate
94 *YOUNGEST_REV with the result. This is useful for making multiple
95 serialized calls to this function with a basically static view of
96 the repository, avoiding race conditions which could occur between
97 multiple invocations with HEAD lookup requests.
99 Else return SVN_ERR_CLIENT_BAD_REVISION.
101 Use POOL for any temporary allocation. */
102 svn_error_t *
103 svn_client__get_revision_number(svn_revnum_t *revnum,
104 svn_revnum_t *youngest_rev,
105 svn_ra_session_t *ra_session,
106 const svn_opt_revision_t *revision,
107 const char *path,
108 apr_pool_t *pool);
110 /* Return true if REVISION1 and REVISION2 would result in the same
111 revision number if interpreted in the context of the same working
112 copy and path and repository, or if both are of kind
113 svn_opt_revision_unspecified. Otherwise, return false. */
114 svn_boolean_t
115 svn_client__compare_revisions(svn_opt_revision_t *revision1,
116 svn_opt_revision_t *revision2);
119 /* Return true if the revision number for REVISION can be determined
120 from just the working copy, or false if it can be determined from
121 just the repository.
123 NOTE: No other kinds of revisions should be possible; but if one
124 day there are, this will return true for those kinds.
126 svn_boolean_t
127 svn_client__revision_is_local(const svn_opt_revision_t *revision);
130 /* Set *COPYFROM_PATH and *COPYFROM_REV to the path and revision that
131 served as the source of the copy from which PATH_OR_URL at REVISION
132 was created, or NULL and SVN_INVALID_REVNUM (respectively) if
133 PATH_OR_URL at REVISION was not the result of a copy operation. */
134 svn_error_t *svn_client__get_copy_source(const char *path_or_url,
135 const svn_opt_revision_t *revision,
136 const char **copyfrom_path,
137 svn_revnum_t *copyfrom_rev,
138 svn_client_ctx_t *ctx,
139 apr_pool_t *pool);
141 /* Set *START_URL and *START_REVISION (and maybe *END_URL
142 and *END_REVISION) to the revisions and repository URLs of one
143 (or two) points of interest along a particular versioned resource's
144 line of history. PATH as it exists in "peg revision"
145 REVISION identifies that line of history, and START and END
146 specify the point(s) of interest (typically the revisions referred
147 to as the "operative range" for a given operation) along that history.
149 END may be of kind svn_opt_revision_unspecified (in which case
150 END_URL and END_REVISION are not touched by the function);
151 START and REVISION may not.
153 RA_SESSION should be an open RA session pointing at the URL of PATH,
154 or NULL, in which case this function will open its own temporary session.
156 A NOTE ABOUT FUTURE REPORTING:
158 If either START or END are greater than REVISION, then do a
159 sanity check (since we cannot search future history yet): verify
160 that PATH in the future revision(s) is the "same object" as the
161 one pegged by REVISION. In other words, all three objects must
162 be connected by a single line of history which exactly passes
163 through PATH at REVISION. If this sanity check fails, return
164 SVN_ERR_CLIENT_UNRELATED_RESOURCES. If PATH doesn't exist in the future
165 revision, SVN_ERR_FS_NOT_FOUND may also be returned.
167 CTX is the client context baton.
169 Use POOL for all allocations. */
170 svn_error_t *
171 svn_client__repos_locations(const char **start_url,
172 svn_opt_revision_t **start_revision,
173 const char **end_url,
174 svn_opt_revision_t **end_revision,
175 svn_ra_session_t *ra_session,
176 const char *path,
177 const svn_opt_revision_t *revision,
178 const svn_opt_revision_t *start,
179 const svn_opt_revision_t *end,
180 svn_client_ctx_t *ctx,
181 apr_pool_t *pool);
184 /* Set *SEGMENTS to an array of svn_location_segment_t * objects, each
185 representing a reposition location segment for the history of PATH
186 (which is relative to RA_SESSION's session URL) in PEG_REVISION
187 between END_REVISION and START_REVISION, ordered from oldest
188 segment to youngest.
190 This is basically a thin de-stream-ifying wrapper around the
191 svn_ra_get_location_segments() interface, which see for the rules
192 governing PEG_REVISION, START_REVISION, and END_REVISION.
194 CTX is the client context baton.
196 Use POOL for all allocations. */
197 svn_error_t *
198 svn_client__repos_location_segments(apr_array_header_t **segments,
199 svn_ra_session_t *ra_session,
200 const char *path,
201 svn_revnum_t peg_revision,
202 svn_revnum_t start_revision,
203 svn_revnum_t end_revision,
204 svn_client_ctx_t *ctx,
205 apr_pool_t *pool);
208 /* Set *ANCESTOR_PATH and *ANCESTOR_REVISION to the youngest common
209 ancestor path (a path relative to the root of the repository) and
210 revision, respectively, of the two locations identified as
211 PATH_OR_URL1@REVISION1 and PATH_OR_URL2@REVISION2. Use the
212 authentication baton cached in CTX to authenticate against the
213 repository. Use POOL for all allocations. */
214 svn_error_t *
215 svn_client__get_youngest_common_ancestor(const char **ancestor_path,
216 svn_revnum_t *ancestor_revision,
217 const char *path_or_url1,
218 const svn_opt_revision_t *revision1,
219 const char *path_or_url2,
220 const svn_opt_revision_t *revision2,
221 svn_client_ctx_t *ctx,
222 apr_pool_t *pool);
224 /* Given PATH_OR_URL, which contains either a working copy path or an
225 absolute URL, a peg revision PEG_REVISION, and a desired revision
226 REVISION, create an RA connection to that object as it exists in
227 that revision, following copy history if necessary. If REVISION is
228 younger than PEG_REVISION, then PATH_OR_URL will be checked to see
229 that it is the same node in both PEG_REVISION and REVISION. If it
230 is not, then @c SVN_ERR_CLIENT_UNRELATED_RESOURCES is returned.
232 BASE_ACCESS is the working copy the ra_session corresponds to, should
233 only be used if PATH_OR_URL is a url.
235 If PEG_REVISION's kind is svn_opt_revision_unspecified, it is
236 interpreted as "head" for a URL or "working" for a working-copy path.
238 Store the resulting ra_session in *RA_SESSION_P. Store the actual
239 revision number of the object in *REV_P, and the final resulting
240 URL in *URL_P.
242 Use authentication baton cached in CTX to authenticate against the
243 repository.
245 Use POOL for all allocations. */
246 svn_error_t *
247 svn_client__ra_session_from_path(svn_ra_session_t **ra_session_p,
248 svn_revnum_t *rev_p,
249 const char **url_p,
250 const char *path_or_url,
251 svn_wc_adm_access_t *base_access,
252 const svn_opt_revision_t *peg_revision,
253 const svn_opt_revision_t *revision,
254 svn_client_ctx_t *ctx,
255 apr_pool_t *pool);
257 /* Set *REL_PATH to a relative path which, when URI-encoded and joined
258 with RA_SESSION's session url, will result in a string that matches URL. */
259 svn_error_t *
260 svn_client__path_relative_to_session(const char **rel_path,
261 svn_ra_session_t *ra_session,
262 const char *url,
263 apr_pool_t *pool);
265 /* Ensure that RA_SESSION's session URL matches SESSION_URL,
266 reparenting that session if necessary. If reparenting occurs,
267 store the previous session URL in *OLD_SESSION_URL (so that if the
268 reparenting is meant to be temporary, the caller can reparent the
269 session back to where it was); otherwise set *OLD_SESSION_URL to
270 NULL.
272 If SESSION_URL is NULL, treat this as a magic value meaning "point
273 the RA session to the root of the repository". */
274 svn_error_t *
275 svn_client__ensure_ra_session_url(const char **old_session_url,
276 svn_ra_session_t *ra_session,
277 const char *session_url,
278 apr_pool_t *pool);
280 /* Set REPOS_ROOT to the URL which represents the root of the
281 repository in with PATH_OR_URL (at PEG_REVISION) is versioned. Use
282 the authentication baton cached in CTX as necessary.
284 ADM_ACCESS is a working copy administrative access baton associated
285 with PATH_OR_URL (if PATH_OR_URL is a working copy path), or NULL.
287 Use POOL for all allocations. */
288 svn_error_t *
289 svn_client__get_repos_root(const char **repos_root,
290 const char *path_or_url,
291 const svn_opt_revision_t *peg_revision,
292 svn_wc_adm_access_t *adm_access,
293 svn_client_ctx_t *ctx,
294 apr_pool_t *pool);
296 /* Return the path of PATH_OR_URL relative to the repository root
297 (REPOS_ROOT) in REL_PATH (URI-decoded). If INCLUDE_LEADING_SLASH
298 is set, the returned result will have a leading slash; otherwise,
299 it will not.
301 The remaining parameters are used to procure the repository root.
302 Either REPOS_ROOT or RA_SESSION -- but not both -- may be NULL.
303 REPOS_ROOT or ADM_ACCESS (which may also be NULL) should be passed
304 when available as an optimization (in that order of preference).
306 CAUTION: While having a leading slash on a so-called relative path
307 might work out well for functionality that interacts with
308 mergeinfo, it results in a relative path that cannot be naively
309 svn_path_join()'d with a repository root URL to provide a full URL.
311 svn_error_t *
312 svn_client__path_relative_to_root(const char **rel_path,
313 const char *path_or_url,
314 const char *repos_root,
315 svn_boolean_t include_leading_slash,
316 svn_ra_session_t *ra_session,
317 svn_wc_adm_access_t *adm_access,
318 apr_pool_t *pool);
320 /* Return the property value for any PROPNAME set on TARGET in *PROPS,
321 with WC paths of char * for keys and property values of
322 svn_string_t * for values. Assumes that PROPS is non-NULL.
324 Treat DEPTH as in svn_client_propget4().
326 svn_error_t *
327 svn_client__get_prop_from_wc(apr_hash_t *props, const char *propname,
328 const char *target, svn_boolean_t pristine,
329 const svn_wc_entry_t *entry,
330 svn_wc_adm_access_t *adm_access,
331 svn_depth_t depth, svn_client_ctx_t *ctx,
332 apr_pool_t *pool);
334 /* Retrieve the oldest revision of the node at REL_PATH at REV since
335 it was last copied (if applicable), and store it in OLDEST_REV. If
336 REL_PATH does not exist in that REV, set *OLDEST_REV to
337 SVN_INVALID_REVNUM. Use POOL for temporary allocations. */
338 svn_error_t *
339 svn_client__oldest_rev_at_path(svn_revnum_t *oldest_rev,
340 svn_ra_session_t *ra_session,
341 const char *rel_path,
342 svn_revnum_t rev,
343 apr_pool_t *pool);
345 /* A default error handler for use with svn_wc_walk_entries3(). Returns
346 ERR in all cases. */
347 svn_error_t *
348 svn_client__default_walker_error_handler(const char *path,
349 svn_error_t *err,
350 void *walk_baton,
351 apr_pool_t *pool);
354 /* ---------------------------------------------------------------- */
356 /*** RA callbacks ***/
359 /* CTX is of type "svn_client_ctx_t *". */
360 #define SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx) \
361 ((ctx)->log_msg_func3 || (ctx)->log_msg_func2 || (ctx)->log_msg_func)
363 /* This is the baton that we pass svn_ra_open2(), and is associated with
364 the callback table we provide to RA. */
365 typedef struct
367 /* Holds the directory that corresponds to the REPOS_URL at svn_ra_open2()
368 time. When callbacks specify a relative path, they are joined with
369 this base directory. */
370 const char *base_dir;
371 svn_wc_adm_access_t *base_access;
373 /* When true, makes sure temporary files are created
374 outside the working copy. */
375 svn_boolean_t read_only_wc;
377 /* An array of svn_client_commit_item3_t * structures, present only
378 during working copy commits. */
379 apr_array_header_t *commit_items;
381 /* A client context. */
382 svn_client_ctx_t *ctx;
384 /* The pool to use for session-related items. */
385 apr_pool_t *pool;
387 } svn_client__callback_baton_t;
390 /* Open an RA session, returning it in *RA_SESSION.
392 The root of the session is specified by BASE_URL and BASE_DIR.
393 BASE_ACCESS is an access baton for BASE_DIR administrative data.
395 Additional control parameters:
397 - COMMIT_ITEMS is an array of svn_client_commit_item_t *
398 structures, present only for working copy commits, NULL otherwise.
400 - USE_ADMIN indicates that the RA layer should create tempfiles
401 in the administrative area instead of in the working copy itself,
402 and read properties from the administrative area.
404 - READ_ONLY_WC indicates that the RA layer should not attempt to
405 modify the WC props directly.
407 BASE_DIR may be NULL if the RA operation does not correspond to a
408 working copy (in which case, USE_ADMIN should be FALSE, and
409 BASE_ACCESS should be null).
411 The calling application's authentication baton is provided in CTX,
412 and allocations related to this session are performed in POOL.
414 NOTE: The reason for the _internal suffix of this function's name is to
415 avoid confusion with the public API svn_client_open_ra_session(). */
416 svn_error_t *
417 svn_client__open_ra_session_internal(svn_ra_session_t **ra_session,
418 const char *base_url,
419 const char *base_dir,
420 svn_wc_adm_access_t *base_access,
421 apr_array_header_t *commit_items,
422 svn_boolean_t use_admin,
423 svn_boolean_t read_only_wc,
424 svn_client_ctx_t *ctx,
425 apr_pool_t *pool);
429 /* ---------------------------------------------------------------- */
431 /*** Commit ***/
433 /* Get the commit_baton to be used in couple with commit_callback. */
434 svn_error_t *svn_client__commit_get_baton(void **baton,
435 svn_commit_info_t **info,
436 apr_pool_t *pool);
438 /* The commit_callback function for storing svn_client_commit_info_t
439 pointed by commit_baton. If the commit_info supplied by get_baton
440 points to NULL after close_edit, it means the commit is a no-op.
442 svn_error_t *svn_client__commit_callback(const svn_commit_info_t *commit_info,
443 void *baton,
444 apr_pool_t *pool);
446 /* ---------------------------------------------------------------- */
448 /*** Status ***/
450 /* Verify that the path can be deleted without losing stuff,
451 i.e. ensure that there are no modified or unversioned resources
452 under PATH. This is similar to checking the output of the status
453 command. CTX is used for the client's config options. POOL is
454 used for all temporary allocations. */
455 svn_error_t * svn_client__can_delete(const char *path,
456 svn_client_ctx_t *ctx,
457 apr_pool_t *pool);
460 /* ---------------------------------------------------------------- */
462 /*** Add/delete ***/
464 /* Read automatic properties matching PATH from CTX->config.
465 Set *PROPERTIES to a hash containing propname/value pairs
466 (const char * keys mapping to svn_string_t * values), or if
467 auto-props are disabled, set *PROPERTIES to NULL.
468 Set *MIMETYPE to the mimetype, if any, or to NULL.
469 Allocate the hash table, keys, values, and mimetype in POOL. */
470 svn_error_t *svn_client__get_auto_props(apr_hash_t **properties,
471 const char **mimetype,
472 const char *path,
473 svn_client_ctx_t *ctx,
474 apr_pool_t *pool);
477 /* The main logic for client deletion from a working copy. Deletes PATH
478 from ADM_ACCESS. If PATH (or any item below a directory PATH) is
479 modified the delete will fail and return an error unless FORCE or KEEP_LOCAL
480 is TRUE.
482 If KEEP_LOCAL is TRUE then PATH is only scheduled from deletion from the
483 repository and a local copy of PATH will be kept in the working copy.
485 If DRY_RUN is TRUE all the checks are made to ensure that the delete can
486 occur, but the working copy is not modified. If NOTIFY_FUNC is not
487 null, it is called with NOTIFY_BATON for each file or directory deleted. */
488 svn_error_t * svn_client__wc_delete(const char *path,
489 svn_wc_adm_access_t *adm_access,
490 svn_boolean_t force,
491 svn_boolean_t dry_run,
492 svn_boolean_t keep_local,
493 svn_wc_notify_func2_t notify_func,
494 void *notify_baton,
495 svn_client_ctx_t *ctx,
496 apr_pool_t *pool);
498 /* Return the set of WC paths to entries which would have been deleted
499 by an update/merge if not in "dry run" mode, or NULL if not in "dry
500 run" mode. MERGE_CMD_BATON is expected to be of type "struct
501 merge_cmd_baton" (from merge.c). It contains the list, which is
502 intended for direct modification. */
503 apr_hash_t *svn_client__dry_run_deletions(void *merge_cmd_baton);
505 /* Make PATH and add it to the working copy, optionally making all the
506 intermediate parent directories if MAKE_PARENTS is TRUE. */
507 svn_error_t *
508 svn_client__make_local_parents(const char *path,
509 svn_boolean_t make_parents,
510 svn_client_ctx_t *ctx,
511 apr_pool_t *pool);
513 /* ---------------------------------------------------------------- */
515 /*** Checkout, update and switch ***/
517 /* Update a working copy PATH to REVISION, and (if not NULL) set
518 RESULT_REV to the update revision.
520 If DEPTH is svn_depth_unknown, then use whatever depth is already
521 set for PATH, or @c svn_depth_infinity if PATH does not exist.
523 Else if DEPTH is svn_depth_infinity, then update fully recursively
524 (resetting the existing depth of the working copy if necessary).
525 Else if DEPTH is svn_depth_files, update all files under PATH (if
526 any), but exclude any subdirectories. Else if DEPTH is
527 svn_depth_immediates, update all files and include immediate
528 subdirectories (at svn_depth_empty). Else if DEPTH is
529 svn_depth_empty, just update PATH; if PATH is a directory, that
530 means touching only its properties not its entries.
532 If IGNORE_EXTERNALS is true, do no externals processing.
534 If TIMESTAMP_SLEEP is NULL this function will sleep before
535 returning to ensure timestamp integrity. If TIMESTAMP_SLEEP is not
536 NULL then the function will not sleep but will set *TIMESTAMP_SLEEP
537 to TRUE if a sleep is required, and will not change
538 *TIMESTAMP_SLEEP if no sleep is required.
540 If ALLOW_UNVER_OBSTRUCTIONS is TRUE, unversioned children of PATH
541 that obstruct items added from the repos are tolerated; if FALSE,
542 these obstructions cause the update to fail.
544 If SEND_COPYFROM_ARGS is true, then request that the server not
545 send file contents when adding files that have been created by
546 explicit copying; instead, just send copyfrom-args to add_file(),
547 and possibly follow up with an apply_textdelta() against the copied
548 file.
550 svn_error_t *
551 svn_client__update_internal(svn_revnum_t *result_rev,
552 const char *path,
553 const svn_opt_revision_t *revision,
554 svn_depth_t depth,
555 svn_boolean_t ignore_externals,
556 svn_boolean_t allow_unver_obstructions,
557 svn_boolean_t *timestamp_sleep,
558 svn_boolean_t send_copyfrom_args,
559 svn_client_ctx_t *ctx,
560 apr_pool_t *pool);
562 /* Checkout into PATH a working copy of URL at REVISION, and (if not
563 NULL) set RESULT_REV to the checked out revision.
565 If DEPTH is svn_depth_infinity, then check out fully recursively.
566 Else if DEPTH is svn_depth_files, checkout all files under PATH (if
567 any), but not subdirectories. Else if DEPTH is
568 svn_depth_immediates, check out all files and include immediate
569 subdirectories (at svn_depth_empty). Else if DEPTH is
570 svn_depth_empty, just check out PATH, with none of its entries.
572 DEPTH must be a definite depth, not (e.g.) svn_depth_unknown.
574 If IGNORE_EXTERNALS is true, do no externals processing.
576 If TIMESTAMP_SLEEP is NULL this function will sleep before
577 returning to ensure timestamp integrity. If TIMESTAMP_SLEEP is not
578 NULL then the function will not sleep but will set *TIMESTAMP_SLEEP
579 to TRUE if a sleep is required, and will not change
580 *TIMESTAMP_SLEEP if no sleep is required. If
581 ALLOW_UNVER_OBSTRUCTIONS is TRUE, unversioned children of PATH that
582 obstruct items added from the repos are tolerated; if FALSE, these
583 obstructions cause the checkout to fail. */
584 svn_error_t *
585 svn_client__checkout_internal(svn_revnum_t *result_rev,
586 const char *URL,
587 const char *path,
588 const svn_opt_revision_t *peg_revision,
589 const svn_opt_revision_t *revision,
590 svn_depth_t depth,
591 svn_boolean_t ignore_externals,
592 svn_boolean_t allow_unver_obstructions,
593 svn_boolean_t *timestamp_sleep,
594 svn_client_ctx_t *ctx,
595 apr_pool_t *pool);
597 /* Switch a working copy PATH to URL@PEG_REVISION at REVISION, and (if not
598 NULL) set RESULT_REV to the switch revision. Only switch as deeply as DEPTH
599 indicates. If TIMESTAMP_SLEEP is NULL this function will sleep before
600 returning to ensure timestamp integrity. If TIMESTAMP_SLEEP is not
601 NULL then the function will not sleep but will set *TIMESTAMP_SLEEP
602 to TRUE if a sleep is required, and will not change
603 *TIMESTAMP_SLEEP if no sleep is required. If IGNORE_EXTERNALS is true,
604 don't process externals. If ALLOW_UNVER_OBSTRUCTIONS is TRUE, unversioned
605 children of PATH that obstruct items added from the repos are tolerated;
606 if FALSE, these obstructions cause the switch to fail. */
607 svn_error_t *
608 svn_client__switch_internal(svn_revnum_t *result_rev,
609 const char *path,
610 const char *url,
611 const svn_opt_revision_t *peg_revision,
612 const svn_opt_revision_t *revision,
613 svn_depth_t depth,
614 svn_boolean_t *timestamp_sleep,
615 svn_boolean_t ignore_externals,
616 svn_boolean_t allow_unver_obstructions,
617 svn_client_ctx_t *ctx,
618 apr_pool_t *pool);
620 /* ---------------------------------------------------------------- */
622 /*** Editor for repository diff ***/
624 /* Create an editor for a pure repository comparison, i.e. comparing one
625 repository version against the other.
627 TARGET is a working-copy path, the base of the hierarchy to be
628 compared. It corresponds to the URL opened in RA_SESSION below.
630 ADM_ACCESS is an access baton with a write lock for the anchor of
631 TARGET. It should lock the entire TARGET tree if RECURSE is TRUE.
632 ADM_ACCESS may be NULL, in which case the DIFF_CMD callbacks will be
633 passed a NULL access baton.
635 DIFF_CMD/DIFF_CMD_BATON represent the callback and callback argument that
636 implement the file comparison function
638 DEPTH is the depth to recurse.
640 DRY_RUN is set if this is a dry-run merge. It is not relevant for diff.
642 RA_SESSION defines the additional RA session for requesting file
643 contents.
645 REVISION is the start revision in the comparison.
647 If NOTIFY_FUNC is non-null, invoke it with NOTIFY_BATON for each
648 file and directory operated on during the edit.
650 EDITOR/EDIT_BATON return the newly created editor and baton/ */
651 svn_error_t *
652 svn_client__get_diff_editor(const char *target,
653 svn_wc_adm_access_t *adm_access,
654 const svn_wc_diff_callbacks2_t *diff_cmd,
655 void *diff_cmd_baton,
656 svn_depth_t depth,
657 svn_boolean_t dry_run,
658 svn_ra_session_t *ra_session,
659 svn_revnum_t revision,
660 svn_wc_notify_func2_t notify_func,
661 void *notify_baton,
662 svn_cancel_func_t cancel_func,
663 void *cancel_baton,
664 const svn_delta_editor_t **editor,
665 void **edit_baton,
666 apr_pool_t *pool);
669 /* ---------------------------------------------------------------- */
671 /*** Editor for diff summary ***/
673 /* Create an editor for a repository diff summary, i.e. comparing one
674 repository version against the other and only providing information
675 about the changed items without the text deltas.
677 TARGET is the target of the diff, relative to the root of the edit.
679 SUMMARIZE_FUNC is called with SUMMARIZE_BATON as parameter by the
680 created svn_delta_editor_t for each changed item.
682 See svn_client__get_diff_editor() for a description of the other
683 parameters. */
684 svn_error_t *
685 svn_client__get_diff_summarize_editor(const char *target,
686 svn_client_diff_summarize_func_t
687 summarize_func,
688 void *summarize_baton,
689 svn_ra_session_t *ra_session,
690 svn_revnum_t revision,
691 svn_cancel_func_t cancel_func,
692 void *cancel_baton,
693 const svn_delta_editor_t **editor,
694 void **edit_baton,
695 apr_pool_t *pool);
697 /* ---------------------------------------------------------------- */
699 /*** Copy Stuff ***/
701 /* This structure is used to associate a specific copy or move SRC with a
702 specific copy or move destination. It also contains information which
703 various helper functions may need. Not every copy function uses every
704 field.
706 typedef struct
708 /* The source path or url. */
709 const char *src;
711 /* The absolute path of the source. */
712 const char *src_abs;
714 /* The base name of the object. It should be the same for both src
715 and dst. */
716 const char *base_name;
718 /* The node kind of the source */
719 svn_node_kind_t src_kind;
721 /* The original source name. (Used when the source gets overwritten by a
722 peg revision lookup.) */
723 const char *src_original;
725 /* The source operational revision. */
726 svn_opt_revision_t src_op_revision;
728 /* The source peg revision. */
729 svn_opt_revision_t src_peg_revision;
731 /* The source revision number. */
732 svn_revnum_t src_revnum;
734 /* The destination path or url */
735 const char *dst;
737 /* The destination's parent path */
738 const char *dst_parent;
739 } svn_client__copy_pair_t;
741 /* ---------------------------------------------------------------- */
743 /*** Commit Stuff ***/
745 /* WARNING: This is all new, untested, un-peer-reviewed conceptual
746 stuff.
748 The day that 'svn switch' came into existence, our old commit
749 crawler (svn_wc_crawl_local_mods) became obsolete. It relied far
750 too heavily on the on-disk hierarchy of files and directories, and
751 simply had no way to support disjoint working copy trees or nest
752 working copies. The primary reason for this is that commit
753 process, in order to guarantee atomicity, is a single drive of a
754 commit editor which is based not on working copy paths, but on
755 URLs. With the completion of 'svn switch', it became all too
756 likely that the on-disk working copy hierarchy would no longer be
757 guaranteed to map to a similar in-repository hierarchy.
759 Aside from this new brokenness of the old system, an unrelated
760 feature request had cropped up -- the ability to know in advance of
761 your commit, exactly what would be committed (so that log messages
762 could be initially populated with this information). Since the old
763 crawler discovered commit candidates while in the process of
764 committing, it was impossible to harvest this information upfront.
765 As a workaround, svn_wc_statuses() was used to stat the whole
766 working copy for changes before the commit started...and then the
767 commit would again stat the whole tree for changes.
769 Enter the new system.
771 The primary goal of this system is very straightforward: harvest
772 all commit candidate information up front, and cache enough info in
773 the process to use this to drive a URL-sorted commit.
775 *** END-OF-KNOWLEDGE ***
777 The prototypes below are still in development. In general, the
778 idea is that commit-y processes ('svn mkdir URL', 'svn delete URL',
779 'svn commit', 'svn copy WC_PATH URL', 'svn copy URL1 URL2', 'svn
780 move URL1 URL2', others?) generate the cached commit candidate
781 information, and hand this information off to a consumer which is
782 responsible for driving the RA layer's commit editor in a
783 URL-depth-first fashion and reporting back the post-commit
784 information.
790 /* ### This is TEMPORARY! Until we can find out the canonical
791 repository URL of a given entry, we'll just use this bogus value in
792 for our single committables hash key. By the time we support
793 multiple repositories we will have to be storing the canonical
794 repository URLs anyway, so this will go away and the real URLs will
795 be the keys of the committables hash. */
796 #define SVN_CLIENT__SINGLE_REPOS_NAME "svn:single-repos"
799 /* Recursively crawl a set of working copy paths (PARENT_DIR + each
800 item in the TARGETS array) looking for commit candidates, locking
801 working copy directories as the crawl progresses. For each
802 candidate found:
804 - create svn_client_commit_item_t for the candidate.
806 - add the structure to an apr_array_header_t array of commit
807 items that are in the same repository, creating a new array if
808 necessary.
810 - add (or update) a reference to this array to the COMMITTABLES
811 hash, keyed on the canonical repository name. ### todo, until
812 multi-repository support actually exists, the single key here
813 will actually be some arbitrary thing to be ignored.
815 - if the candidate has a lock token, add it to the LOCK_TOKENS hash.
817 - if the candidate is a directory scheduled for deletion, crawl
818 the directories children recursively for any lock tokens and
819 add them to the LOCK_TOKENS array.
821 At the successful return of this function, COMMITTABLES will be an
822 apr_hash_t * hash of apr_array_header_t * arrays (of
823 svn_client_commit_item_t * structures), keyed on const char *
824 canonical repository URLs. LOCK_TOKENS will point to a hash table
825 with const char * lock tokens, keyed on const char * URLs. Also,
826 LOCKED_DIRS will be an apr_hash_t * hash of svn_wc_adm_access_t *
827 keyed on const char * working copy path directory names which were
828 locked in the process of this crawl. These will need to be
829 unlocked again post-commit.
831 If DEPTH is specified, descend (or not) into each target in TARGETS
832 as specified by DEPTH; the behavior is the same as that described
833 for svn_client_commit4().
835 If JUST_LOCKED is TRUE, treat unmodified items with lock tokens as
836 commit candidates.
838 If CHANGELIST_NAME is non-NULL, then use it as a restrictive filter
839 when harvesting committables; that is, don't add a path to
840 COMMITTABLES unless it's a member of the changelist.
842 If CTX->CANCEL_FUNC is non-null, it will be called with
843 CTX->CANCEL_BATON while harvesting to determine if the client has
844 cancelled the operation. */
845 svn_error_t *
846 svn_client__harvest_committables(apr_hash_t **committables,
847 apr_hash_t **lock_tokens,
848 svn_wc_adm_access_t *parent_dir,
849 apr_array_header_t *targets,
850 svn_depth_t depth,
851 svn_boolean_t just_locked,
852 const char *changelist_name,
853 svn_client_ctx_t *ctx,
854 apr_pool_t *pool);
857 /* Recursively crawl each working copy path SRC in COPY_PAIRS, harvesting
858 commit_items into a COMMITABLES hash (see the docstring for
859 svn_client__harvest_committables for what that really means, and
860 for the relevance of LOCKED_DIRS) as if every entry at or below
861 the SRC was to be committed as a set of adds (mostly with history)
862 to a new repository URL (DST in COPY_PAIRS).
864 If CTX->CANCEL_FUNC is non-null, it will be called with
865 CTX->CANCEL_BATON while harvesting to determine if the client has
866 cancelled the operation. */
867 svn_error_t *
868 svn_client__get_copy_committables(apr_hash_t **committables,
869 const apr_array_header_t *copy_pairs,
870 svn_wc_adm_access_t *adm_access,
871 svn_client_ctx_t *ctx,
872 apr_pool_t *pool);
875 /* A qsort()-compatible sort routine for sorting an array of
876 svn_client_commit_item_t's by their URL member. */
877 int svn_client__sort_commit_item_urls(const void *a, const void *b);
880 /* Rewrite the COMMIT_ITEMS array to be sorted by URL. Also, discover
881 a common *BASE_URL for the items in the array, and rewrite those
882 items' URLs to be relative to that *BASE_URL.
884 Afterwards, some of the items in COMMIT_ITEMS may contain data
885 allocated in POOL. */
886 svn_error_t *
887 svn_client__condense_commit_items(const char **base_url,
888 apr_array_header_t *commit_items,
889 apr_pool_t *pool);
892 /* Commit the items in the COMMIT_ITEMS array using EDITOR/EDIT_BATON
893 to describe the committed local mods. Prior to this call,
894 COMMIT_ITEMS should have been run through (and BASE_URL generated
895 by) svn_client__condense_commit_items.
897 CTX->NOTIFY_FUNC/CTX->BATON will be called as the commit progresses, as
898 a way of describing actions to the application layer (if non NULL).
900 NOTIFY_PATH_PREFIX is used to send shorter, relative paths to the
901 notify_func (it's a prefix that will be subtracted from the front
902 of the paths.)
904 If the caller wants to keep track of any outstanding temporary
905 files left after the transmission of text and property mods,
906 *TEMPFILES is the place to look.
908 MD5 checksums, if available, for the new text bases of committed
909 files are stored in *DIGESTS, which maps const char* paths (from the
910 items' paths) to const unsigned char* digests. DIGESTS may be
911 null. */
912 svn_error_t *
913 svn_client__do_commit(const char *base_url,
914 apr_array_header_t *commit_items,
915 svn_wc_adm_access_t *adm_access,
916 const svn_delta_editor_t *editor,
917 void *edit_baton,
918 const char *notify_path_prefix,
919 apr_hash_t **tempfiles,
920 apr_hash_t **digests,
921 svn_client_ctx_t *ctx,
922 apr_pool_t *pool);
926 /*** Externals (Modules) ***/
928 /* Handle changes to the svn:externals property in the tree traversed
929 by TRAVERSAL_INFO (obtained from svn_wc_get_update_editor or
930 svn_wc_get_switch_editor, for example). The tree's top level
931 directory is at TO_PATH and corresponds to FROM_URL URL in the
932 repository, which has a root URL of REPOS_ROOT_URL.
934 For each changed value of the property, discover the nature of the
935 change and behave appropriately -- either check a new "external"
936 subdir, or call svn_wc_remove_from_revision_control() on an
937 existing one, or both.
939 REQUESTED_DEPTH is the requested depth of the driving operation
940 (e.g., update, switch, etc). If it is neither svn_depth_infinity
941 nor svn_depth_unknown, then changes to svn:externals will have no
942 effect. If REQUESTED_DEPTH is svn_depth_unknown, then the ambient
943 depth of each working copy directory holding an svn:externals value
944 will determine whether that value is interpreted there (the ambient
945 depth must be svn_depth_infinity). If REQUESTED_DEPTH is
946 svn_depth_infinity, then it is presumed to be expanding any
947 shallower ambient depth, so changes to svn:externals values will be
948 interpreted.
950 Pass NOTIFY_FUNC with NOTIFY_BATON along to svn_client_checkout().
952 ### todo: AUTH_BATON may not be so useful. It's almost like we
953 need access to the original auth-obtaining callbacks that
954 produced auth baton in the first place. Hmmm. ###
956 If UPDATE_UNCHANGED, then run svn_client_update() on any external
957 items that are the same in both the before and after traversal
958 info.
960 *TIMESTAMP_SLEEP will be set TRUE if a sleep is required to ensure
961 timestamp integrity, *TIMESTAMP_SLEEP will be unchanged if no sleep
962 is required.
964 Use POOL for temporary allocation. */
965 svn_error_t *
966 svn_client__handle_externals(svn_wc_traversal_info_t *traversal_info,
967 const char *from_url,
968 const char *to_path,
969 const char *repos_root_url,
970 svn_depth_t requested_depth,
971 svn_boolean_t update_unchanged,
972 svn_boolean_t *timestamp_sleep,
973 svn_client_ctx_t *ctx,
974 apr_pool_t *pool);
977 /* Fetch externals definitions described by EXTERNALS, a hash of the
978 form returned by svn_wc_edited_externals() (which see). If
979 IS_EXPORT is set, the external items will be exported instead of
980 checked out -- they will have no administrative subdirectories.
982 The checked out or exported tree's top level directory is at
983 TO_PATH and corresponds to FROM_URL URL in the repository, which
984 has a root URL of REPOS_ROOT_URL.
986 REQUESTED_DEPTH is the requested_depth of the driving operation; it
987 behaves as for svn_client__handle_externals(), except that ambient
988 depths are presumed to be svn_depth_infinity.
990 *TIMESTAMP_SLEEP will be set TRUE if a sleep is required to ensure
991 timestamp integrity, *TIMESTAMP_SLEEP will be unchanged if no sleep
992 is required.
994 Use POOL for temporary allocation. */
995 svn_error_t *
996 svn_client__fetch_externals(apr_hash_t *externals,
997 const char *from_url,
998 const char *to_path,
999 const char *repos_root_url,
1000 svn_depth_t requested_depth,
1001 svn_boolean_t is_export,
1002 svn_boolean_t *timestamp_sleep,
1003 svn_client_ctx_t *ctx,
1004 apr_pool_t *pool);
1007 /* Perform status operations on each external in TRAVERSAL_INFO. All
1008 other options are the same as those passed to svn_client_status(). */
1009 svn_error_t *
1010 svn_client__do_external_status(svn_wc_traversal_info_t *traversal_info,
1011 svn_wc_status_func2_t status_func,
1012 void *status_baton,
1013 svn_depth_t depth,
1014 svn_boolean_t get_all,
1015 svn_boolean_t update,
1016 svn_boolean_t no_ignore,
1017 svn_client_ctx_t *ctx,
1018 apr_pool_t *pool);
1022 /* Retrieve log messages using the first provided (non-NULL) callback
1023 in the set of *CTX->log_msg_func3, CTX->log_msg_func2, or
1024 CTX->log_msg_func. Other arguments same as
1025 svn_client_get_commit_log3_t. */
1026 svn_error_t *
1027 svn_client__get_log_msg(const char **log_msg,
1028 const char **tmp_file,
1029 const apr_array_header_t *commit_items,
1030 svn_client_ctx_t *ctx,
1031 apr_pool_t *pool);
1033 /* Return the revision properties stored in CTX (if any), adding LOG_MSG
1034 as SVN_PROP_REVISION_LOG in *REVPROP_TABLE, allocated in POOL.
1035 *REVPROP_TABLE will map const char * property names to svn_string_t values.
1036 If CTX->REVPROP_TABLE is non-NULL, check that it doesn't contain
1037 any of the standard Subversion properties. In that case, return
1038 SVN_ERR_CLIENT_PROPERTY_NAME. */
1039 svn_error_t *svn_client__get_revprop_table(apr_hash_t **revprop_table,
1040 const char *log_msg,
1041 svn_client_ctx_t *ctx,
1042 apr_pool_t *pool);
1045 #ifdef __cplusplus
1047 #endif /* __cplusplus */
1049 #endif /* SVN_LIBSVN_CLIENT_H */