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 /* The RA layer vtable. */
42 typedef struct svn_ra__vtable_t {
43 /* This field should always remain first in the vtable. */
44 const svn_version_t *(*get_version)(void);
46 /* Return a short description of the RA implementation, as a localized
48 const char *(*get_description)(apr_pool_t *pool);
50 /* Return a list of actual URI schemes supported by this implementation.
51 * The returned array is NULL-terminated. */
52 const char * const *(*get_schemes)(apr_pool_t *pool);
54 /* Implementations of the public API functions. */
56 /* See svn_ra_open4(). */
57 /* All fields in SESSION, except priv, have been initialized by the
58 time this is called. SESSION->priv may be set by this function. */
59 svn_error_t *(*open_session)(svn_ra_session_t *session,
60 const char **corrected_url,
61 const char *session_URL,
62 const svn_ra_callbacks2_t *callbacks,
64 svn_auth_baton_t *auth_baton,
66 apr_pool_t *result_pool,
67 apr_pool_t *scratch_pool);
68 /* Backs svn_ra_dup_session */
69 svn_error_t * (*dup_session)(svn_ra_session_t *new_session,
70 svn_ra_session_t *old_session,
71 const char *new_session_url,
72 apr_pool_t *result_pool,
73 apr_pool_t *scratch_pool);
74 /* See svn_ra_reparent(). */
75 /* URL is guaranteed to have what get_repos_root() returns as a prefix. */
76 svn_error_t *(*reparent)(svn_ra_session_t *session,
79 /* See svn_ra_get_session_url(). */
80 svn_error_t *(*get_session_url)(svn_ra_session_t *session,
83 /* See svn_ra_get_latest_revnum(). */
84 svn_error_t *(*get_latest_revnum)(svn_ra_session_t *session,
85 svn_revnum_t *latest_revnum,
87 /* See svn_ra_get_dated_revision(). */
88 svn_error_t *(*get_dated_revision)(svn_ra_session_t *session,
89 svn_revnum_t *revision,
92 /* See svn_ra_change_rev_prop2(). */
93 svn_error_t *(*change_rev_prop)(svn_ra_session_t *session,
96 const svn_string_t *const *old_value_p,
97 const svn_string_t *value,
100 /* See svn_ra_rev_proplist(). */
101 svn_error_t *(*rev_proplist)(svn_ra_session_t *session,
105 /* See svn_ra_rev_prop(). */
106 svn_error_t *(*rev_prop)(svn_ra_session_t *session,
109 svn_string_t **value,
111 /* See svn_ra_get_commit_editor3(). */
112 svn_error_t *(*get_commit_editor)(svn_ra_session_t *session,
113 const svn_delta_editor_t **editor,
115 apr_hash_t *revprop_table,
116 svn_commit_callback2_t callback,
117 void *callback_baton,
118 apr_hash_t *lock_tokens,
119 svn_boolean_t keep_locks,
121 /* See svn_ra_get_file(). */
122 svn_error_t *(*get_file)(svn_ra_session_t *session,
124 svn_revnum_t revision,
125 svn_stream_t *stream,
126 svn_revnum_t *fetched_rev,
129 /* See svn_ra_get_dir2(). */
130 svn_error_t *(*get_dir)(svn_ra_session_t *session,
131 apr_hash_t **dirents,
132 svn_revnum_t *fetched_rev,
135 svn_revnum_t revision,
136 apr_uint32_t dirent_fields,
138 /* See svn_ra_get_mergeinfo(). */
139 svn_error_t *(*get_mergeinfo)(svn_ra_session_t *session,
140 svn_mergeinfo_catalog_t *mergeinfo,
141 const apr_array_header_t *paths,
142 svn_revnum_t revision,
143 svn_mergeinfo_inheritance_t inherit,
144 svn_boolean_t include_merged_revisions,
146 /* See svn_ra_do_update3(). */
147 svn_error_t *(*do_update)(svn_ra_session_t *session,
148 const svn_ra_reporter3_t **reporter,
150 svn_revnum_t revision_to_update_to,
151 const char *update_target,
153 svn_boolean_t send_copyfrom_args,
154 svn_boolean_t ignore_ancestry,
155 const svn_delta_editor_t *update_editor,
157 apr_pool_t *result_pool,
158 apr_pool_t *scratch_pool);
159 /* See svn_ra_do_switch3(). */
160 svn_error_t *(*do_switch)(svn_ra_session_t *session,
161 const svn_ra_reporter3_t **reporter,
163 svn_revnum_t revision_to_switch_to,
164 const char *switch_target,
166 const char *switch_url,
167 svn_boolean_t send_copyfrom_args,
168 svn_boolean_t ignore_ancestry,
169 const svn_delta_editor_t *switch_editor,
171 apr_pool_t *result_pool,
172 apr_pool_t *scratch_pool);
173 /* See svn_ra_do_status2(). */
174 svn_error_t *(*do_status)(svn_ra_session_t *session,
175 const svn_ra_reporter3_t **reporter,
177 const char *status_target,
178 svn_revnum_t revision,
180 const svn_delta_editor_t *status_editor,
183 /* See svn_ra_do_diff3(). */
184 svn_error_t *(*do_diff)(svn_ra_session_t *session,
185 const svn_ra_reporter3_t **reporter,
187 svn_revnum_t revision,
188 const char *diff_target,
190 svn_boolean_t ignore_ancestry,
191 svn_boolean_t text_deltas,
192 const char *versus_url,
193 const svn_delta_editor_t *diff_editor,
196 /* See svn_ra_get_log2(). */
197 svn_error_t *(*get_log)(svn_ra_session_t *session,
198 const apr_array_header_t *paths,
202 svn_boolean_t discover_changed_paths,
203 svn_boolean_t strict_node_history,
204 svn_boolean_t include_merged_revisions,
205 const apr_array_header_t *revprops,
206 svn_log_entry_receiver_t receiver,
207 void *receiver_baton,
209 /* See svn_ra_check_path(). */
210 svn_error_t *(*check_path)(svn_ra_session_t *session,
212 svn_revnum_t revision,
213 svn_node_kind_t *kind,
215 /* See svn_ra_stat(). */
216 svn_error_t *(*stat)(svn_ra_session_t *session,
218 svn_revnum_t revision,
219 svn_dirent_t **dirent,
221 /* See svn_ra_get_uuid2(). */
222 svn_error_t *(*get_uuid)(svn_ra_session_t *session,
225 /* See svn_ra_get_repos_root2(). */
226 svn_error_t *(*get_repos_root)(svn_ra_session_t *session,
229 /* See svn_ra_get_locations(). */
230 svn_error_t *(*get_locations)(svn_ra_session_t *session,
231 apr_hash_t **locations,
233 svn_revnum_t peg_revision,
234 const apr_array_header_t *location_revisions,
236 /* See svn_ra_get_location_segments(). */
237 svn_error_t *(*get_location_segments)(svn_ra_session_t *session,
239 svn_revnum_t peg_revision,
240 svn_revnum_t start_rev,
241 svn_revnum_t end_rev,
242 svn_location_segment_receiver_t rcvr,
243 void *receiver_baton,
245 /* See svn_ra_get_file_revs2(). */
246 svn_error_t *(*get_file_revs)(svn_ra_session_t *session,
250 svn_boolean_t include_merged_revisions,
251 svn_file_rev_handler_t handler,
254 /* See svn_ra_lock(). */
255 svn_error_t *(*lock)(svn_ra_session_t *session,
256 apr_hash_t *path_revs,
259 svn_ra_lock_callback_t lock_func,
262 /* See svn_ra_unlock(). */
263 svn_error_t *(*unlock)(svn_ra_session_t *session,
264 apr_hash_t *path_tokens,
266 svn_ra_lock_callback_t lock_func,
269 /* See svn_ra_get_lock(). */
270 svn_error_t *(*get_lock)(svn_ra_session_t *session,
274 /* See svn_ra_get_locks2(). */
275 svn_error_t *(*get_locks)(svn_ra_session_t *session,
280 /* See svn_ra_replay(). */
281 svn_error_t *(*replay)(svn_ra_session_t *session,
282 svn_revnum_t revision,
283 svn_revnum_t low_water_mark,
284 svn_boolean_t text_deltas,
285 const svn_delta_editor_t *editor,
288 /* See svn_ra_has_capability(). */
289 svn_error_t *(*has_capability)(svn_ra_session_t *session,
291 const char *capability,
293 /* See svn_ra_replay_range(). */
295 (*replay_range)(svn_ra_session_t *session,
296 svn_revnum_t start_revision,
297 svn_revnum_t end_revision,
298 svn_revnum_t low_water_mark,
299 svn_boolean_t text_deltas,
300 svn_ra_replay_revstart_callback_t revstart_func,
301 svn_ra_replay_revfinish_callback_t revfinish_func,
304 /* See svn_ra_get_deleted_rev(). */
305 svn_error_t *(*get_deleted_rev)(svn_ra_session_t *session,
307 svn_revnum_t peg_revision,
308 svn_revnum_t end_revision,
309 svn_revnum_t *revision_deleted,
312 /* See svn_ra__register_editor_shim_callbacks() */
313 svn_error_t *(*register_editor_shim_callbacks)(svn_ra_session_t *session,
314 svn_delta_shim_callbacks_t *callbacks);
315 /* See svn_ra_get_inherited_props(). */
316 svn_error_t *(*get_inherited_props)(svn_ra_session_t *session,
317 apr_array_header_t **iprops,
319 svn_revnum_t revision,
320 apr_pool_t *result_pool,
321 apr_pool_t *scratch_pool);
322 /* See svn_ra__get_commit_ev2() */
323 svn_error_t *(*get_commit_ev2)(
324 svn_editor_t **editor,
325 svn_ra_session_t *session,
326 apr_hash_t *revprop_table,
327 svn_commit_callback2_t callback,
328 void *callback_baton,
329 apr_hash_t *lock_tokens,
330 svn_boolean_t keep_locks,
331 svn_ra__provide_base_cb_t provide_base_cb,
332 svn_ra__provide_props_cb_t provide_props_cb,
333 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
335 svn_cancel_func_t cancel_func,
337 apr_pool_t *result_pool,
338 apr_pool_t *scratch_pool);
340 /* See svn_ra__replay_range_ev2() */
341 svn_error_t *(*replay_range_ev2)(
342 svn_ra_session_t *session,
343 svn_revnum_t start_revision,
344 svn_revnum_t end_revision,
345 svn_revnum_t low_water_mark,
346 svn_boolean_t send_deltas,
347 svn_ra__replay_revstart_ev2_callback_t revstart_func,
348 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
350 apr_pool_t *scratch_pool);
354 /* The RA session object. */
355 struct svn_ra_session_t {
356 const svn_ra__vtable_t *vtable;
358 /* Cancellation handlers consumers may want to use. */
359 svn_cancel_func_t cancel_func;
362 /* Pool used to manage this session. */
365 /* Private data for the RA implementation. */
369 /* Each libsvn_ra_foo defines a function named svn_ra_foo__init of this type.
371 * The LOADER_VERSION parameter must remain first in the list, and the
372 * function must use the C calling convention on all platforms, so that
373 * the init functions can safely read the version parameter.
375 * POOL will be available as long as this module is being used.
377 * ### need to force this to be __cdecl on Windows... how??
379 typedef svn_error_t *
380 (*svn_ra__init_func_t)(const svn_version_t *loader_version,
381 const svn_ra__vtable_t **vtable,
384 /* Declarations of the init functions for the available RA libraries. */
385 svn_error_t *svn_ra_local__init(const svn_version_t *loader_version,
386 const svn_ra__vtable_t **vtable,
388 svn_error_t *svn_ra_svn__init(const svn_version_t *loader_version,
389 const svn_ra__vtable_t **vtable,
391 svn_error_t *svn_ra_serf__init(const svn_version_t *loader_version,
392 const svn_ra__vtable_t **vtable,
397 /*** Compat Functions ***/
400 * Set *LOCATIONS to the locations (at the repository revisions
401 * LOCATION_REVISIONS) of the file identified by PATH in PEG_REVISION.
402 * PATH is relative to the URL to which SESSION was opened.
403 * LOCATION_REVISIONS is an array of svn_revnum_t's. *LOCATIONS will
404 * be a mapping from the revisions to their appropriate absolute
405 * paths. If the file doesn't exist in a location_revision, that
406 * revision will be ignored.
408 * Use POOL for all allocations.
410 * NOTE: This function uses the RA get_log interfaces to do its work,
411 * as a fallback mechanism for servers which don't support the native
415 svn_ra__locations_from_log(svn_ra_session_t *session,
416 apr_hash_t **locations_p,
418 svn_revnum_t peg_revision,
419 const apr_array_header_t *location_revisions,
423 * Call RECEIVER (with RECEIVER_BATON) for each segment in the
424 * location history of PATH in START_REV, working backwards in time
425 * from START_REV to END_REV.
427 * END_REV may be SVN_INVALID_REVNUM to indicate that you want to
428 * trace the history of the object to its origin.
430 * START_REV may be SVN_INVALID_REVNUM to indicate that you want to
431 * trace the history of the object beginning in the HEAD revision.
432 * Otherwise, START_REV must be younger than END_REV (unless END_REV
433 * is SVN_INVALID_REVNUM).
435 * Use POOL for all allocations.
437 * NOTE: This function uses the RA get_log interfaces to do its work,
438 * as a fallback mechanism for servers which don't support the native
439 * get_location_segments API.
442 svn_ra__location_segments_from_log(svn_ra_session_t *session,
444 svn_revnum_t peg_revision,
445 svn_revnum_t start_rev,
446 svn_revnum_t end_rev,
447 svn_location_segment_receiver_t receiver,
448 void *receiver_baton,
452 * Retrieve a subset of the interesting revisions of a file PATH
453 * as seen in revision END (see svn_fs_history_prev() for a
454 * definition of "interesting revisions"). Invoke HANDLER with
455 * @a handler_baton as its first argument for each such revision.
456 * @a session is an open RA session. Use POOL for all allocations.
458 * If there is an interesting revision of the file that is less than or
459 * equal to START, the iteration will begin at that revision.
460 * Else, the iteration will begin at the first revision of the file in
461 * the repository, which has to be less than or equal to END. Note
462 * that if the function succeeds, HANDLER will have been called at
465 * In a series of calls to HANDLER, the file contents for the first
466 * interesting revision will be provided as a text delta against the
467 * empty file. In the following calls, the delta will be against the
468 * fulltext contents for the previous call.
470 * NOTE: This function uses the RA get_log interfaces to do its work,
471 * as a fallback mechanism for servers which don't support the native
472 * get_location_segments API.
475 svn_ra__file_revs_from_log(svn_ra_session_t *session,
479 svn_file_rev_handler_t handler,
485 * Given a path REL_DELETED_PATH, relative to the URL of SESSION, which
486 * exists at PEG_REVISION, and an END_REVISION > PEG_REVISION at which
487 * REL_DELETED_PATH no longer exists, set *REVISION_DELETED to the revision
488 * REL_DELETED_PATH was first deleted or replaced, within the inclusive
489 * revision range defined by PEG_REVISION and END_REVISION.
491 * If REL_DELETED_PATH does not exist at PEG_REVISION or was not deleted prior
492 * to END_REVISION within the specified range, then set *REVISION_DELETED to
493 * SVN_INVALID_REVNUM. If PEG_REVISION or END_REVISION are invalid or if
494 * END_REVISION <= PEG_REVISION, then return SVN_ERR_CLIENT_BAD_REVISION.
496 * Use POOL for all allocations.
498 * NOTE: This function uses the RA get_log interfaces to do its work,
499 * as a fallback mechanism for servers which don't support the native
500 * get_deleted_rev API.
503 svn_ra__get_deleted_rev_from_log(svn_ra_session_t *session,
504 const char *rel_deleted_path,
505 svn_revnum_t peg_revision,
506 svn_revnum_t end_revision,
507 svn_revnum_t *revision_deleted,
512 * Fallback logic for svn_ra_get_inherited_props() when that API
513 * need to find PATH's inherited properties on a legacy server that
514 * doesn't have the SVN_RA_CAPABILITY_INHERITED_PROPS capability.
516 * All arguments are as per svn_ra_get_inherited_props().
519 svn_ra__get_inherited_props_walk(svn_ra_session_t *session,
521 svn_revnum_t revision,
522 apr_array_header_t **inherited_props,
523 apr_pool_t *result_pool,
524 apr_pool_t *scratch_pool);
526 /* Utility function to provide a shim between a returned Ev2 and an RA
527 provider's Ev1-based commit editor.
529 See svn_ra__get_commit_ev2() for parameter semantics. */
531 svn_ra__use_commit_shim(svn_editor_t **editor,
532 svn_ra_session_t *session,
533 apr_hash_t *revprop_table,
534 svn_commit_callback2_t callback,
535 void *callback_baton,
536 apr_hash_t *lock_tokens,
537 svn_boolean_t keep_locks,
538 svn_ra__provide_base_cb_t provide_base_cb,
539 svn_ra__provide_props_cb_t provide_props_cb,
540 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
542 svn_cancel_func_t cancel_func,
544 apr_pool_t *result_pool,
545 apr_pool_t *scratch_pool);
547 /* Utility function to provide a shim between a returned Ev2 and an RA
548 provider's Ev1-based commit editor.
550 See svn_ra__replay_range_ev2() for parameter semantics. */
552 svn_ra__use_replay_range_shim(svn_ra_session_t *session,
553 svn_revnum_t start_revision,
554 svn_revnum_t end_revision,
555 svn_revnum_t low_water_mark,
556 svn_boolean_t send_deltas,
557 svn_ra__replay_revstart_ev2_callback_t revstart_func,
558 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
560 svn_ra__provide_base_cb_t provide_base_cb,
561 svn_ra__provide_props_cb_t provide_props_cb,
563 apr_pool_t *scratch_pool);