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 **redirect_url,
46 const char *repos_URL,
48 const svn_ra_callbacks2_t *callbacks,
53 /* The RA layer vtable. */
54 typedef struct svn_ra__vtable_t {
55 /* This field should always remain first in the vtable. */
56 const svn_version_t *(*get_version)(void);
58 /* Return a short description of the RA implementation, as a localized
60 const char *(*get_description)(apr_pool_t *pool);
62 /* Return a list of actual URI schemes supported by this implementation.
63 * The returned array is NULL-terminated. */
64 const char * const *(*get_schemes)(apr_pool_t *pool);
66 /* Implementations of the public API functions. */
68 /* See svn_ra_open5(). */
69 /* All fields in SESSION, except priv, have been initialized by the
70 time this is called. SESSION->priv may be set by this function. */
71 svn_error_t *(*open_session)(svn_ra_session_t *session,
72 const char **corrected_url,
73 const char **redirect_url,
74 const char *session_URL,
75 const svn_ra_callbacks2_t *callbacks,
77 svn_auth_baton_t *auth_baton,
79 apr_pool_t *result_pool,
80 apr_pool_t *scratch_pool);
81 /* Backs svn_ra_dup_session */
82 svn_error_t * (*dup_session)(svn_ra_session_t *new_session,
83 svn_ra_session_t *old_session,
84 const char *new_session_url,
85 apr_pool_t *result_pool,
86 apr_pool_t *scratch_pool);
87 /* See svn_ra_reparent(). */
88 /* URL is guaranteed to have what get_repos_root() returns as a prefix. */
89 svn_error_t *(*reparent)(svn_ra_session_t *session,
92 /* See svn_ra_get_session_url(). */
93 svn_error_t *(*get_session_url)(svn_ra_session_t *session,
96 /* See svn_ra_get_latest_revnum(). */
97 svn_error_t *(*get_latest_revnum)(svn_ra_session_t *session,
98 svn_revnum_t *latest_revnum,
100 /* See svn_ra_get_dated_revision(). */
101 svn_error_t *(*get_dated_revision)(svn_ra_session_t *session,
102 svn_revnum_t *revision,
105 /* See svn_ra_change_rev_prop2(). */
106 svn_error_t *(*change_rev_prop)(svn_ra_session_t *session,
109 const svn_string_t *const *old_value_p,
110 const svn_string_t *value,
113 /* See svn_ra_rev_proplist(). */
114 svn_error_t *(*rev_proplist)(svn_ra_session_t *session,
118 /* See svn_ra_rev_prop(). */
119 svn_error_t *(*rev_prop)(svn_ra_session_t *session,
122 svn_string_t **value,
124 /* See svn_ra_get_commit_editor3(). */
125 svn_error_t *(*get_commit_editor)(svn_ra_session_t *session,
126 const svn_delta_editor_t **editor,
128 apr_hash_t *revprop_table,
129 svn_commit_callback2_t callback,
130 void *callback_baton,
131 apr_hash_t *lock_tokens,
132 svn_boolean_t keep_locks,
134 /* See svn_ra_get_file(). */
135 svn_error_t *(*get_file)(svn_ra_session_t *session,
137 svn_revnum_t revision,
138 svn_stream_t *stream,
139 svn_revnum_t *fetched_rev,
142 /* See svn_ra_get_dir2(). */
143 svn_error_t *(*get_dir)(svn_ra_session_t *session,
144 apr_hash_t **dirents,
145 svn_revnum_t *fetched_rev,
148 svn_revnum_t revision,
149 apr_uint32_t dirent_fields,
151 /* See svn_ra_get_mergeinfo(). */
152 svn_error_t *(*get_mergeinfo)(svn_ra_session_t *session,
153 svn_mergeinfo_catalog_t *mergeinfo,
154 const apr_array_header_t *paths,
155 svn_revnum_t revision,
156 svn_mergeinfo_inheritance_t inherit,
157 svn_boolean_t include_merged_revisions,
159 /* See svn_ra_do_update3(). */
160 svn_error_t *(*do_update)(svn_ra_session_t *session,
161 const svn_ra_reporter3_t **reporter,
163 svn_revnum_t revision_to_update_to,
164 const char *update_target,
166 svn_boolean_t send_copyfrom_args,
167 svn_boolean_t ignore_ancestry,
168 const svn_delta_editor_t *update_editor,
170 apr_pool_t *result_pool,
171 apr_pool_t *scratch_pool);
172 /* See svn_ra_do_switch3(). */
173 svn_error_t *(*do_switch)(svn_ra_session_t *session,
174 const svn_ra_reporter3_t **reporter,
176 svn_revnum_t revision_to_switch_to,
177 const char *switch_target,
179 const char *switch_url,
180 svn_boolean_t send_copyfrom_args,
181 svn_boolean_t ignore_ancestry,
182 const svn_delta_editor_t *switch_editor,
184 apr_pool_t *result_pool,
185 apr_pool_t *scratch_pool);
186 /* See svn_ra_do_status2(). */
187 svn_error_t *(*do_status)(svn_ra_session_t *session,
188 const svn_ra_reporter3_t **reporter,
190 const char *status_target,
191 svn_revnum_t revision,
193 const svn_delta_editor_t *status_editor,
196 /* See svn_ra_do_diff3(). */
197 svn_error_t *(*do_diff)(svn_ra_session_t *session,
198 const svn_ra_reporter3_t **reporter,
200 svn_revnum_t revision,
201 const char *diff_target,
203 svn_boolean_t ignore_ancestry,
204 svn_boolean_t text_deltas,
205 const char *versus_url,
206 const svn_delta_editor_t *diff_editor,
209 /* See svn_ra_get_log2(). */
210 svn_error_t *(*get_log)(svn_ra_session_t *session,
211 const apr_array_header_t *paths,
215 svn_boolean_t discover_changed_paths,
216 svn_boolean_t strict_node_history,
217 svn_boolean_t include_merged_revisions,
218 const apr_array_header_t *revprops,
219 svn_log_entry_receiver_t receiver,
220 void *receiver_baton,
222 /* See svn_ra_check_path(). */
223 svn_error_t *(*check_path)(svn_ra_session_t *session,
225 svn_revnum_t revision,
226 svn_node_kind_t *kind,
228 /* See svn_ra_stat(). */
229 svn_error_t *(*stat)(svn_ra_session_t *session,
231 svn_revnum_t revision,
232 svn_dirent_t **dirent,
234 /* See svn_ra_get_uuid2(). */
235 svn_error_t *(*get_uuid)(svn_ra_session_t *session,
238 /* See svn_ra_get_repos_root2(). */
239 svn_error_t *(*get_repos_root)(svn_ra_session_t *session,
242 /* See svn_ra_get_locations(). */
243 svn_error_t *(*get_locations)(svn_ra_session_t *session,
244 apr_hash_t **locations,
246 svn_revnum_t peg_revision,
247 const apr_array_header_t *location_revisions,
249 /* See svn_ra_get_location_segments(). */
250 svn_error_t *(*get_location_segments)(svn_ra_session_t *session,
252 svn_revnum_t peg_revision,
253 svn_revnum_t start_rev,
254 svn_revnum_t end_rev,
255 svn_location_segment_receiver_t rcvr,
256 void *receiver_baton,
258 /* See svn_ra_get_file_revs2(). */
259 svn_error_t *(*get_file_revs)(svn_ra_session_t *session,
263 svn_boolean_t include_merged_revisions,
264 svn_file_rev_handler_t handler,
267 /* See svn_ra_lock(). */
268 svn_error_t *(*lock)(svn_ra_session_t *session,
269 apr_hash_t *path_revs,
272 svn_ra_lock_callback_t lock_func,
275 /* See svn_ra_unlock(). */
276 svn_error_t *(*unlock)(svn_ra_session_t *session,
277 apr_hash_t *path_tokens,
279 svn_ra_lock_callback_t lock_func,
282 /* See svn_ra_get_lock(). */
283 svn_error_t *(*get_lock)(svn_ra_session_t *session,
287 /* See svn_ra_get_locks2(). */
288 svn_error_t *(*get_locks)(svn_ra_session_t *session,
293 /* See svn_ra_replay(). */
294 svn_error_t *(*replay)(svn_ra_session_t *session,
295 svn_revnum_t revision,
296 svn_revnum_t low_water_mark,
297 svn_boolean_t text_deltas,
298 const svn_delta_editor_t *editor,
301 /* See svn_ra_has_capability(). */
302 svn_error_t *(*has_capability)(svn_ra_session_t *session,
304 const char *capability,
306 /* See svn_ra_replay_range(). */
308 (*replay_range)(svn_ra_session_t *session,
309 svn_revnum_t start_revision,
310 svn_revnum_t end_revision,
311 svn_revnum_t low_water_mark,
312 svn_boolean_t text_deltas,
313 svn_ra_replay_revstart_callback_t revstart_func,
314 svn_ra_replay_revfinish_callback_t revfinish_func,
317 /* See svn_ra_get_deleted_rev(). */
318 svn_error_t *(*get_deleted_rev)(svn_ra_session_t *session,
320 svn_revnum_t peg_revision,
321 svn_revnum_t end_revision,
322 svn_revnum_t *revision_deleted,
324 /* See svn_ra_get_inherited_props(). */
325 svn_error_t *(*get_inherited_props)(svn_ra_session_t *session,
326 apr_array_header_t **iprops,
328 svn_revnum_t revision,
329 apr_pool_t *result_pool,
330 apr_pool_t *scratch_pool);
331 /* If not NULL, receives a pointer to svn_ra_open, to alllow opening
332 a new ra session from inside the ra layer without a circular
334 svn_error_t *(*set_svn_ra_open)(svn_ra_session_t *session,
335 svn_ra__open_func_t func);
337 /* See svn_ra_list(). */
338 svn_error_t *(*list)(svn_ra_session_t *session,
340 svn_revnum_t revision,
341 const apr_array_header_t *patterns,
343 apr_uint32_t dirent_fields,
344 svn_ra_dirent_receiver_t receiver,
345 void *receiver_baton,
346 apr_pool_t *scratch_pool);
348 /* Experimental support below here */
350 /* See svn_ra__register_editor_shim_callbacks() */
351 svn_error_t *(*register_editor_shim_callbacks)(svn_ra_session_t *session,
352 svn_delta_shim_callbacks_t *callbacks);
353 /* See svn_ra__get_commit_ev2() */
354 svn_error_t *(*get_commit_ev2)(
355 svn_editor_t **editor,
356 svn_ra_session_t *session,
357 apr_hash_t *revprop_table,
358 svn_commit_callback2_t callback,
359 void *callback_baton,
360 apr_hash_t *lock_tokens,
361 svn_boolean_t keep_locks,
362 svn_ra__provide_base_cb_t provide_base_cb,
363 svn_ra__provide_props_cb_t provide_props_cb,
364 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
366 svn_cancel_func_t cancel_func,
368 apr_pool_t *result_pool,
369 apr_pool_t *scratch_pool);
371 /* See svn_ra__replay_range_ev2() */
372 svn_error_t *(*replay_range_ev2)(
373 svn_ra_session_t *session,
374 svn_revnum_t start_revision,
375 svn_revnum_t end_revision,
376 svn_revnum_t low_water_mark,
377 svn_boolean_t send_deltas,
378 svn_ra__replay_revstart_ev2_callback_t revstart_func,
379 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
381 apr_pool_t *scratch_pool);
385 /* The RA session object. */
386 struct svn_ra_session_t {
387 const svn_ra__vtable_t *vtable;
389 /* Cancellation handlers consumers may want to use. */
390 svn_cancel_func_t cancel_func;
393 /* Pool used to manage this session. */
396 /* Private data for the RA implementation. */
400 /* Each libsvn_ra_foo defines a function named svn_ra_foo__init of this type.
402 * The LOADER_VERSION parameter must remain first in the list, and the
403 * function must use the C calling convention on all platforms, so that
404 * the init functions can safely read the version parameter.
406 * POOL will be available as long as this module is being used.
408 * ### need to force this to be __cdecl on Windows... how??
410 typedef svn_error_t *
411 (*svn_ra__init_func_t)(const svn_version_t *loader_version,
412 const svn_ra__vtable_t **vtable,
415 /* Declarations of the init functions for the available RA libraries. */
416 svn_error_t *svn_ra_local__init(const svn_version_t *loader_version,
417 const svn_ra__vtable_t **vtable,
419 svn_error_t *svn_ra_svn__init(const svn_version_t *loader_version,
420 const svn_ra__vtable_t **vtable,
422 svn_error_t *svn_ra_serf__init(const svn_version_t *loader_version,
423 const svn_ra__vtable_t **vtable,
428 /*** Compat Functions ***/
431 * Set *LOCATIONS to the locations (at the repository revisions
432 * LOCATION_REVISIONS) of the file identified by PATH in PEG_REVISION.
433 * PATH is relative to the URL to which SESSION was opened.
434 * LOCATION_REVISIONS is an array of svn_revnum_t's. *LOCATIONS will
435 * be a mapping from the revisions to their appropriate absolute
436 * paths. If the file doesn't exist in a location_revision, that
437 * revision will be ignored.
439 * Use POOL for all allocations.
441 * NOTE: This function uses the RA get_log interfaces to do its work,
442 * as a fallback mechanism for servers which don't support the native
446 svn_ra__locations_from_log(svn_ra_session_t *session,
447 apr_hash_t **locations_p,
449 svn_revnum_t peg_revision,
450 const apr_array_header_t *location_revisions,
454 * Call RECEIVER (with RECEIVER_BATON) for each segment in the
455 * location history of PATH in START_REV, working backwards in time
456 * from START_REV to END_REV.
458 * END_REV may be SVN_INVALID_REVNUM to indicate that you want to
459 * trace the history of the object to its origin.
461 * START_REV may be SVN_INVALID_REVNUM to indicate that you want to
462 * trace the history of the object beginning in the HEAD revision.
463 * Otherwise, START_REV must be younger than END_REV (unless END_REV
464 * is SVN_INVALID_REVNUM).
466 * Use POOL for all allocations.
468 * NOTE: This function uses the RA get_log interfaces to do its work,
469 * as a fallback mechanism for servers which don't support the native
470 * get_location_segments API.
473 svn_ra__location_segments_from_log(svn_ra_session_t *session,
475 svn_revnum_t peg_revision,
476 svn_revnum_t start_rev,
477 svn_revnum_t end_rev,
478 svn_location_segment_receiver_t receiver,
479 void *receiver_baton,
483 * Retrieve a subset of the interesting revisions of a file PATH
484 * as seen in revision END (see svn_fs_history_prev() for a
485 * definition of "interesting revisions"). Invoke HANDLER with
486 * @a handler_baton as its first argument for each such revision.
487 * @a session is an open RA session. Use POOL for all allocations.
489 * If there is an interesting revision of the file that is less than or
490 * equal to START, the iteration will begin at that revision.
491 * Else, the iteration will begin at the first revision of the file in
492 * the repository, which has to be less than or equal to END. Note
493 * that if the function succeeds, HANDLER will have been called at
496 * In a series of calls to HANDLER, the file contents for the first
497 * interesting revision will be provided as a text delta against the
498 * empty file. In the following calls, the delta will be against the
499 * fulltext contents for the previous call.
501 * NOTE: This function uses the RA get_log interfaces to do its work,
502 * as a fallback mechanism for servers which don't support the native
503 * get_location_segments API.
506 svn_ra__file_revs_from_log(svn_ra_session_t *session,
510 svn_file_rev_handler_t handler,
516 * Given a path REL_DELETED_PATH, relative to the URL of SESSION, which
517 * exists at PEG_REVISION, and an END_REVISION > PEG_REVISION at which
518 * REL_DELETED_PATH no longer exists, set *REVISION_DELETED to the revision
519 * REL_DELETED_PATH was first deleted or replaced, within the inclusive
520 * revision range defined by PEG_REVISION and END_REVISION.
522 * If REL_DELETED_PATH does not exist at PEG_REVISION or was not deleted prior
523 * to END_REVISION within the specified range, then set *REVISION_DELETED to
524 * SVN_INVALID_REVNUM. If PEG_REVISION or END_REVISION are invalid or if
525 * END_REVISION <= PEG_REVISION, then return SVN_ERR_CLIENT_BAD_REVISION.
527 * Use POOL for all allocations.
529 * NOTE: This function uses the RA get_log interfaces to do its work,
530 * as a fallback mechanism for servers which don't support the native
531 * get_deleted_rev API.
534 svn_ra__get_deleted_rev_from_log(svn_ra_session_t *session,
535 const char *rel_deleted_path,
536 svn_revnum_t peg_revision,
537 svn_revnum_t end_revision,
538 svn_revnum_t *revision_deleted,
543 * Fallback logic for svn_ra_get_inherited_props() when that API
544 * need to find PATH's inherited properties on a legacy server that
545 * doesn't have the SVN_RA_CAPABILITY_INHERITED_PROPS capability.
547 * All arguments are as per svn_ra_get_inherited_props().
550 svn_ra__get_inherited_props_walk(svn_ra_session_t *session,
552 svn_revnum_t revision,
553 apr_array_header_t **inherited_props,
554 apr_pool_t *result_pool,
555 apr_pool_t *scratch_pool);
557 /* Utility function to provide a shim between a returned Ev2 and an RA
558 provider's Ev1-based commit editor.
560 See svn_ra__get_commit_ev2() for parameter semantics. */
562 svn_ra__use_commit_shim(svn_editor_t **editor,
563 svn_ra_session_t *session,
564 apr_hash_t *revprop_table,
565 svn_commit_callback2_t callback,
566 void *callback_baton,
567 apr_hash_t *lock_tokens,
568 svn_boolean_t keep_locks,
569 svn_ra__provide_base_cb_t provide_base_cb,
570 svn_ra__provide_props_cb_t provide_props_cb,
571 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
573 svn_cancel_func_t cancel_func,
575 apr_pool_t *result_pool,
576 apr_pool_t *scratch_pool);
578 /* Utility function to provide a shim between a returned Ev2 and an RA
579 provider's Ev1-based commit editor.
581 See svn_ra__replay_range_ev2() for parameter semantics. */
583 svn_ra__use_replay_range_shim(svn_ra_session_t *session,
584 svn_revnum_t start_revision,
585 svn_revnum_t end_revision,
586 svn_revnum_t low_water_mark,
587 svn_boolean_t send_deltas,
588 svn_ra__replay_revstart_ev2_callback_t revstart_func,
589 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
591 svn_ra__provide_base_cb_t provide_base_cb,
592 svn_ra__provide_props_cb_t provide_props_cb,
594 apr_pool_t *scratch_pool);