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/* Prototype of most recent version of svn_ra_openX() api, optionally 42 handed to the ra api to allow opening other ra sessions. */ 43typedef svn_error_t * (*svn_ra__open_func_t)(svn_ra_session_t **session_p, 44 const char **corrected_url, 45 const char **redirect_url, 46 const char *repos_URL, 47 const char *uuid, 48 const svn_ra_callbacks2_t *callbacks, 49 void *callback_baton, 50 apr_hash_t *config, 51 apr_pool_t *pool); 52 53/* The RA layer vtable. */ 54typedef struct svn_ra__vtable_t { 55 /* This field should always remain first in the vtable. */ 56 const svn_version_t *(*get_version)(void); 57 58 /* Return a short description of the RA implementation, as a localized 59 * string. */ 60 const char *(*get_description)(apr_pool_t *pool); 61 62 /* Return a list of actual URI schemes supported by this implementation. 63 * The returned array is NULL-terminated. */ 64 const char * const *(*get_schemes)(apr_pool_t *pool); 65 66 /* Implementations of the public API functions. */ 67 68 /* See svn_ra_open5(). */ 69 /* All fields in SESSION, except priv, have been initialized by the 70 time this is called. SESSION->priv may be set by this function. */ 71 svn_error_t *(*open_session)(svn_ra_session_t *session, 72 const char **corrected_url, 73 const char **redirect_url, 74 const char *session_URL, 75 const svn_ra_callbacks2_t *callbacks, 76 void *callback_baton, 77 svn_auth_baton_t *auth_baton, 78 apr_hash_t *config, 79 apr_pool_t *result_pool, 80 apr_pool_t *scratch_pool); 81 /* Backs svn_ra_dup_session */ 82 svn_error_t * (*dup_session)(svn_ra_session_t *new_session, 83 svn_ra_session_t *old_session, 84 const char *new_session_url, 85 apr_pool_t *result_pool, 86 apr_pool_t *scratch_pool); 87 /* See svn_ra_reparent(). */ 88 /* URL is guaranteed to have what get_repos_root() returns as a prefix. */ 89 svn_error_t *(*reparent)(svn_ra_session_t *session, 90 const char *url, 91 apr_pool_t *pool); 92 /* See svn_ra_get_session_url(). */ 93 svn_error_t *(*get_session_url)(svn_ra_session_t *session, 94 const char **url, 95 apr_pool_t *pool); 96 /* See svn_ra_get_latest_revnum(). */ 97 svn_error_t *(*get_latest_revnum)(svn_ra_session_t *session, 98 svn_revnum_t *latest_revnum, 99 apr_pool_t *pool); 100 /* See svn_ra_get_dated_revision(). */ 101 svn_error_t *(*get_dated_revision)(svn_ra_session_t *session, 102 svn_revnum_t *revision, 103 apr_time_t tm, 104 apr_pool_t *pool); 105 /* See svn_ra_change_rev_prop2(). */ 106 svn_error_t *(*change_rev_prop)(svn_ra_session_t *session, 107 svn_revnum_t rev, 108 const char *name, 109 const svn_string_t *const *old_value_p, 110 const svn_string_t *value, 111 apr_pool_t *pool); 112 113 /* See svn_ra_rev_proplist(). */ 114 svn_error_t *(*rev_proplist)(svn_ra_session_t *session, 115 svn_revnum_t rev, 116 apr_hash_t **props, 117 apr_pool_t *pool); 118 /* See svn_ra_rev_prop(). */ 119 svn_error_t *(*rev_prop)(svn_ra_session_t *session, 120 svn_revnum_t rev, 121 const char *name, 122 svn_string_t **value, 123 apr_pool_t *pool); 124 /* See svn_ra_get_commit_editor3(). */ 125 svn_error_t *(*get_commit_editor)(svn_ra_session_t *session, 126 const svn_delta_editor_t **editor, 127 void **edit_baton, 128 apr_hash_t *revprop_table, 129 svn_commit_callback2_t callback, 130 void *callback_baton, 131 apr_hash_t *lock_tokens, 132 svn_boolean_t keep_locks, 133 apr_pool_t *pool); 134 /* See svn_ra_get_file(). */ 135 svn_error_t *(*get_file)(svn_ra_session_t *session, 136 const char *path, 137 svn_revnum_t revision, 138 svn_stream_t *stream, 139 svn_revnum_t *fetched_rev, 140 apr_hash_t **props, 141 apr_pool_t *pool); 142 /* See svn_ra_get_dir2(). */ 143 svn_error_t *(*get_dir)(svn_ra_session_t *session, 144 apr_hash_t **dirents, 145 svn_revnum_t *fetched_rev, 146 apr_hash_t **props, 147 const char *path, 148 svn_revnum_t revision, 149 apr_uint32_t dirent_fields, 150 apr_pool_t *pool); 151 /* See svn_ra_get_mergeinfo(). */ 152 svn_error_t *(*get_mergeinfo)(svn_ra_session_t *session, 153 svn_mergeinfo_catalog_t *mergeinfo, 154 const apr_array_header_t *paths, 155 svn_revnum_t revision, 156 svn_mergeinfo_inheritance_t inherit, 157 svn_boolean_t include_merged_revisions, 158 apr_pool_t *pool); 159 /* See svn_ra_do_update3(). */ 160 svn_error_t *(*do_update)(svn_ra_session_t *session, 161 const svn_ra_reporter3_t **reporter, 162 void **report_baton, 163 svn_revnum_t revision_to_update_to, 164 const char *update_target, 165 svn_depth_t depth, 166 svn_boolean_t send_copyfrom_args, 167 svn_boolean_t ignore_ancestry, 168 const svn_delta_editor_t *update_editor, 169 void *update_baton, 170 apr_pool_t *result_pool, 171 apr_pool_t *scratch_pool); 172 /* See svn_ra_do_switch3(). */ 173 svn_error_t *(*do_switch)(svn_ra_session_t *session, 174 const svn_ra_reporter3_t **reporter, 175 void **report_baton, 176 svn_revnum_t revision_to_switch_to, 177 const char *switch_target, 178 svn_depth_t depth, 179 const char *switch_url, 180 svn_boolean_t send_copyfrom_args, 181 svn_boolean_t ignore_ancestry, 182 const svn_delta_editor_t *switch_editor, 183 void *switch_baton, 184 apr_pool_t *result_pool, 185 apr_pool_t *scratch_pool); 186 /* See svn_ra_do_status2(). */ 187 svn_error_t *(*do_status)(svn_ra_session_t *session, 188 const svn_ra_reporter3_t **reporter, 189 void **report_baton, 190 const char *status_target, 191 svn_revnum_t revision, 192 svn_depth_t depth, 193 const svn_delta_editor_t *status_editor, 194 void *status_baton, 195 apr_pool_t *pool); 196 /* See svn_ra_do_diff3(). */ 197 svn_error_t *(*do_diff)(svn_ra_session_t *session, 198 const svn_ra_reporter3_t **reporter, 199 void **report_baton, 200 svn_revnum_t revision, 201 const char *diff_target, 202 svn_depth_t depth, 203 svn_boolean_t ignore_ancestry, 204 svn_boolean_t text_deltas, 205 const char *versus_url, 206 const svn_delta_editor_t *diff_editor, 207 void *diff_baton, 208 apr_pool_t *pool); 209 /* See svn_ra_get_log2(). */ 210 svn_error_t *(*get_log)(svn_ra_session_t *session, 211 const apr_array_header_t *paths, 212 svn_revnum_t start, 213 svn_revnum_t end, 214 int limit, 215 svn_boolean_t discover_changed_paths, 216 svn_boolean_t strict_node_history, 217 svn_boolean_t include_merged_revisions, 218 const apr_array_header_t *revprops, 219 svn_log_entry_receiver_t receiver, 220 void *receiver_baton, 221 apr_pool_t *pool); 222 /* See svn_ra_check_path(). */ 223 svn_error_t *(*check_path)(svn_ra_session_t *session, 224 const char *path, 225 svn_revnum_t revision, 226 svn_node_kind_t *kind, 227 apr_pool_t *pool); 228 /* See svn_ra_stat(). */ 229 svn_error_t *(*stat)(svn_ra_session_t *session, 230 const char *path, 231 svn_revnum_t revision, 232 svn_dirent_t **dirent, 233 apr_pool_t *pool); 234 /* See svn_ra_get_uuid2(). */ 235 svn_error_t *(*get_uuid)(svn_ra_session_t *session, 236 const char **uuid, 237 apr_pool_t *pool); 238 /* See svn_ra_get_repos_root2(). */ 239 svn_error_t *(*get_repos_root)(svn_ra_session_t *session, 240 const char **url, 241 apr_pool_t *pool); 242 /* See svn_ra_get_locations(). */ 243 svn_error_t *(*get_locations)(svn_ra_session_t *session, 244 apr_hash_t **locations, 245 const char *path, 246 svn_revnum_t peg_revision, 247 const apr_array_header_t *location_revisions, 248 apr_pool_t *pool); 249 /* See svn_ra_get_location_segments(). */ 250 svn_error_t *(*get_location_segments)(svn_ra_session_t *session, 251 const char *path, 252 svn_revnum_t peg_revision, 253 svn_revnum_t start_rev, 254 svn_revnum_t end_rev, 255 svn_location_segment_receiver_t rcvr, 256 void *receiver_baton, 257 apr_pool_t *pool); 258 /* See svn_ra_get_file_revs2(). */ 259 svn_error_t *(*get_file_revs)(svn_ra_session_t *session, 260 const char *path, 261 svn_revnum_t start, 262 svn_revnum_t end, 263 svn_boolean_t include_merged_revisions, 264 svn_file_rev_handler_t handler, 265 void *handler_baton, 266 apr_pool_t *pool); 267 /* See svn_ra_lock(). */ 268 svn_error_t *(*lock)(svn_ra_session_t *session, 269 apr_hash_t *path_revs, 270 const char *comment, 271 svn_boolean_t force, 272 svn_ra_lock_callback_t lock_func, 273 void *lock_baton, 274 apr_pool_t *pool); 275 /* See svn_ra_unlock(). */ 276 svn_error_t *(*unlock)(svn_ra_session_t *session, 277 apr_hash_t *path_tokens, 278 svn_boolean_t force, 279 svn_ra_lock_callback_t lock_func, 280 void *lock_baton, 281 apr_pool_t *pool); 282 /* See svn_ra_get_lock(). */ 283 svn_error_t *(*get_lock)(svn_ra_session_t *session, 284 svn_lock_t **lock, 285 const char *path, 286 apr_pool_t *pool); 287 /* See svn_ra_get_locks2(). */ 288 svn_error_t *(*get_locks)(svn_ra_session_t *session, 289 apr_hash_t **locks, 290 const char *path, 291 svn_depth_t depth, 292 apr_pool_t *pool); 293 /* See svn_ra_replay(). */ 294 svn_error_t *(*replay)(svn_ra_session_t *session, 295 svn_revnum_t revision, 296 svn_revnum_t low_water_mark, 297 svn_boolean_t text_deltas, 298 const svn_delta_editor_t *editor, 299 void *edit_baton, 300 apr_pool_t *pool); 301 /* See svn_ra_has_capability(). */ 302 svn_error_t *(*has_capability)(svn_ra_session_t *session, 303 svn_boolean_t *has, 304 const char *capability, 305 apr_pool_t *pool); 306 /* See svn_ra_replay_range(). */ 307 svn_error_t * 308 (*replay_range)(svn_ra_session_t *session, 309 svn_revnum_t start_revision, 310 svn_revnum_t end_revision, 311 svn_revnum_t low_water_mark, 312 svn_boolean_t text_deltas, 313 svn_ra_replay_revstart_callback_t revstart_func, 314 svn_ra_replay_revfinish_callback_t revfinish_func, 315 void *replay_baton, 316 apr_pool_t *pool); 317 /* See svn_ra_get_deleted_rev(). */ 318 svn_error_t *(*get_deleted_rev)(svn_ra_session_t *session, 319 const char *path, 320 svn_revnum_t peg_revision, 321 svn_revnum_t end_revision, 322 svn_revnum_t *revision_deleted, 323 apr_pool_t *pool); 324 /* See svn_ra_get_inherited_props(). */ 325 svn_error_t *(*get_inherited_props)(svn_ra_session_t *session, 326 apr_array_header_t **iprops, 327 const char *path, 328 svn_revnum_t revision, 329 apr_pool_t *result_pool, 330 apr_pool_t *scratch_pool); 331 /* If not NULL, receives a pointer to svn_ra_open, to alllow opening 332 a new ra session from inside the ra layer without a circular 333 library dependency*/ 334 svn_error_t *(*set_svn_ra_open)(svn_ra_session_t *session, 335 svn_ra__open_func_t func); 336 337 /* See svn_ra_list(). */ 338 svn_error_t *(*list)(svn_ra_session_t *session, 339 const char *path, 340 svn_revnum_t revision, 341 const apr_array_header_t *patterns, 342 svn_depth_t depth, 343 apr_uint32_t dirent_fields, 344 svn_ra_dirent_receiver_t receiver, 345 void *receiver_baton, 346 apr_pool_t *scratch_pool); 347 348 /* Experimental support below here */ 349 350 /* See svn_ra__register_editor_shim_callbacks() */ 351 svn_error_t *(*register_editor_shim_callbacks)(svn_ra_session_t *session, 352 svn_delta_shim_callbacks_t *callbacks); 353 /* See svn_ra__get_commit_ev2() */ 354 svn_error_t *(*get_commit_ev2)( 355 svn_editor_t **editor, 356 svn_ra_session_t *session, 357 apr_hash_t *revprop_table, 358 svn_commit_callback2_t callback, 359 void *callback_baton, 360 apr_hash_t *lock_tokens, 361 svn_boolean_t keep_locks, 362 svn_ra__provide_base_cb_t provide_base_cb, 363 svn_ra__provide_props_cb_t provide_props_cb, 364 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb, 365 void *cb_baton, 366 svn_cancel_func_t cancel_func, 367 void *cancel_baton, 368 apr_pool_t *result_pool, 369 apr_pool_t *scratch_pool); 370 371 /* See svn_ra__replay_range_ev2() */ 372 svn_error_t *(*replay_range_ev2)( 373 svn_ra_session_t *session, 374 svn_revnum_t start_revision, 375 svn_revnum_t end_revision, 376 svn_revnum_t low_water_mark, 377 svn_boolean_t send_deltas, 378 svn_ra__replay_revstart_ev2_callback_t revstart_func, 379 svn_ra__replay_revfinish_ev2_callback_t revfinish_func, 380 void *replay_baton, 381 apr_pool_t *scratch_pool); 382 383} svn_ra__vtable_t; 384 385/* The RA session object. */ 386struct svn_ra_session_t { 387 const svn_ra__vtable_t *vtable; 388 389 /* Cancellation handlers consumers may want to use. */ 390 svn_cancel_func_t cancel_func; 391 void *cancel_baton; 392 393 /* Pool used to manage this session. */ 394 apr_pool_t *pool; 395 396 /* Private data for the RA implementation. */ 397 void *priv; 398}; 399 400/* Each libsvn_ra_foo defines a function named svn_ra_foo__init of this type. 401 * 402 * The LOADER_VERSION parameter must remain first in the list, and the 403 * function must use the C calling convention on all platforms, so that 404 * the init functions can safely read the version parameter. 405 * 406 * POOL will be available as long as this module is being used. 407 * 408 * ### need to force this to be __cdecl on Windows... how?? 409 */ 410typedef svn_error_t * 411(*svn_ra__init_func_t)(const svn_version_t *loader_version, 412 const svn_ra__vtable_t **vtable, 413 apr_pool_t *pool); 414 415/* Declarations of the init functions for the available RA libraries. */ 416svn_error_t *svn_ra_local__init(const svn_version_t *loader_version, 417 const svn_ra__vtable_t **vtable, 418 apr_pool_t *pool); 419svn_error_t *svn_ra_svn__init(const svn_version_t *loader_version, 420 const svn_ra__vtable_t **vtable, 421 apr_pool_t *pool); 422svn_error_t *svn_ra_serf__init(const svn_version_t *loader_version, 423 const svn_ra__vtable_t **vtable, 424 apr_pool_t *pool); 425 426 427 428/*** Compat Functions ***/ 429 430/** 431 * Set *LOCATIONS to the locations (at the repository revisions 432 * LOCATION_REVISIONS) of the file identified by PATH in PEG_REVISION. 433 * PATH is relative to the URL to which SESSION was opened. 434 * LOCATION_REVISIONS is an array of svn_revnum_t's. *LOCATIONS will 435 * be a mapping from the revisions to their appropriate absolute 436 * paths. If the file doesn't exist in a location_revision, that 437 * revision will be ignored. 438 * 439 * Use POOL for all allocations. 440 * 441 * NOTE: This function uses the RA get_log interfaces to do its work, 442 * as a fallback mechanism for servers which don't support the native 443 * get_locations API. 444 */ 445svn_error_t * 446svn_ra__locations_from_log(svn_ra_session_t *session, 447 apr_hash_t **locations_p, 448 const char *path, 449 svn_revnum_t peg_revision, 450 const apr_array_header_t *location_revisions, 451 apr_pool_t *pool); 452 453/** 454 * Call RECEIVER (with RECEIVER_BATON) for each segment in the 455 * location history of PATH in START_REV, working backwards in time 456 * from START_REV to END_REV. 457 * 458 * END_REV may be SVN_INVALID_REVNUM to indicate that you want to 459 * trace the history of the object to its origin. 460 * 461 * START_REV may be SVN_INVALID_REVNUM to indicate that you want to 462 * trace the history of the object beginning in the HEAD revision. 463 * Otherwise, START_REV must be younger than END_REV (unless END_REV 464 * is SVN_INVALID_REVNUM). 465 * 466 * Use POOL for all allocations. 467 * 468 * NOTE: This function uses the RA get_log interfaces to do its work, 469 * as a fallback mechanism for servers which don't support the native 470 * get_location_segments API. 471 */ 472svn_error_t * 473svn_ra__location_segments_from_log(svn_ra_session_t *session, 474 const char *path, 475 svn_revnum_t peg_revision, 476 svn_revnum_t start_rev, 477 svn_revnum_t end_rev, 478 svn_location_segment_receiver_t receiver, 479 void *receiver_baton, 480 apr_pool_t *pool); 481 482/** 483 * Retrieve a subset of the interesting revisions of a file PATH 484 * as seen in revision END (see svn_fs_history_prev() for a 485 * definition of "interesting revisions"). Invoke HANDLER with 486 * @a handler_baton as its first argument for each such revision. 487 * @a session is an open RA session. Use POOL for all allocations. 488 * 489 * If there is an interesting revision of the file that is less than or 490 * equal to START, the iteration will begin at that revision. 491 * Else, the iteration will begin at the first revision of the file in 492 * the repository, which has to be less than or equal to END. Note 493 * that if the function succeeds, HANDLER will have been called at 494 * least once. 495 * 496 * In a series of calls to HANDLER, the file contents for the first 497 * interesting revision will be provided as a text delta against the 498 * empty file. In the following calls, the delta will be against the 499 * fulltext contents for the previous call. 500 * 501 * NOTE: This function uses the RA get_log interfaces to do its work, 502 * as a fallback mechanism for servers which don't support the native 503 * get_location_segments API. 504 */ 505svn_error_t * 506svn_ra__file_revs_from_log(svn_ra_session_t *session, 507 const char *path, 508 svn_revnum_t start, 509 svn_revnum_t end, 510 svn_file_rev_handler_t handler, 511 void *handler_baton, 512 apr_pool_t *pool); 513 514 515/** 516 * Given a path REL_DELETED_PATH, relative to the URL of SESSION, which 517 * exists at PEG_REVISION, and an END_REVISION > PEG_REVISION at which 518 * REL_DELETED_PATH no longer exists, set *REVISION_DELETED to the revision 519 * REL_DELETED_PATH was first deleted or replaced, within the inclusive 520 * revision range defined by PEG_REVISION and END_REVISION. 521 * 522 * If REL_DELETED_PATH does not exist at PEG_REVISION or was not deleted prior 523 * to END_REVISION within the specified range, then set *REVISION_DELETED to 524 * SVN_INVALID_REVNUM. If PEG_REVISION or END_REVISION are invalid or if 525 * END_REVISION <= PEG_REVISION, then return SVN_ERR_CLIENT_BAD_REVISION. 526 * 527 * Use POOL for all allocations. 528 * 529 * NOTE: This function uses the RA get_log interfaces to do its work, 530 * as a fallback mechanism for servers which don't support the native 531 * get_deleted_rev API. 532 */ 533svn_error_t * 534svn_ra__get_deleted_rev_from_log(svn_ra_session_t *session, 535 const char *rel_deleted_path, 536 svn_revnum_t peg_revision, 537 svn_revnum_t end_revision, 538 svn_revnum_t *revision_deleted, 539 apr_pool_t *pool); 540 541 542/** 543 * Fallback logic for svn_ra_get_inherited_props() when that API 544 * need to find PATH's inherited properties on a legacy server that 545 * doesn't have the SVN_RA_CAPABILITY_INHERITED_PROPS capability. 546 * 547 * All arguments are as per svn_ra_get_inherited_props(). 548 */ 549svn_error_t * 550svn_ra__get_inherited_props_walk(svn_ra_session_t *session, 551 const char *path, 552 svn_revnum_t revision, 553 apr_array_header_t **inherited_props, 554 apr_pool_t *result_pool, 555 apr_pool_t *scratch_pool); 556 557/* Utility function to provide a shim between a returned Ev2 and an RA 558 provider's Ev1-based commit editor. 559 560 See svn_ra__get_commit_ev2() for parameter semantics. */ 561svn_error_t * 562svn_ra__use_commit_shim(svn_editor_t **editor, 563 svn_ra_session_t *session, 564 apr_hash_t *revprop_table, 565 svn_commit_callback2_t callback, 566 void *callback_baton, 567 apr_hash_t *lock_tokens, 568 svn_boolean_t keep_locks, 569 svn_ra__provide_base_cb_t provide_base_cb, 570 svn_ra__provide_props_cb_t provide_props_cb, 571 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb, 572 void *cb_baton, 573 svn_cancel_func_t cancel_func, 574 void *cancel_baton, 575 apr_pool_t *result_pool, 576 apr_pool_t *scratch_pool); 577 578/* Utility function to provide a shim between a returned Ev2 and an RA 579 provider's Ev1-based commit editor. 580 581 See svn_ra__replay_range_ev2() for parameter semantics. */ 582svn_error_t * 583svn_ra__use_replay_range_shim(svn_ra_session_t *session, 584 svn_revnum_t start_revision, 585 svn_revnum_t end_revision, 586 svn_revnum_t low_water_mark, 587 svn_boolean_t send_deltas, 588 svn_ra__replay_revstart_ev2_callback_t revstart_func, 589 svn_ra__replay_revfinish_ev2_callback_t revfinish_func, 590 void *replay_baton, 591 svn_ra__provide_base_cb_t provide_base_cb, 592 svn_ra__provide_props_cb_t provide_props_cb, 593 void *cb_baton, 594 apr_pool_t *scratch_pool); 595 596 597#ifdef __cplusplus 598} 599#endif 600 601#endif 602