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 /* 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); 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 svn_auth_baton_t *auth_baton, 65 apr_hash_t *config, 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, 77 const char *url, 78 apr_pool_t *pool); 79 /* See svn_ra_get_session_url(). */ 80 svn_error_t *(*get_session_url)(svn_ra_session_t *session, 81 const char **url, 82 apr_pool_t *pool); 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, 86 apr_pool_t *pool); 87 /* See svn_ra_get_dated_revision(). */ 88 svn_error_t *(*get_dated_revision)(svn_ra_session_t *session, 89 svn_revnum_t *revision, 90 apr_time_t tm, 91 apr_pool_t *pool); 92 /* See svn_ra_change_rev_prop2(). */ 93 svn_error_t *(*change_rev_prop)(svn_ra_session_t *session, 94 svn_revnum_t rev, 95 const char *name, 96 const svn_string_t *const *old_value_p, 97 const svn_string_t *value, 98 apr_pool_t *pool); 99 100 /* See svn_ra_rev_proplist(). */ 101 svn_error_t *(*rev_proplist)(svn_ra_session_t *session, 102 svn_revnum_t rev, 103 apr_hash_t **props, 104 apr_pool_t *pool); 105 /* See svn_ra_rev_prop(). */ 106 svn_error_t *(*rev_prop)(svn_ra_session_t *session, 107 svn_revnum_t rev, 108 const char *name, 109 svn_string_t **value, 110 apr_pool_t *pool); 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, 114 void **edit_baton, 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, 120 apr_pool_t *pool); 121 /* See svn_ra_get_file(). */ 122 svn_error_t *(*get_file)(svn_ra_session_t *session, 123 const char *path, 124 svn_revnum_t revision, 125 svn_stream_t *stream, 126 svn_revnum_t *fetched_rev, 127 apr_hash_t **props, 128 apr_pool_t *pool); 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, 133 apr_hash_t **props, 134 const char *path, 135 svn_revnum_t revision, 136 apr_uint32_t dirent_fields, 137 apr_pool_t *pool); 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, 145 apr_pool_t *pool); 146 /* See svn_ra_do_update3(). */ 147 svn_error_t *(*do_update)(svn_ra_session_t *session, 148 const svn_ra_reporter3_t **reporter, 149 void **report_baton, 150 svn_revnum_t revision_to_update_to, 151 const char *update_target, 152 svn_depth_t depth, 153 svn_boolean_t send_copyfrom_args, 154 svn_boolean_t ignore_ancestry, 155 const svn_delta_editor_t *update_editor, 156 void *update_baton, 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, 162 void **report_baton, 163 svn_revnum_t revision_to_switch_to, 164 const char *switch_target, 165 svn_depth_t depth, 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, 170 void *switch_baton, 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, 176 void **report_baton, 177 const char *status_target, 178 svn_revnum_t revision, 179 svn_depth_t depth, 180 const svn_delta_editor_t *status_editor, 181 void *status_baton, 182 apr_pool_t *pool); 183 /* See svn_ra_do_diff3(). */ 184 svn_error_t *(*do_diff)(svn_ra_session_t *session, 185 const svn_ra_reporter3_t **reporter, 186 void **report_baton, 187 svn_revnum_t revision, 188 const char *diff_target, 189 svn_depth_t depth, 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, 194 void *diff_baton, 195 apr_pool_t *pool); 196 /* See svn_ra_get_log2(). */ 197 svn_error_t *(*get_log)(svn_ra_session_t *session, 198 const apr_array_header_t *paths, 199 svn_revnum_t start, 200 svn_revnum_t end, 201 int limit, 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, 208 apr_pool_t *pool); 209 /* See svn_ra_check_path(). */ 210 svn_error_t *(*check_path)(svn_ra_session_t *session, 211 const char *path, 212 svn_revnum_t revision, 213 svn_node_kind_t *kind, 214 apr_pool_t *pool); 215 /* See svn_ra_stat(). */ 216 svn_error_t *(*stat)(svn_ra_session_t *session, 217 const char *path, 218 svn_revnum_t revision, 219 svn_dirent_t **dirent, 220 apr_pool_t *pool); 221 /* See svn_ra_get_uuid2(). */ 222 svn_error_t *(*get_uuid)(svn_ra_session_t *session, 223 const char **uuid, 224 apr_pool_t *pool); 225 /* See svn_ra_get_repos_root2(). */ 226 svn_error_t *(*get_repos_root)(svn_ra_session_t *session, 227 const char **url, 228 apr_pool_t *pool); 229 /* See svn_ra_get_locations(). */ 230 svn_error_t *(*get_locations)(svn_ra_session_t *session, 231 apr_hash_t **locations, 232 const char *path, 233 svn_revnum_t peg_revision, 234 const apr_array_header_t *location_revisions, 235 apr_pool_t *pool); 236 /* See svn_ra_get_location_segments(). */ 237 svn_error_t *(*get_location_segments)(svn_ra_session_t *session, 238 const char *path, 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, 244 apr_pool_t *pool); 245 /* See svn_ra_get_file_revs2(). */ 246 svn_error_t *(*get_file_revs)(svn_ra_session_t *session, 247 const char *path, 248 svn_revnum_t start, 249 svn_revnum_t end, 250 svn_boolean_t include_merged_revisions, 251 svn_file_rev_handler_t handler, 252 void *handler_baton, 253 apr_pool_t *pool); 254 /* See svn_ra_lock(). */ 255 svn_error_t *(*lock)(svn_ra_session_t *session, 256 apr_hash_t *path_revs, 257 const char *comment, 258 svn_boolean_t force, 259 svn_ra_lock_callback_t lock_func, 260 void *lock_baton, 261 apr_pool_t *pool); 262 /* See svn_ra_unlock(). */ 263 svn_error_t *(*unlock)(svn_ra_session_t *session, 264 apr_hash_t *path_tokens, 265 svn_boolean_t force, 266 svn_ra_lock_callback_t lock_func, 267 void *lock_baton, 268 apr_pool_t *pool); 269 /* See svn_ra_get_lock(). */ 270 svn_error_t *(*get_lock)(svn_ra_session_t *session, 271 svn_lock_t **lock, 272 const char *path, 273 apr_pool_t *pool); 274 /* See svn_ra_get_locks2(). */ 275 svn_error_t *(*get_locks)(svn_ra_session_t *session, 276 apr_hash_t **locks, 277 const char *path, 278 svn_depth_t depth, 279 apr_pool_t *pool); 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, 286 void *edit_baton, 287 apr_pool_t *pool); 288 /* See svn_ra_has_capability(). */ 289 svn_error_t *(*has_capability)(svn_ra_session_t *session, 290 svn_boolean_t *has, 291 const char *capability, 292 apr_pool_t *pool); 293 /* See svn_ra_replay_range(). */ 294 svn_error_t * 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, 302 void *replay_baton, 303 apr_pool_t *pool); 304 /* See svn_ra_get_deleted_rev(). */ 305 svn_error_t *(*get_deleted_rev)(svn_ra_session_t *session, 306 const char *path, 307 svn_revnum_t peg_revision, 308 svn_revnum_t end_revision, 309 svn_revnum_t *revision_deleted, 310 apr_pool_t *pool); 311 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, 318 const char *path, 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, 334 void *cb_baton, 335 svn_cancel_func_t cancel_func, 336 void *cancel_baton, 337 apr_pool_t *result_pool, 338 apr_pool_t *scratch_pool); 339 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, 349 void *replay_baton, 350 apr_pool_t *scratch_pool); 351 352 } svn_ra__vtable_t; 353 354 /* The RA session object. */ 355 struct svn_ra_session_t { 356 const svn_ra__vtable_t *vtable; 357 358 /* Cancellation handlers consumers may want to use. */ 359 svn_cancel_func_t cancel_func; 360 void *cancel_baton; 361 362 /* Pool used to manage this session. */ 363 apr_pool_t *pool; 364 365 /* Private data for the RA implementation. */ 366 void *priv; 367 }; 368 369 /* Each libsvn_ra_foo defines a function named svn_ra_foo__init of this type. 370 * 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. 374 * 375 * POOL will be available as long as this module is being used. 376 * 377 * ### need to force this to be __cdecl on Windows... how?? 378 */ 379 typedef svn_error_t * 380 (*svn_ra__init_func_t)(const svn_version_t *loader_version, 381 const svn_ra__vtable_t **vtable, 382 apr_pool_t *pool); 383 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, 387 apr_pool_t *pool); 388 svn_error_t *svn_ra_svn__init(const svn_version_t *loader_version, 389 const svn_ra__vtable_t **vtable, 390 apr_pool_t *pool); 391 svn_error_t *svn_ra_serf__init(const svn_version_t *loader_version, 392 const svn_ra__vtable_t **vtable, 393 apr_pool_t *pool); 394 395 396 397 /*** Compat Functions ***/ 398 399 /** 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. 407 * 408 * Use POOL for all allocations. 409 * 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 412 * get_locations API. 413 */ 414 svn_error_t * 415 svn_ra__locations_from_log(svn_ra_session_t *session, 416 apr_hash_t **locations_p, 417 const char *path, 418 svn_revnum_t peg_revision, 419 const apr_array_header_t *location_revisions, 420 apr_pool_t *pool); 421 422 /** 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. 426 * 427 * END_REV may be SVN_INVALID_REVNUM to indicate that you want to 428 * trace the history of the object to its origin. 429 * 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). 434 * 435 * Use POOL for all allocations. 436 * 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. 440 */ 441 svn_error_t * 442 svn_ra__location_segments_from_log(svn_ra_session_t *session, 443 const char *path, 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, 449 apr_pool_t *pool); 450 451 /** 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. 457 * 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 463 * least once. 464 * 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. 469 * 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. 473 */ 474 svn_error_t * 475 svn_ra__file_revs_from_log(svn_ra_session_t *session, 476 const char *path, 477 svn_revnum_t start, 478 svn_revnum_t end, 479 svn_file_rev_handler_t handler, 480 void *handler_baton, 481 apr_pool_t *pool); 482 483 484 /** 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. 490 * 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. 495 * 496 * Use POOL for all allocations. 497 * 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. 501 */ 502 svn_error_t * 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, 508 apr_pool_t *pool); 509 510 511 /** 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. 515 * 516 * All arguments are as per svn_ra_get_inherited_props(). 517 */ 518 svn_error_t * 519 svn_ra__get_inherited_props_walk(svn_ra_session_t *session, 520 const char *path, 521 svn_revnum_t revision, 522 apr_array_header_t **inherited_props, 523 apr_pool_t *result_pool, 524 apr_pool_t *scratch_pool); 525 526 /* Utility function to provide a shim between a returned Ev2 and an RA 527 provider's Ev1-based commit editor. 528 529 See svn_ra__get_commit_ev2() for parameter semantics. */ 530 svn_error_t * 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, 541 void *cb_baton, 542 svn_cancel_func_t cancel_func, 543 void *cancel_baton, 544 apr_pool_t *result_pool, 545 apr_pool_t *scratch_pool); 546 547 /* Utility function to provide a shim between a returned Ev2 and an RA 548 provider's Ev1-based commit editor. 549 550 See svn_ra__replay_range_ev2() for parameter semantics. */ 551 svn_error_t * 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, 559 void *replay_baton, 560 svn_ra__provide_base_cb_t provide_base_cb, 561 svn_ra__provide_props_cb_t provide_props_cb, 562 void *cb_baton, 563 apr_pool_t *scratch_pool); 564 565 566 #ifdef __cplusplus 567 } 568 #endif 569 570 #endif 571