ra_loader.h revision 262253
1/** 2 * @copyright 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 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 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 19 * under the License. 20 * ==================================================================== 21 * @endcopyright 22 * 23 * @file ra_loader.h 24 * @brief structures related to repository access, private to libsvn_ra and the 25 * RA implementation libraries. 26 */ 27 28 29 30#ifndef LIBSVN_RA_RA_LOADER_H 31#define LIBSVN_RA_RA_LOADER_H 32 33#include "svn_ra.h" 34 35#include "private/svn_ra_private.h" 36 37#ifdef __cplusplus 38extern "C" { 39#endif 40 41/* The RA layer vtable. */ 42typedef struct svn_ra__vtable_t { 43 /* This field should always remain first in the vtable. */ 44 const svn_version_t *(*get_version)(void); 45 46 /* Return a short description of the RA implementation, as a localized 47 * string. */ 48 const char *(*get_description)(apr_pool_t *pool); 49 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); 53 54 /* Implementations of the public API functions. */ 55 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, 63 void *callback_baton, 64 apr_hash_t *config, 65 apr_pool_t *pool); 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, 69 const char *url, 70 apr_pool_t *pool); 71 /* See svn_ra_get_session_url(). */ 72 svn_error_t *(*get_session_url)(svn_ra_session_t *session, 73 const char **url, 74 apr_pool_t *pool); 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, 78 apr_pool_t *pool); 79 /* See svn_ra_get_dated_revision(). */ 80 svn_error_t *(*get_dated_revision)(svn_ra_session_t *session, 81 svn_revnum_t *revision, 82 apr_time_t tm, 83 apr_pool_t *pool); 84 /* See svn_ra_change_rev_prop2(). */ 85 svn_error_t *(*change_rev_prop)(svn_ra_session_t *session, 86 svn_revnum_t rev, 87 const char *name, 88 const svn_string_t *const *old_value_p, 89 const svn_string_t *value, 90 apr_pool_t *pool); 91 92 /* See svn_ra_rev_proplist(). */ 93 svn_error_t *(*rev_proplist)(svn_ra_session_t *session, 94 svn_revnum_t rev, 95 apr_hash_t **props, 96 apr_pool_t *pool); 97 /* See svn_ra_rev_prop(). */ 98 svn_error_t *(*rev_prop)(svn_ra_session_t *session, 99 svn_revnum_t rev, 100 const char *name, 101 svn_string_t **value, 102 apr_pool_t *pool); 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, 106 void **edit_baton, 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, 112 apr_pool_t *pool); 113 /* See svn_ra_get_file(). */ 114 svn_error_t *(*get_file)(svn_ra_session_t *session, 115 const char *path, 116 svn_revnum_t revision, 117 svn_stream_t *stream, 118 svn_revnum_t *fetched_rev, 119 apr_hash_t **props, 120 apr_pool_t *pool); 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, 125 apr_hash_t **props, 126 const char *path, 127 svn_revnum_t revision, 128 apr_uint32_t dirent_fields, 129 apr_pool_t *pool); 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, 137 apr_pool_t *pool); 138 /* See svn_ra_do_update3(). */ 139 svn_error_t *(*do_update)(svn_ra_session_t *session, 140 const svn_ra_reporter3_t **reporter, 141 void **report_baton, 142 svn_revnum_t revision_to_update_to, 143 const char *update_target, 144 svn_depth_t depth, 145 svn_boolean_t send_copyfrom_args, 146 svn_boolean_t ignore_ancestry, 147 const svn_delta_editor_t *update_editor, 148 void *update_baton, 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, 154 void **report_baton, 155 svn_revnum_t revision_to_switch_to, 156 const char *switch_target, 157 svn_depth_t depth, 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, 162 void *switch_baton, 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, 168 void **report_baton, 169 const char *status_target, 170 svn_revnum_t revision, 171 svn_depth_t depth, 172 const svn_delta_editor_t *status_editor, 173 void *status_baton, 174 apr_pool_t *pool); 175 /* See svn_ra_do_diff3(). */ 176 svn_error_t *(*do_diff)(svn_ra_session_t *session, 177 const svn_ra_reporter3_t **reporter, 178 void **report_baton, 179 svn_revnum_t revision, 180 const char *diff_target, 181 svn_depth_t depth, 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, 186 void *diff_baton, 187 apr_pool_t *pool); 188 /* See svn_ra_get_log2(). */ 189 svn_error_t *(*get_log)(svn_ra_session_t *session, 190 const apr_array_header_t *paths, 191 svn_revnum_t start, 192 svn_revnum_t end, 193 int limit, 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, 200 apr_pool_t *pool); 201 /* See svn_ra_check_path(). */ 202 svn_error_t *(*check_path)(svn_ra_session_t *session, 203 const char *path, 204 svn_revnum_t revision, 205 svn_node_kind_t *kind, 206 apr_pool_t *pool); 207 /* See svn_ra_stat(). */ 208 svn_error_t *(*stat)(svn_ra_session_t *session, 209 const char *path, 210 svn_revnum_t revision, 211 svn_dirent_t **dirent, 212 apr_pool_t *pool); 213 /* See svn_ra_get_uuid2(). */ 214 svn_error_t *(*get_uuid)(svn_ra_session_t *session, 215 const char **uuid, 216 apr_pool_t *pool); 217 /* See svn_ra_get_repos_root2(). */ 218 svn_error_t *(*get_repos_root)(svn_ra_session_t *session, 219 const char **url, 220 apr_pool_t *pool); 221 /* See svn_ra_get_locations(). */ 222 svn_error_t *(*get_locations)(svn_ra_session_t *session, 223 apr_hash_t **locations, 224 const char *path, 225 svn_revnum_t peg_revision, 226 const apr_array_header_t *location_revisions, 227 apr_pool_t *pool); 228 /* See svn_ra_get_location_segments(). */ 229 svn_error_t *(*get_location_segments)(svn_ra_session_t *session, 230 const char *path, 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, 236 apr_pool_t *pool); 237 /* See svn_ra_get_file_revs2(). */ 238 svn_error_t *(*get_file_revs)(svn_ra_session_t *session, 239 const char *path, 240 svn_revnum_t start, 241 svn_revnum_t end, 242 svn_boolean_t include_merged_revisions, 243 svn_file_rev_handler_t handler, 244 void *handler_baton, 245 apr_pool_t *pool); 246 /* See svn_ra_lock(). */ 247 svn_error_t *(*lock)(svn_ra_session_t *session, 248 apr_hash_t *path_revs, 249 const char *comment, 250 svn_boolean_t force, 251 svn_ra_lock_callback_t lock_func, 252 void *lock_baton, 253 apr_pool_t *pool); 254 /* See svn_ra_unlock(). */ 255 svn_error_t *(*unlock)(svn_ra_session_t *session, 256 apr_hash_t *path_tokens, 257 svn_boolean_t force, 258 svn_ra_lock_callback_t lock_func, 259 void *lock_baton, 260 apr_pool_t *pool); 261 /* See svn_ra_get_lock(). */ 262 svn_error_t *(*get_lock)(svn_ra_session_t *session, 263 svn_lock_t **lock, 264 const char *path, 265 apr_pool_t *pool); 266 /* See svn_ra_get_locks2(). */ 267 svn_error_t *(*get_locks)(svn_ra_session_t *session, 268 apr_hash_t **locks, 269 const char *path, 270 svn_depth_t depth, 271 apr_pool_t *pool); 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, 278 void *edit_baton, 279 apr_pool_t *pool); 280 /* See svn_ra_has_capability(). */ 281 svn_error_t *(*has_capability)(svn_ra_session_t *session, 282 svn_boolean_t *has, 283 const char *capability, 284 apr_pool_t *pool); 285 /* See svn_ra_replay_range(). */ 286 svn_error_t * 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, 294 void *replay_baton, 295 apr_pool_t *pool); 296 /* See svn_ra_get_deleted_rev(). */ 297 svn_error_t *(*get_deleted_rev)(svn_ra_session_t *session, 298 const char *path, 299 svn_revnum_t peg_revision, 300 svn_revnum_t end_revision, 301 svn_revnum_t *revision_deleted, 302 apr_pool_t *pool); 303 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, 310 const char *path, 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, 326 void *cb_baton, 327 svn_cancel_func_t cancel_func, 328 void *cancel_baton, 329 apr_pool_t *result_pool, 330 apr_pool_t *scratch_pool); 331 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, 341 void *replay_baton, 342 apr_pool_t *scratch_pool); 343 344} svn_ra__vtable_t; 345 346/* The RA session object. */ 347struct svn_ra_session_t { 348 const svn_ra__vtable_t *vtable; 349 350 /* Cancellation handlers consumers may want to use. */ 351 svn_cancel_func_t cancel_func; 352 void *cancel_baton; 353 354 /* Pool used to manage this session. */ 355 apr_pool_t *pool; 356 357 /* Private data for the RA implementation. */ 358 void *priv; 359}; 360 361/* Each libsvn_ra_foo defines a function named svn_ra_foo__init of this type. 362 * 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. 366 * 367 * POOL will be available as long as this module is being used. 368 * 369 * ### need to force this to be __cdecl on Windows... how?? 370 */ 371typedef svn_error_t * 372(*svn_ra__init_func_t)(const svn_version_t *loader_version, 373 const svn_ra__vtable_t **vtable, 374 apr_pool_t *pool); 375 376/* Declarations of the init functions for the available RA libraries. */ 377svn_error_t *svn_ra_local__init(const svn_version_t *loader_version, 378 const svn_ra__vtable_t **vtable, 379 apr_pool_t *pool); 380svn_error_t *svn_ra_svn__init(const svn_version_t *loader_version, 381 const svn_ra__vtable_t **vtable, 382 apr_pool_t *pool); 383svn_error_t *svn_ra_serf__init(const svn_version_t *loader_version, 384 const svn_ra__vtable_t **vtable, 385 apr_pool_t *pool); 386 387 388 389/*** Compat Functions ***/ 390 391/** 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. 399 * 400 * Use POOL for all allocations. 401 * 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 404 * get_locations API. 405 */ 406svn_error_t * 407svn_ra__locations_from_log(svn_ra_session_t *session, 408 apr_hash_t **locations_p, 409 const char *path, 410 svn_revnum_t peg_revision, 411 const apr_array_header_t *location_revisions, 412 apr_pool_t *pool); 413 414/** 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. 418 * 419 * END_REV may be SVN_INVALID_REVNUM to indicate that you want to 420 * trace the history of the object to its origin. 421 * 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). 426 * 427 * Use POOL for all allocations. 428 * 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. 432 */ 433svn_error_t * 434svn_ra__location_segments_from_log(svn_ra_session_t *session, 435 const char *path, 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, 441 apr_pool_t *pool); 442 443/** 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. 449 * 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 455 * least once. 456 * 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. 461 * 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. 465 */ 466svn_error_t * 467svn_ra__file_revs_from_log(svn_ra_session_t *session, 468 const char *path, 469 svn_revnum_t start, 470 svn_revnum_t end, 471 svn_file_rev_handler_t handler, 472 void *handler_baton, 473 apr_pool_t *pool); 474 475 476/** 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. 482 * 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. 487 * 488 * Use POOL for all allocations. 489 * 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. 493 */ 494svn_error_t * 495svn_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, 500 apr_pool_t *pool); 501 502 503/** 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. 507 * 508 * All arguments are as per svn_ra_get_inherited_props(). 509 */ 510svn_error_t * 511svn_ra__get_inherited_props_walk(svn_ra_session_t *session, 512 const char *path, 513 svn_revnum_t revision, 514 apr_array_header_t **inherited_props, 515 apr_pool_t *result_pool, 516 apr_pool_t *scratch_pool); 517 518/* Utility function to provide a shim between a returned Ev2 and an RA 519 provider's Ev1-based commit editor. 520 521 See svn_ra__get_commit_ev2() for parameter semantics. */ 522svn_error_t * 523svn_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, 533 void *cb_baton, 534 svn_cancel_func_t cancel_func, 535 void *cancel_baton, 536 apr_pool_t *result_pool, 537 apr_pool_t *scratch_pool); 538 539/* Utility function to provide a shim between a returned Ev2 and an RA 540 provider's Ev1-based commit editor. 541 542 See svn_ra__replay_range_ev2() for parameter semantics. */ 543svn_error_t * 544svn_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, 551 void *replay_baton, 552 svn_ra__provide_base_cb_t provide_base_cb, 553 svn_ra__provide_props_cb_t provide_props_cb, 554 void *cb_baton, 555 apr_pool_t *scratch_pool); 556 557 558#ifdef __cplusplus 559} 560#endif 561 562#endif 563