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)(void);
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,
66 /* See svn_ra_reparent(). */
67 /* URL is guaranteed to have what get_repos_root() returns as a prefix. */
68 svn_error_t *(*reparent)(svn_ra_session_t *session,
71 /* See svn_ra_get_session_url(). */
72 svn_error_t *(*get_session_url)(svn_ra_session_t *session,
75 /* See svn_ra_get_latest_revnum(). */
76 svn_error_t *(*get_latest_revnum)(svn_ra_session_t *session,
77 svn_revnum_t *latest_revnum,
79 /* See svn_ra_get_dated_revision(). */
80 svn_error_t *(*get_dated_revision)(svn_ra_session_t *session,
81 svn_revnum_t *revision,
84 /* See svn_ra_change_rev_prop2(). */
85 svn_error_t *(*change_rev_prop)(svn_ra_session_t *session,
88 const svn_string_t *const *old_value_p,
89 const svn_string_t *value,
92 /* See svn_ra_rev_proplist(). */
93 svn_error_t *(*rev_proplist)(svn_ra_session_t *session,
97 /* See svn_ra_rev_prop(). */
98 svn_error_t *(*rev_prop)(svn_ra_session_t *session,
101 svn_string_t **value,
103 /* See svn_ra_get_commit_editor3(). */
104 svn_error_t *(*get_commit_editor)(svn_ra_session_t *session,
105 const svn_delta_editor_t **editor,
107 apr_hash_t *revprop_table,
108 svn_commit_callback2_t callback,
109 void *callback_baton,
110 apr_hash_t *lock_tokens,
111 svn_boolean_t keep_locks,
113 /* See svn_ra_get_file(). */
114 svn_error_t *(*get_file)(svn_ra_session_t *session,
116 svn_revnum_t revision,
117 svn_stream_t *stream,
118 svn_revnum_t *fetched_rev,
121 /* See svn_ra_get_dir2(). */
122 svn_error_t *(*get_dir)(svn_ra_session_t *session,
123 apr_hash_t **dirents,
124 svn_revnum_t *fetched_rev,
127 svn_revnum_t revision,
128 apr_uint32_t dirent_fields,
130 /* See svn_ra_get_mergeinfo(). */
131 svn_error_t *(*get_mergeinfo)(svn_ra_session_t *session,
132 svn_mergeinfo_catalog_t *mergeinfo,
133 const apr_array_header_t *paths,
134 svn_revnum_t revision,
135 svn_mergeinfo_inheritance_t inherit,
136 svn_boolean_t include_merged_revisions,
138 /* See svn_ra_do_update3(). */
139 svn_error_t *(*do_update)(svn_ra_session_t *session,
140 const svn_ra_reporter3_t **reporter,
142 svn_revnum_t revision_to_update_to,
143 const char *update_target,
145 svn_boolean_t send_copyfrom_args,
146 svn_boolean_t ignore_ancestry,
147 const svn_delta_editor_t *update_editor,
149 apr_pool_t *result_pool,
150 apr_pool_t *scratch_pool);
151 /* See svn_ra_do_switch3(). */
152 svn_error_t *(*do_switch)(svn_ra_session_t *session,
153 const svn_ra_reporter3_t **reporter,
155 svn_revnum_t revision_to_switch_to,
156 const char *switch_target,
158 const char *switch_url,
159 svn_boolean_t send_copyfrom_args,
160 svn_boolean_t ignore_ancestry,
161 const svn_delta_editor_t *switch_editor,
163 apr_pool_t *result_pool,
164 apr_pool_t *scratch_pool);
165 /* See svn_ra_do_status2(). */
166 svn_error_t *(*do_status)(svn_ra_session_t *session,
167 const svn_ra_reporter3_t **reporter,
169 const char *status_target,
170 svn_revnum_t revision,
172 const svn_delta_editor_t *status_editor,
175 /* See svn_ra_do_diff3(). */
176 svn_error_t *(*do_diff)(svn_ra_session_t *session,
177 const svn_ra_reporter3_t **reporter,
179 svn_revnum_t revision,
180 const char *diff_target,
182 svn_boolean_t ignore_ancestry,
183 svn_boolean_t text_deltas,
184 const char *versus_url,
185 const svn_delta_editor_t *diff_editor,
188 /* See svn_ra_get_log2(). */
189 svn_error_t *(*get_log)(svn_ra_session_t *session,
190 const apr_array_header_t *paths,
194 svn_boolean_t discover_changed_paths,
195 svn_boolean_t strict_node_history,
196 svn_boolean_t include_merged_revisions,
197 const apr_array_header_t *revprops,
198 svn_log_entry_receiver_t receiver,
199 void *receiver_baton,
201 /* See svn_ra_check_path(). */
202 svn_error_t *(*check_path)(svn_ra_session_t *session,
204 svn_revnum_t revision,
205 svn_node_kind_t *kind,
207 /* See svn_ra_stat(). */
208 svn_error_t *(*stat)(svn_ra_session_t *session,
210 svn_revnum_t revision,
211 svn_dirent_t **dirent,
213 /* See svn_ra_get_uuid2(). */
214 svn_error_t *(*get_uuid)(svn_ra_session_t *session,
217 /* See svn_ra_get_repos_root2(). */
218 svn_error_t *(*get_repos_root)(svn_ra_session_t *session,
221 /* See svn_ra_get_locations(). */
222 svn_error_t *(*get_locations)(svn_ra_session_t *session,
223 apr_hash_t **locations,
225 svn_revnum_t peg_revision,
226 const apr_array_header_t *location_revisions,
228 /* See svn_ra_get_location_segments(). */
229 svn_error_t *(*get_location_segments)(svn_ra_session_t *session,
231 svn_revnum_t peg_revision,
232 svn_revnum_t start_rev,
233 svn_revnum_t end_rev,
234 svn_location_segment_receiver_t rcvr,
235 void *receiver_baton,
237 /* See svn_ra_get_file_revs2(). */
238 svn_error_t *(*get_file_revs)(svn_ra_session_t *session,
242 svn_boolean_t include_merged_revisions,
243 svn_file_rev_handler_t handler,
246 /* See svn_ra_lock(). */
247 svn_error_t *(*lock)(svn_ra_session_t *session,
248 apr_hash_t *path_revs,
251 svn_ra_lock_callback_t lock_func,
254 /* See svn_ra_unlock(). */
255 svn_error_t *(*unlock)(svn_ra_session_t *session,
256 apr_hash_t *path_tokens,
258 svn_ra_lock_callback_t lock_func,
261 /* See svn_ra_get_lock(). */
262 svn_error_t *(*get_lock)(svn_ra_session_t *session,
266 /* See svn_ra_get_locks2(). */
267 svn_error_t *(*get_locks)(svn_ra_session_t *session,
272 /* See svn_ra_replay(). */
273 svn_error_t *(*replay)(svn_ra_session_t *session,
274 svn_revnum_t revision,
275 svn_revnum_t low_water_mark,
276 svn_boolean_t text_deltas,
277 const svn_delta_editor_t *editor,
280 /* See svn_ra_has_capability(). */
281 svn_error_t *(*has_capability)(svn_ra_session_t *session,
283 const char *capability,
285 /* See svn_ra_replay_range(). */
287 (*replay_range)(svn_ra_session_t *session,
288 svn_revnum_t start_revision,
289 svn_revnum_t end_revision,
290 svn_revnum_t low_water_mark,
291 svn_boolean_t text_deltas,
292 svn_ra_replay_revstart_callback_t revstart_func,
293 svn_ra_replay_revfinish_callback_t revfinish_func,
296 /* See svn_ra_get_deleted_rev(). */
297 svn_error_t *(*get_deleted_rev)(svn_ra_session_t *session,
299 svn_revnum_t peg_revision,
300 svn_revnum_t end_revision,
301 svn_revnum_t *revision_deleted,
304 /* See svn_ra__register_editor_shim_callbacks() */
305 svn_error_t *(*register_editor_shim_callbacks)(svn_ra_session_t *session,
306 svn_delta_shim_callbacks_t *callbacks);
307 /* See svn_ra_get_inherited_props(). */
308 svn_error_t *(*get_inherited_props)(svn_ra_session_t *session,
309 apr_array_header_t **iprops,
311 svn_revnum_t revision,
312 apr_pool_t *result_pool,
313 apr_pool_t *scratch_pool);
314 /* See svn_ra__get_commit_ev2() */
315 svn_error_t *(*get_commit_ev2)(
316 svn_editor_t **editor,
317 svn_ra_session_t *session,
318 apr_hash_t *revprop_table,
319 svn_commit_callback2_t callback,
320 void *callback_baton,
321 apr_hash_t *lock_tokens,
322 svn_boolean_t keep_locks,
323 svn_ra__provide_base_cb_t provide_base_cb,
324 svn_ra__provide_props_cb_t provide_props_cb,
325 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
327 svn_cancel_func_t cancel_func,
329 apr_pool_t *result_pool,
330 apr_pool_t *scratch_pool);
332 /* See svn_ra__replay_range_ev2() */
333 svn_error_t *(*replay_range_ev2)(
334 svn_ra_session_t *session,
335 svn_revnum_t start_revision,
336 svn_revnum_t end_revision,
337 svn_revnum_t low_water_mark,
338 svn_boolean_t send_deltas,
339 svn_ra__replay_revstart_ev2_callback_t revstart_func,
340 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
342 apr_pool_t *scratch_pool);
346 /* The RA session object. */
347 struct svn_ra_session_t {
348 const svn_ra__vtable_t *vtable;
350 /* Cancellation handlers consumers may want to use. */
351 svn_cancel_func_t cancel_func;
354 /* Pool used to manage this session. */
357 /* Private data for the RA implementation. */
361 /* Each libsvn_ra_foo defines a function named svn_ra_foo__init of this type.
363 * The LOADER_VERSION parameter must remain first in the list, and the
364 * function must use the C calling convention on all platforms, so that
365 * the init functions can safely read the version parameter.
367 * POOL will be available as long as this module is being used.
369 * ### need to force this to be __cdecl on Windows... how??
371 typedef svn_error_t *
372 (*svn_ra__init_func_t)(const svn_version_t *loader_version,
373 const svn_ra__vtable_t **vtable,
376 /* Declarations of the init functions for the available RA libraries. */
377 svn_error_t *svn_ra_local__init(const svn_version_t *loader_version,
378 const svn_ra__vtable_t **vtable,
380 svn_error_t *svn_ra_svn__init(const svn_version_t *loader_version,
381 const svn_ra__vtable_t **vtable,
383 svn_error_t *svn_ra_serf__init(const svn_version_t *loader_version,
384 const svn_ra__vtable_t **vtable,
389 /*** Compat Functions ***/
392 * Set *LOCATIONS to the locations (at the repository revisions
393 * LOCATION_REVISIONS) of the file identified by PATH in PEG_REVISION.
394 * PATH is relative to the URL to which SESSION was opened.
395 * LOCATION_REVISIONS is an array of svn_revnum_t's. *LOCATIONS will
396 * be a mapping from the revisions to their appropriate absolute
397 * paths. If the file doesn't exist in a location_revision, that
398 * revision will be ignored.
400 * Use POOL for all allocations.
402 * NOTE: This function uses the RA get_log interfaces to do its work,
403 * as a fallback mechanism for servers which don't support the native
407 svn_ra__locations_from_log(svn_ra_session_t *session,
408 apr_hash_t **locations_p,
410 svn_revnum_t peg_revision,
411 const apr_array_header_t *location_revisions,
415 * Call RECEIVER (with RECEIVER_BATON) for each segment in the
416 * location history of PATH in START_REV, working backwards in time
417 * from START_REV to END_REV.
419 * END_REV may be SVN_INVALID_REVNUM to indicate that you want to
420 * trace the history of the object to its origin.
422 * START_REV may be SVN_INVALID_REVNUM to indicate that you want to
423 * trace the history of the object beginning in the HEAD revision.
424 * Otherwise, START_REV must be younger than END_REV (unless END_REV
425 * is SVN_INVALID_REVNUM).
427 * Use POOL for all allocations.
429 * NOTE: This function uses the RA get_log interfaces to do its work,
430 * as a fallback mechanism for servers which don't support the native
431 * get_location_segments API.
434 svn_ra__location_segments_from_log(svn_ra_session_t *session,
436 svn_revnum_t peg_revision,
437 svn_revnum_t start_rev,
438 svn_revnum_t end_rev,
439 svn_location_segment_receiver_t receiver,
440 void *receiver_baton,
444 * Retrieve a subset of the interesting revisions of a file PATH
445 * as seen in revision END (see svn_fs_history_prev() for a
446 * definition of "interesting revisions"). Invoke HANDLER with
447 * @a handler_baton as its first argument for each such revision.
448 * @a session is an open RA session. Use POOL for all allocations.
450 * If there is an interesting revision of the file that is less than or
451 * equal to START, the iteration will begin at that revision.
452 * Else, the iteration will begin at the first revision of the file in
453 * the repository, which has to be less than or equal to END. Note
454 * that if the function succeeds, HANDLER will have been called at
457 * In a series of calls to HANDLER, the file contents for the first
458 * interesting revision will be provided as a text delta against the
459 * empty file. In the following calls, the delta will be against the
460 * fulltext contents for the previous call.
462 * NOTE: This function uses the RA get_log interfaces to do its work,
463 * as a fallback mechanism for servers which don't support the native
464 * get_location_segments API.
467 svn_ra__file_revs_from_log(svn_ra_session_t *session,
471 svn_file_rev_handler_t handler,
477 * Given a path REL_DELETED_PATH, relative to the URL of SESSION, which
478 * exists at PEG_REVISION, and an END_REVISION > PEG_REVISION at which
479 * REL_DELETED_PATH no longer exists, set *REVISION_DELETED to the revision
480 * REL_DELETED_PATH was first deleted or replaced, within the inclusive
481 * revision range defined by PEG_REVISION and END_REVISION.
483 * If REL_DELETED_PATH does not exist at PEG_REVISION or was not deleted prior
484 * to END_REVISION within the specified range, then set *REVISION_DELETED to
485 * SVN_INVALID_REVNUM. If PEG_REVISION or END_REVISION are invalid or if
486 * END_REVISION <= PEG_REVISION, then return SVN_ERR_CLIENT_BAD_REVISION.
488 * Use POOL for all allocations.
490 * NOTE: This function uses the RA get_log interfaces to do its work,
491 * as a fallback mechanism for servers which don't support the native
492 * get_deleted_rev API.
495 svn_ra__get_deleted_rev_from_log(svn_ra_session_t *session,
496 const char *rel_deleted_path,
497 svn_revnum_t peg_revision,
498 svn_revnum_t end_revision,
499 svn_revnum_t *revision_deleted,
504 * Fallback logic for svn_ra_get_inherited_props() when that API
505 * need to find PATH's inherited properties on a legacy server that
506 * doesn't have the SVN_RA_CAPABILITY_INHERITED_PROPS capability.
508 * All arguments are as per svn_ra_get_inherited_props().
511 svn_ra__get_inherited_props_walk(svn_ra_session_t *session,
513 svn_revnum_t revision,
514 apr_array_header_t **inherited_props,
515 apr_pool_t *result_pool,
516 apr_pool_t *scratch_pool);
518 /* Utility function to provide a shim between a returned Ev2 and an RA
519 provider's Ev1-based commit editor.
521 See svn_ra__get_commit_ev2() for parameter semantics. */
523 svn_ra__use_commit_shim(svn_editor_t **editor,
524 svn_ra_session_t *session,
525 apr_hash_t *revprop_table,
526 svn_commit_callback2_t callback,
527 void *callback_baton,
528 apr_hash_t *lock_tokens,
529 svn_boolean_t keep_locks,
530 svn_ra__provide_base_cb_t provide_base_cb,
531 svn_ra__provide_props_cb_t provide_props_cb,
532 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
534 svn_cancel_func_t cancel_func,
536 apr_pool_t *result_pool,
537 apr_pool_t *scratch_pool);
539 /* Utility function to provide a shim between a returned Ev2 and an RA
540 provider's Ev1-based commit editor.
542 See svn_ra__replay_range_ev2() for parameter semantics. */
544 svn_ra__use_replay_range_shim(svn_ra_session_t *session,
545 svn_revnum_t start_revision,
546 svn_revnum_t end_revision,
547 svn_revnum_t low_water_mark,
548 svn_boolean_t send_deltas,
549 svn_ra__replay_revstart_ev2_callback_t revstart_func,
550 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
552 svn_ra__provide_base_cb_t provide_base_cb,
553 svn_ra__provide_props_cb_t provide_props_cb,
555 apr_pool_t *scratch_pool);