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 * ====================================================================
24 * @brief structures related to repository access, private to libsvn_ra and the
25 * RA implementation libraries.
30 #ifndef LIBSVN_RA_RA_LOADER_H
31 #define LIBSVN_RA_RA_LOADER_H
35 #include "private/svn_ra_private.h"
41 /* Prototype of most recent version of svn_ra_openX() api, optionally
42 handed to the ra api to allow opening other ra sessions. */
43 typedef svn_error_t * (*svn_ra__open_func_t)(svn_ra_session_t **session_p,
44 const char **corrected_url,
45 const char *repos_URL,
47 const svn_ra_callbacks2_t *callbacks,
52 /* The RA layer vtable. */
53 typedef struct svn_ra__vtable_t {
54 /* This field should always remain first in the vtable. */
55 const svn_version_t *(*get_version)(void);
57 /* Return a short description of the RA implementation, as a localized
59 const char *(*get_description)(apr_pool_t *pool);
61 /* Return a list of actual URI schemes supported by this implementation.
62 * The returned array is NULL-terminated. */
63 const char * const *(*get_schemes)(apr_pool_t *pool);
65 /* Implementations of the public API functions. */
67 /* See svn_ra_open4(). */
68 /* All fields in SESSION, except priv, have been initialized by the
69 time this is called. SESSION->priv may be set by this function. */
70 svn_error_t *(*open_session)(svn_ra_session_t *session,
71 const char **corrected_url,
72 const char *session_URL,
73 const svn_ra_callbacks2_t *callbacks,
75 svn_auth_baton_t *auth_baton,
77 apr_pool_t *result_pool,
78 apr_pool_t *scratch_pool);
79 /* Backs svn_ra_dup_session */
80 svn_error_t * (*dup_session)(svn_ra_session_t *new_session,
81 svn_ra_session_t *old_session,
82 const char *new_session_url,
83 apr_pool_t *result_pool,
84 apr_pool_t *scratch_pool);
85 /* See svn_ra_reparent(). */
86 /* URL is guaranteed to have what get_repos_root() returns as a prefix. */
87 svn_error_t *(*reparent)(svn_ra_session_t *session,
90 /* See svn_ra_get_session_url(). */
91 svn_error_t *(*get_session_url)(svn_ra_session_t *session,
94 /* See svn_ra_get_latest_revnum(). */
95 svn_error_t *(*get_latest_revnum)(svn_ra_session_t *session,
96 svn_revnum_t *latest_revnum,
98 /* See svn_ra_get_dated_revision(). */
99 svn_error_t *(*get_dated_revision)(svn_ra_session_t *session,
100 svn_revnum_t *revision,
103 /* See svn_ra_change_rev_prop2(). */
104 svn_error_t *(*change_rev_prop)(svn_ra_session_t *session,
107 const svn_string_t *const *old_value_p,
108 const svn_string_t *value,
111 /* See svn_ra_rev_proplist(). */
112 svn_error_t *(*rev_proplist)(svn_ra_session_t *session,
116 /* See svn_ra_rev_prop(). */
117 svn_error_t *(*rev_prop)(svn_ra_session_t *session,
120 svn_string_t **value,
122 /* See svn_ra_get_commit_editor3(). */
123 svn_error_t *(*get_commit_editor)(svn_ra_session_t *session,
124 const svn_delta_editor_t **editor,
126 apr_hash_t *revprop_table,
127 svn_commit_callback2_t callback,
128 void *callback_baton,
129 apr_hash_t *lock_tokens,
130 svn_boolean_t keep_locks,
132 /* See svn_ra_get_file(). */
133 svn_error_t *(*get_file)(svn_ra_session_t *session,
135 svn_revnum_t revision,
136 svn_stream_t *stream,
137 svn_revnum_t *fetched_rev,
140 /* See svn_ra_get_dir2(). */
141 svn_error_t *(*get_dir)(svn_ra_session_t *session,
142 apr_hash_t **dirents,
143 svn_revnum_t *fetched_rev,
146 svn_revnum_t revision,
147 apr_uint32_t dirent_fields,
149 /* See svn_ra_get_mergeinfo(). */
150 svn_error_t *(*get_mergeinfo)(svn_ra_session_t *session,
151 svn_mergeinfo_catalog_t *mergeinfo,
152 const apr_array_header_t *paths,
153 svn_revnum_t revision,
154 svn_mergeinfo_inheritance_t inherit,
155 svn_boolean_t include_merged_revisions,
157 /* See svn_ra_do_update3(). */
158 svn_error_t *(*do_update)(svn_ra_session_t *session,
159 const svn_ra_reporter3_t **reporter,
161 svn_revnum_t revision_to_update_to,
162 const char *update_target,
164 svn_boolean_t send_copyfrom_args,
165 svn_boolean_t ignore_ancestry,
166 const svn_delta_editor_t *update_editor,
168 apr_pool_t *result_pool,
169 apr_pool_t *scratch_pool);
170 /* See svn_ra_do_switch3(). */
171 svn_error_t *(*do_switch)(svn_ra_session_t *session,
172 const svn_ra_reporter3_t **reporter,
174 svn_revnum_t revision_to_switch_to,
175 const char *switch_target,
177 const char *switch_url,
178 svn_boolean_t send_copyfrom_args,
179 svn_boolean_t ignore_ancestry,
180 const svn_delta_editor_t *switch_editor,
182 apr_pool_t *result_pool,
183 apr_pool_t *scratch_pool);
184 /* See svn_ra_do_status2(). */
185 svn_error_t *(*do_status)(svn_ra_session_t *session,
186 const svn_ra_reporter3_t **reporter,
188 const char *status_target,
189 svn_revnum_t revision,
191 const svn_delta_editor_t *status_editor,
194 /* See svn_ra_do_diff3(). */
195 svn_error_t *(*do_diff)(svn_ra_session_t *session,
196 const svn_ra_reporter3_t **reporter,
198 svn_revnum_t revision,
199 const char *diff_target,
201 svn_boolean_t ignore_ancestry,
202 svn_boolean_t text_deltas,
203 const char *versus_url,
204 const svn_delta_editor_t *diff_editor,
207 /* See svn_ra_get_log2(). */
208 svn_error_t *(*get_log)(svn_ra_session_t *session,
209 const apr_array_header_t *paths,
213 svn_boolean_t discover_changed_paths,
214 svn_boolean_t strict_node_history,
215 svn_boolean_t include_merged_revisions,
216 const apr_array_header_t *revprops,
217 svn_log_entry_receiver_t receiver,
218 void *receiver_baton,
220 /* See svn_ra_check_path(). */
221 svn_error_t *(*check_path)(svn_ra_session_t *session,
223 svn_revnum_t revision,
224 svn_node_kind_t *kind,
226 /* See svn_ra_stat(). */
227 svn_error_t *(*stat)(svn_ra_session_t *session,
229 svn_revnum_t revision,
230 svn_dirent_t **dirent,
232 /* See svn_ra_get_uuid2(). */
233 svn_error_t *(*get_uuid)(svn_ra_session_t *session,
236 /* See svn_ra_get_repos_root2(). */
237 svn_error_t *(*get_repos_root)(svn_ra_session_t *session,
240 /* See svn_ra_get_locations(). */
241 svn_error_t *(*get_locations)(svn_ra_session_t *session,
242 apr_hash_t **locations,
244 svn_revnum_t peg_revision,
245 const apr_array_header_t *location_revisions,
247 /* See svn_ra_get_location_segments(). */
248 svn_error_t *(*get_location_segments)(svn_ra_session_t *session,
250 svn_revnum_t peg_revision,
251 svn_revnum_t start_rev,
252 svn_revnum_t end_rev,
253 svn_location_segment_receiver_t rcvr,
254 void *receiver_baton,
256 /* See svn_ra_get_file_revs2(). */
257 svn_error_t *(*get_file_revs)(svn_ra_session_t *session,
261 svn_boolean_t include_merged_revisions,
262 svn_file_rev_handler_t handler,
265 /* See svn_ra_lock(). */
266 svn_error_t *(*lock)(svn_ra_session_t *session,
267 apr_hash_t *path_revs,
270 svn_ra_lock_callback_t lock_func,
273 /* See svn_ra_unlock(). */
274 svn_error_t *(*unlock)(svn_ra_session_t *session,
275 apr_hash_t *path_tokens,
277 svn_ra_lock_callback_t lock_func,
280 /* See svn_ra_get_lock(). */
281 svn_error_t *(*get_lock)(svn_ra_session_t *session,
285 /* See svn_ra_get_locks2(). */
286 svn_error_t *(*get_locks)(svn_ra_session_t *session,
291 /* See svn_ra_replay(). */
292 svn_error_t *(*replay)(svn_ra_session_t *session,
293 svn_revnum_t revision,
294 svn_revnum_t low_water_mark,
295 svn_boolean_t text_deltas,
296 const svn_delta_editor_t *editor,
299 /* See svn_ra_has_capability(). */
300 svn_error_t *(*has_capability)(svn_ra_session_t *session,
302 const char *capability,
304 /* See svn_ra_replay_range(). */
306 (*replay_range)(svn_ra_session_t *session,
307 svn_revnum_t start_revision,
308 svn_revnum_t end_revision,
309 svn_revnum_t low_water_mark,
310 svn_boolean_t text_deltas,
311 svn_ra_replay_revstart_callback_t revstart_func,
312 svn_ra_replay_revfinish_callback_t revfinish_func,
315 /* See svn_ra_get_deleted_rev(). */
316 svn_error_t *(*get_deleted_rev)(svn_ra_session_t *session,
318 svn_revnum_t peg_revision,
319 svn_revnum_t end_revision,
320 svn_revnum_t *revision_deleted,
322 /* See svn_ra_get_inherited_props(). */
323 svn_error_t *(*get_inherited_props)(svn_ra_session_t *session,
324 apr_array_header_t **iprops,
326 svn_revnum_t revision,
327 apr_pool_t *result_pool,
328 apr_pool_t *scratch_pool);
329 /* If not NULL, receives a pointer to svn_ra_open, to alllow opening
330 a new ra session from inside the ra layer without a circular
332 svn_error_t *(*set_svn_ra_open)(svn_ra_session_t *session,
333 svn_ra__open_func_t func);
335 /* See svn_ra_list(). */
336 svn_error_t *(*list)(svn_ra_session_t *session,
338 svn_revnum_t revision,
339 const apr_array_header_t *patterns,
341 apr_uint32_t dirent_fields,
342 svn_ra_dirent_receiver_t receiver,
343 void *receiver_baton,
344 apr_pool_t *scratch_pool);
346 /* Experimental support below here */
348 /* See svn_ra__register_editor_shim_callbacks() */
349 svn_error_t *(*register_editor_shim_callbacks)(svn_ra_session_t *session,
350 svn_delta_shim_callbacks_t *callbacks);
351 /* See svn_ra__get_commit_ev2() */
352 svn_error_t *(*get_commit_ev2)(
353 svn_editor_t **editor,
354 svn_ra_session_t *session,
355 apr_hash_t *revprop_table,
356 svn_commit_callback2_t callback,
357 void *callback_baton,
358 apr_hash_t *lock_tokens,
359 svn_boolean_t keep_locks,
360 svn_ra__provide_base_cb_t provide_base_cb,
361 svn_ra__provide_props_cb_t provide_props_cb,
362 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
364 svn_cancel_func_t cancel_func,
366 apr_pool_t *result_pool,
367 apr_pool_t *scratch_pool);
369 /* See svn_ra__replay_range_ev2() */
370 svn_error_t *(*replay_range_ev2)(
371 svn_ra_session_t *session,
372 svn_revnum_t start_revision,
373 svn_revnum_t end_revision,
374 svn_revnum_t low_water_mark,
375 svn_boolean_t send_deltas,
376 svn_ra__replay_revstart_ev2_callback_t revstart_func,
377 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
379 apr_pool_t *scratch_pool);
383 /* The RA session object. */
384 struct svn_ra_session_t {
385 const svn_ra__vtable_t *vtable;
387 /* Cancellation handlers consumers may want to use. */
388 svn_cancel_func_t cancel_func;
391 /* Pool used to manage this session. */
394 /* Private data for the RA implementation. */
398 /* Each libsvn_ra_foo defines a function named svn_ra_foo__init of this type.
400 * The LOADER_VERSION parameter must remain first in the list, and the
401 * function must use the C calling convention on all platforms, so that
402 * the init functions can safely read the version parameter.
404 * POOL will be available as long as this module is being used.
406 * ### need to force this to be __cdecl on Windows... how??
408 typedef svn_error_t *
409 (*svn_ra__init_func_t)(const svn_version_t *loader_version,
410 const svn_ra__vtable_t **vtable,
413 /* Declarations of the init functions for the available RA libraries. */
414 svn_error_t *svn_ra_local__init(const svn_version_t *loader_version,
415 const svn_ra__vtable_t **vtable,
417 svn_error_t *svn_ra_svn__init(const svn_version_t *loader_version,
418 const svn_ra__vtable_t **vtable,
420 svn_error_t *svn_ra_serf__init(const svn_version_t *loader_version,
421 const svn_ra__vtable_t **vtable,
426 /*** Compat Functions ***/
429 * Set *LOCATIONS to the locations (at the repository revisions
430 * LOCATION_REVISIONS) of the file identified by PATH in PEG_REVISION.
431 * PATH is relative to the URL to which SESSION was opened.
432 * LOCATION_REVISIONS is an array of svn_revnum_t's. *LOCATIONS will
433 * be a mapping from the revisions to their appropriate absolute
434 * paths. If the file doesn't exist in a location_revision, that
435 * revision will be ignored.
437 * Use POOL for all allocations.
439 * NOTE: This function uses the RA get_log interfaces to do its work,
440 * as a fallback mechanism for servers which don't support the native
444 svn_ra__locations_from_log(svn_ra_session_t *session,
445 apr_hash_t **locations_p,
447 svn_revnum_t peg_revision,
448 const apr_array_header_t *location_revisions,
452 * Call RECEIVER (with RECEIVER_BATON) for each segment in the
453 * location history of PATH in START_REV, working backwards in time
454 * from START_REV to END_REV.
456 * END_REV may be SVN_INVALID_REVNUM to indicate that you want to
457 * trace the history of the object to its origin.
459 * START_REV may be SVN_INVALID_REVNUM to indicate that you want to
460 * trace the history of the object beginning in the HEAD revision.
461 * Otherwise, START_REV must be younger than END_REV (unless END_REV
462 * is SVN_INVALID_REVNUM).
464 * Use POOL for all allocations.
466 * NOTE: This function uses the RA get_log interfaces to do its work,
467 * as a fallback mechanism for servers which don't support the native
468 * get_location_segments API.
471 svn_ra__location_segments_from_log(svn_ra_session_t *session,
473 svn_revnum_t peg_revision,
474 svn_revnum_t start_rev,
475 svn_revnum_t end_rev,
476 svn_location_segment_receiver_t receiver,
477 void *receiver_baton,
481 * Retrieve a subset of the interesting revisions of a file PATH
482 * as seen in revision END (see svn_fs_history_prev() for a
483 * definition of "interesting revisions"). Invoke HANDLER with
484 * @a handler_baton as its first argument for each such revision.
485 * @a session is an open RA session. Use POOL for all allocations.
487 * If there is an interesting revision of the file that is less than or
488 * equal to START, the iteration will begin at that revision.
489 * Else, the iteration will begin at the first revision of the file in
490 * the repository, which has to be less than or equal to END. Note
491 * that if the function succeeds, HANDLER will have been called at
494 * In a series of calls to HANDLER, the file contents for the first
495 * interesting revision will be provided as a text delta against the
496 * empty file. In the following calls, the delta will be against the
497 * fulltext contents for the previous call.
499 * NOTE: This function uses the RA get_log interfaces to do its work,
500 * as a fallback mechanism for servers which don't support the native
501 * get_location_segments API.
504 svn_ra__file_revs_from_log(svn_ra_session_t *session,
508 svn_file_rev_handler_t handler,
514 * Given a path REL_DELETED_PATH, relative to the URL of SESSION, which
515 * exists at PEG_REVISION, and an END_REVISION > PEG_REVISION at which
516 * REL_DELETED_PATH no longer exists, set *REVISION_DELETED to the revision
517 * REL_DELETED_PATH was first deleted or replaced, within the inclusive
518 * revision range defined by PEG_REVISION and END_REVISION.
520 * If REL_DELETED_PATH does not exist at PEG_REVISION or was not deleted prior
521 * to END_REVISION within the specified range, then set *REVISION_DELETED to
522 * SVN_INVALID_REVNUM. If PEG_REVISION or END_REVISION are invalid or if
523 * END_REVISION <= PEG_REVISION, then return SVN_ERR_CLIENT_BAD_REVISION.
525 * Use POOL for all allocations.
527 * NOTE: This function uses the RA get_log interfaces to do its work,
528 * as a fallback mechanism for servers which don't support the native
529 * get_deleted_rev API.
532 svn_ra__get_deleted_rev_from_log(svn_ra_session_t *session,
533 const char *rel_deleted_path,
534 svn_revnum_t peg_revision,
535 svn_revnum_t end_revision,
536 svn_revnum_t *revision_deleted,
541 * Fallback logic for svn_ra_get_inherited_props() when that API
542 * need to find PATH's inherited properties on a legacy server that
543 * doesn't have the SVN_RA_CAPABILITY_INHERITED_PROPS capability.
545 * All arguments are as per svn_ra_get_inherited_props().
548 svn_ra__get_inherited_props_walk(svn_ra_session_t *session,
550 svn_revnum_t revision,
551 apr_array_header_t **inherited_props,
552 apr_pool_t *result_pool,
553 apr_pool_t *scratch_pool);
555 /* Utility function to provide a shim between a returned Ev2 and an RA
556 provider's Ev1-based commit editor.
558 See svn_ra__get_commit_ev2() for parameter semantics. */
560 svn_ra__use_commit_shim(svn_editor_t **editor,
561 svn_ra_session_t *session,
562 apr_hash_t *revprop_table,
563 svn_commit_callback2_t callback,
564 void *callback_baton,
565 apr_hash_t *lock_tokens,
566 svn_boolean_t keep_locks,
567 svn_ra__provide_base_cb_t provide_base_cb,
568 svn_ra__provide_props_cb_t provide_props_cb,
569 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
571 svn_cancel_func_t cancel_func,
573 apr_pool_t *result_pool,
574 apr_pool_t *scratch_pool);
576 /* Utility function to provide a shim between a returned Ev2 and an RA
577 provider's Ev1-based commit editor.
579 See svn_ra__replay_range_ev2() for parameter semantics. */
581 svn_ra__use_replay_range_shim(svn_ra_session_t *session,
582 svn_revnum_t start_revision,
583 svn_revnum_t end_revision,
584 svn_revnum_t low_water_mark,
585 svn_boolean_t send_deltas,
586 svn_ra__replay_revstart_ev2_callback_t revstart_func,
587 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
589 svn_ra__provide_base_cb_t provide_base_cb,
590 svn_ra__provide_props_cb_t provide_props_cb,
592 apr_pool_t *scratch_pool);