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 38 extern "C" { 39 #endif 40 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, 46 const char *uuid, 47 const svn_ra_callbacks2_t *callbacks, 48 void *callback_baton, 49 apr_hash_t *config, 50 apr_pool_t *pool); 51 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); 56 57 /* Return a short description of the RA implementation, as a localized 58 * string. */ 59 const char *(*get_description)(apr_pool_t *pool); 60 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); 64 65 /* Implementations of the public API functions. */ 66 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, 74 void *callback_baton, 75 svn_auth_baton_t *auth_baton, 76 apr_hash_t *config, 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, 88 const char *url, 89 apr_pool_t *pool); 90 /* See svn_ra_get_session_url(). */ 91 svn_error_t *(*get_session_url)(svn_ra_session_t *session, 92 const char **url, 93 apr_pool_t *pool); 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, 97 apr_pool_t *pool); 98 /* See svn_ra_get_dated_revision(). */ 99 svn_error_t *(*get_dated_revision)(svn_ra_session_t *session, 100 svn_revnum_t *revision, 101 apr_time_t tm, 102 apr_pool_t *pool); 103 /* See svn_ra_change_rev_prop2(). */ 104 svn_error_t *(*change_rev_prop)(svn_ra_session_t *session, 105 svn_revnum_t rev, 106 const char *name, 107 const svn_string_t *const *old_value_p, 108 const svn_string_t *value, 109 apr_pool_t *pool); 110 111 /* See svn_ra_rev_proplist(). */ 112 svn_error_t *(*rev_proplist)(svn_ra_session_t *session, 113 svn_revnum_t rev, 114 apr_hash_t **props, 115 apr_pool_t *pool); 116 /* See svn_ra_rev_prop(). */ 117 svn_error_t *(*rev_prop)(svn_ra_session_t *session, 118 svn_revnum_t rev, 119 const char *name, 120 svn_string_t **value, 121 apr_pool_t *pool); 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, 125 void **edit_baton, 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, 131 apr_pool_t *pool); 132 /* See svn_ra_get_file(). */ 133 svn_error_t *(*get_file)(svn_ra_session_t *session, 134 const char *path, 135 svn_revnum_t revision, 136 svn_stream_t *stream, 137 svn_revnum_t *fetched_rev, 138 apr_hash_t **props, 139 apr_pool_t *pool); 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, 144 apr_hash_t **props, 145 const char *path, 146 svn_revnum_t revision, 147 apr_uint32_t dirent_fields, 148 apr_pool_t *pool); 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, 156 apr_pool_t *pool); 157 /* See svn_ra_do_update3(). */ 158 svn_error_t *(*do_update)(svn_ra_session_t *session, 159 const svn_ra_reporter3_t **reporter, 160 void **report_baton, 161 svn_revnum_t revision_to_update_to, 162 const char *update_target, 163 svn_depth_t depth, 164 svn_boolean_t send_copyfrom_args, 165 svn_boolean_t ignore_ancestry, 166 const svn_delta_editor_t *update_editor, 167 void *update_baton, 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, 173 void **report_baton, 174 svn_revnum_t revision_to_switch_to, 175 const char *switch_target, 176 svn_depth_t depth, 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, 181 void *switch_baton, 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, 187 void **report_baton, 188 const char *status_target, 189 svn_revnum_t revision, 190 svn_depth_t depth, 191 const svn_delta_editor_t *status_editor, 192 void *status_baton, 193 apr_pool_t *pool); 194 /* See svn_ra_do_diff3(). */ 195 svn_error_t *(*do_diff)(svn_ra_session_t *session, 196 const svn_ra_reporter3_t **reporter, 197 void **report_baton, 198 svn_revnum_t revision, 199 const char *diff_target, 200 svn_depth_t depth, 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, 205 void *diff_baton, 206 apr_pool_t *pool); 207 /* See svn_ra_get_log2(). */ 208 svn_error_t *(*get_log)(svn_ra_session_t *session, 209 const apr_array_header_t *paths, 210 svn_revnum_t start, 211 svn_revnum_t end, 212 int limit, 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, 219 apr_pool_t *pool); 220 /* See svn_ra_check_path(). */ 221 svn_error_t *(*check_path)(svn_ra_session_t *session, 222 const char *path, 223 svn_revnum_t revision, 224 svn_node_kind_t *kind, 225 apr_pool_t *pool); 226 /* See svn_ra_stat(). */ 227 svn_error_t *(*stat)(svn_ra_session_t *session, 228 const char *path, 229 svn_revnum_t revision, 230 svn_dirent_t **dirent, 231 apr_pool_t *pool); 232 /* See svn_ra_get_uuid2(). */ 233 svn_error_t *(*get_uuid)(svn_ra_session_t *session, 234 const char **uuid, 235 apr_pool_t *pool); 236 /* See svn_ra_get_repos_root2(). */ 237 svn_error_t *(*get_repos_root)(svn_ra_session_t *session, 238 const char **url, 239 apr_pool_t *pool); 240 /* See svn_ra_get_locations(). */ 241 svn_error_t *(*get_locations)(svn_ra_session_t *session, 242 apr_hash_t **locations, 243 const char *path, 244 svn_revnum_t peg_revision, 245 const apr_array_header_t *location_revisions, 246 apr_pool_t *pool); 247 /* See svn_ra_get_location_segments(). */ 248 svn_error_t *(*get_location_segments)(svn_ra_session_t *session, 249 const char *path, 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, 255 apr_pool_t *pool); 256 /* See svn_ra_get_file_revs2(). */ 257 svn_error_t *(*get_file_revs)(svn_ra_session_t *session, 258 const char *path, 259 svn_revnum_t start, 260 svn_revnum_t end, 261 svn_boolean_t include_merged_revisions, 262 svn_file_rev_handler_t handler, 263 void *handler_baton, 264 apr_pool_t *pool); 265 /* See svn_ra_lock(). */ 266 svn_error_t *(*lock)(svn_ra_session_t *session, 267 apr_hash_t *path_revs, 268 const char *comment, 269 svn_boolean_t force, 270 svn_ra_lock_callback_t lock_func, 271 void *lock_baton, 272 apr_pool_t *pool); 273 /* See svn_ra_unlock(). */ 274 svn_error_t *(*unlock)(svn_ra_session_t *session, 275 apr_hash_t *path_tokens, 276 svn_boolean_t force, 277 svn_ra_lock_callback_t lock_func, 278 void *lock_baton, 279 apr_pool_t *pool); 280 /* See svn_ra_get_lock(). */ 281 svn_error_t *(*get_lock)(svn_ra_session_t *session, 282 svn_lock_t **lock, 283 const char *path, 284 apr_pool_t *pool); 285 /* See svn_ra_get_locks2(). */ 286 svn_error_t *(*get_locks)(svn_ra_session_t *session, 287 apr_hash_t **locks, 288 const char *path, 289 svn_depth_t depth, 290 apr_pool_t *pool); 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, 297 void *edit_baton, 298 apr_pool_t *pool); 299 /* See svn_ra_has_capability(). */ 300 svn_error_t *(*has_capability)(svn_ra_session_t *session, 301 svn_boolean_t *has, 302 const char *capability, 303 apr_pool_t *pool); 304 /* See svn_ra_replay_range(). */ 305 svn_error_t * 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, 313 void *replay_baton, 314 apr_pool_t *pool); 315 /* See svn_ra_get_deleted_rev(). */ 316 svn_error_t *(*get_deleted_rev)(svn_ra_session_t *session, 317 const char *path, 318 svn_revnum_t peg_revision, 319 svn_revnum_t end_revision, 320 svn_revnum_t *revision_deleted, 321 apr_pool_t *pool); 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, 325 const char *path, 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 331 library dependency*/ 332 svn_error_t *(*set_svn_ra_open)(svn_ra_session_t *session, 333 svn_ra__open_func_t func); 334 335 /* See svn_ra_list(). */ 336 svn_error_t *(*list)(svn_ra_session_t *session, 337 const char *path, 338 svn_revnum_t revision, 339 const apr_array_header_t *patterns, 340 svn_depth_t depth, 341 apr_uint32_t dirent_fields, 342 svn_ra_dirent_receiver_t receiver, 343 void *receiver_baton, 344 apr_pool_t *scratch_pool); 345 346 /* Experimental support below here */ 347 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, 363 void *cb_baton, 364 svn_cancel_func_t cancel_func, 365 void *cancel_baton, 366 apr_pool_t *result_pool, 367 apr_pool_t *scratch_pool); 368 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, 378 void *replay_baton, 379 apr_pool_t *scratch_pool); 380 381 } svn_ra__vtable_t; 382 383 /* The RA session object. */ 384 struct svn_ra_session_t { 385 const svn_ra__vtable_t *vtable; 386 387 /* Cancellation handlers consumers may want to use. */ 388 svn_cancel_func_t cancel_func; 389 void *cancel_baton; 390 391 /* Pool used to manage this session. */ 392 apr_pool_t *pool; 393 394 /* Private data for the RA implementation. */ 395 void *priv; 396 }; 397 398 /* Each libsvn_ra_foo defines a function named svn_ra_foo__init of this type. 399 * 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. 403 * 404 * POOL will be available as long as this module is being used. 405 * 406 * ### need to force this to be __cdecl on Windows... how?? 407 */ 408 typedef svn_error_t * 409 (*svn_ra__init_func_t)(const svn_version_t *loader_version, 410 const svn_ra__vtable_t **vtable, 411 apr_pool_t *pool); 412 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, 416 apr_pool_t *pool); 417 svn_error_t *svn_ra_svn__init(const svn_version_t *loader_version, 418 const svn_ra__vtable_t **vtable, 419 apr_pool_t *pool); 420 svn_error_t *svn_ra_serf__init(const svn_version_t *loader_version, 421 const svn_ra__vtable_t **vtable, 422 apr_pool_t *pool); 423 424 425 426 /*** Compat Functions ***/ 427 428 /** 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. 436 * 437 * Use POOL for all allocations. 438 * 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 441 * get_locations API. 442 */ 443 svn_error_t * 444 svn_ra__locations_from_log(svn_ra_session_t *session, 445 apr_hash_t **locations_p, 446 const char *path, 447 svn_revnum_t peg_revision, 448 const apr_array_header_t *location_revisions, 449 apr_pool_t *pool); 450 451 /** 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. 455 * 456 * END_REV may be SVN_INVALID_REVNUM to indicate that you want to 457 * trace the history of the object to its origin. 458 * 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). 463 * 464 * Use POOL for all allocations. 465 * 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. 469 */ 470 svn_error_t * 471 svn_ra__location_segments_from_log(svn_ra_session_t *session, 472 const char *path, 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, 478 apr_pool_t *pool); 479 480 /** 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. 486 * 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 492 * least once. 493 * 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. 498 * 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. 502 */ 503 svn_error_t * 504 svn_ra__file_revs_from_log(svn_ra_session_t *session, 505 const char *path, 506 svn_revnum_t start, 507 svn_revnum_t end, 508 svn_file_rev_handler_t handler, 509 void *handler_baton, 510 apr_pool_t *pool); 511 512 513 /** 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. 519 * 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. 524 * 525 * Use POOL for all allocations. 526 * 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. 530 */ 531 svn_error_t * 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, 537 apr_pool_t *pool); 538 539 540 /** 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. 544 * 545 * All arguments are as per svn_ra_get_inherited_props(). 546 */ 547 svn_error_t * 548 svn_ra__get_inherited_props_walk(svn_ra_session_t *session, 549 const char *path, 550 svn_revnum_t revision, 551 apr_array_header_t **inherited_props, 552 apr_pool_t *result_pool, 553 apr_pool_t *scratch_pool); 554 555 /* Utility function to provide a shim between a returned Ev2 and an RA 556 provider's Ev1-based commit editor. 557 558 See svn_ra__get_commit_ev2() for parameter semantics. */ 559 svn_error_t * 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, 570 void *cb_baton, 571 svn_cancel_func_t cancel_func, 572 void *cancel_baton, 573 apr_pool_t *result_pool, 574 apr_pool_t *scratch_pool); 575 576 /* Utility function to provide a shim between a returned Ev2 and an RA 577 provider's Ev1-based commit editor. 578 579 See svn_ra__replay_range_ev2() for parameter semantics. */ 580 svn_error_t * 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, 588 void *replay_baton, 589 svn_ra__provide_base_cb_t provide_base_cb, 590 svn_ra__provide_props_cb_t provide_props_cb, 591 void *cb_baton, 592 apr_pool_t *scratch_pool); 593 594 595 #ifdef __cplusplus 596 } 597 #endif 598 599 #endif 600