00001 /** 00002 * @copyright 00003 * ==================================================================== 00004 * Licensed to the Apache Software Foundation (ASF) under one 00005 * or more contributor license agreements. See the NOTICE file 00006 * distributed with this work for additional information 00007 * regarding copyright ownership. The ASF licenses this file 00008 * to you under the Apache License, Version 2.0 (the 00009 * "License"); you may not use this file except in compliance 00010 * with the License. You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, 00015 * software distributed under the License is distributed on an 00016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00017 * KIND, either express or implied. See the License for the 00018 * specific language governing permissions and limitations 00019 * under the License. 00020 * ==================================================================== 00021 * @endcopyright 00022 * 00023 * @file svn_fs.h 00024 * @brief Interface to the Subversion filesystem. 00025 */ 00026 00027 #ifndef SVN_FS_H 00028 #define SVN_FS_H 00029 00030 #include <apr.h> 00031 #include <apr_pools.h> 00032 #include <apr_hash.h> 00033 #include <apr_tables.h> 00034 #include <apr_time.h> /* for apr_time_t */ 00035 00036 #include "svn_types.h" 00037 #include "svn_string.h" 00038 #include "svn_delta.h" 00039 #include "svn_io.h" 00040 #include "svn_mergeinfo.h" 00041 #include "svn_checksum.h" 00042 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif /* __cplusplus */ 00047 00048 00049 /** 00050 * Get libsvn_fs version information. 00051 * 00052 * @since New in 1.1. 00053 */ 00054 const svn_version_t * 00055 svn_fs_version(void); 00056 00057 /** 00058 * @defgroup fs_handling Filesystem interaction subsystem 00059 * @{ 00060 */ 00061 00062 /* Opening and creating filesystems. */ 00063 00064 00065 /** An object representing a Subversion filesystem. */ 00066 typedef struct svn_fs_t svn_fs_t; 00067 00068 /** 00069 * @defgroup svn_fs_backend_names Built-in back-ends 00070 * Constants defining the currently supported built-in filesystem backends. 00071 * 00072 * @see svn_fs_type 00073 * @{ 00074 */ 00075 /** @since New in 1.1. */ 00076 #define SVN_FS_TYPE_BDB "bdb" 00077 /** @since New in 1.1. */ 00078 #define SVN_FS_TYPE_FSFS "fsfs" 00079 00080 /** 00081 * EXPERIMENTAL filesystem backend. 00082 * 00083 * It is not ready for general production use. Please consult the 00084 * respective release notes on suggested usage scenarios. 00085 * 00086 * @since New in 1.9. 00087 */ 00088 #define SVN_FS_TYPE_FSX "fsx" 00089 00090 /** @} */ 00091 00092 00093 /** 00094 * @name Filesystem configuration options 00095 * @{ 00096 */ 00097 #define SVN_FS_CONFIG_BDB_TXN_NOSYNC "bdb-txn-nosync" 00098 #define SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE "bdb-log-autoremove" 00099 00100 /** Enable / disable text delta caching for a FSFS repository. 00101 * 00102 * @since New in 1.7. 00103 */ 00104 #define SVN_FS_CONFIG_FSFS_CACHE_DELTAS "fsfs-cache-deltas" 00105 00106 /** Enable / disable full-text caching for a FSFS repository. 00107 * 00108 * @since New in 1.7. 00109 */ 00110 #define SVN_FS_CONFIG_FSFS_CACHE_FULLTEXTS "fsfs-cache-fulltexts" 00111 00112 /** Enable / disable revprop caching for a FSFS repository. 00113 * 00114 * "2" is allowed, too and means "enable if efficient", 00115 * i.e. this will not create warning at runtime if there 00116 * is no efficient support for revprop caching. 00117 * 00118 * @since New in 1.8. 00119 */ 00120 #define SVN_FS_CONFIG_FSFS_CACHE_REVPROPS "fsfs-cache-revprops" 00121 00122 /** Select the cache namespace. If you potentially share the cache with 00123 * another FS object for the same repository, objects read through one FS 00124 * will not need to be read again for the other. In most cases, that is 00125 * a very desirable behavior and the default is, therefore, an empty 00126 * namespace. 00127 * 00128 * If you want to be sure that your FS instance will actually read all 00129 * requested data at least once, you need to specify a separate namespace 00130 * for it. All repository verification code, for instance, should use 00131 * some GUID here that is different each time you open an FS instance. 00132 * 00133 * @since New in 1.8. 00134 */ 00135 #define SVN_FS_CONFIG_FSFS_CACHE_NS "fsfs-cache-namespace" 00136 00137 /** Enable / disable caching of node properties for a FSFS repository. 00138 * 00139 * @since New in 1.10. 00140 */ 00141 #define SVN_FS_CONFIG_FSFS_CACHE_NODEPROPS "fsfs-cache-nodeprops" 00142 00143 /** Enable / disable the FSFS format 7 "block read" feature. 00144 * 00145 * @since New in 1.9. 00146 */ 00147 #define SVN_FS_CONFIG_FSFS_BLOCK_READ "fsfs-block-read" 00148 00149 /** String with a decimal representation of the FSFS format shard size. 00150 * Zero ("0") means that a repository with linear layout should be created. 00151 * 00152 * This option will only be used during the creation of new repositories 00153 * and is otherwise ignored. 00154 * 00155 * @since New in 1.9. 00156 */ 00157 #define SVN_FS_CONFIG_FSFS_SHARD_SIZE "fsfs-shard-size" 00158 00159 /** Enable / disable the FSFS format 7 logical addressing feature for a 00160 * newly created repository. 00161 * 00162 * This option will only be used during the creation of new repositories 00163 * and is otherwise ignored. 00164 * 00165 * @since New in 1.9. 00166 */ 00167 #define SVN_FS_CONFIG_FSFS_LOG_ADDRESSING "fsfs-log-addressing" 00168 00169 /* Note to maintainers: if you add further SVN_FS_CONFIG_FSFS_CACHE_* knobs, 00170 update fs_fs.c:verify_as_revision_before_current_plus_plus(). */ 00171 00172 /** Select the filesystem type. See also #svn_fs_type(). 00173 * 00174 * @since New in 1.1. */ 00175 #define SVN_FS_CONFIG_FS_TYPE "fs-type" 00176 00177 /** Create repository format compatible with Subversion versions 00178 * earlier than 1.4. 00179 * 00180 * @since New in 1.4. 00181 */ 00182 #define SVN_FS_CONFIG_PRE_1_4_COMPATIBLE "pre-1.4-compatible" 00183 00184 /** Create repository format compatible with Subversion versions 00185 * earlier than 1.5. 00186 * 00187 * @since New in 1.5. 00188 */ 00189 #define SVN_FS_CONFIG_PRE_1_5_COMPATIBLE "pre-1.5-compatible" 00190 00191 /** Create repository format compatible with Subversion versions 00192 * earlier than 1.6. 00193 * 00194 * @since New in 1.6. 00195 */ 00196 #define SVN_FS_CONFIG_PRE_1_6_COMPATIBLE "pre-1.6-compatible" 00197 00198 /** Create repository format compatible with Subversion versions 00199 * earlier than 1.8. 00200 * 00201 * @since New in 1.8. 00202 */ 00203 #define SVN_FS_CONFIG_PRE_1_8_COMPATIBLE "pre-1.8-compatible" 00204 00205 /** Create repository format compatible with the specified Subversion 00206 * release. The value must be a version in the same format as 00207 * #SVN_VER_NUMBER and cannot exceed the current version. 00208 * 00209 * @note The @c patch component would often be ignored, due to our forward 00210 * compatibility promises within minor release lines. It should therefore 00211 * usually be set to @c 0. 00212 * 00213 * @since New in 1.9. 00214 */ 00215 #define SVN_FS_CONFIG_COMPATIBLE_VERSION "compatible-version" 00216 00217 /** Specifies whether the filesystem should be forcing a physical write of 00218 * the data to disk. Enabling the option allows the filesystem to return 00219 * from the API calls without forcing the write to disk. If this option 00220 * is disabled, the changes are always written to disk. 00221 * 00222 * @note Avoiding the forced write to disk usually is more efficient, but 00223 * doesn't guarantee data integrity after a system crash or power failure 00224 * and should be used with caution. 00225 * 00226 * @since New in 1.10. 00227 */ 00228 #define SVN_FS_CONFIG_NO_FLUSH_TO_DISK "no-flush-to-disk" 00229 00230 /** @} */ 00231 00232 00233 /** 00234 * Callers should invoke this function to initialize global state in 00235 * the FS library before creating FS objects. If this function is 00236 * invoked, no FS objects may be created in another thread at the same 00237 * time as this invocation, and the provided @a pool must last longer 00238 * than any FS object created subsequently. 00239 * 00240 * If this function is not called, the FS library will make a best 00241 * effort to bootstrap a mutex for protecting data common to FS 00242 * objects; however, there is a small window of failure. Also, a 00243 * small amount of data will be leaked if the Subversion FS library is 00244 * dynamically unloaded, and using the bdb FS can potentially segfault 00245 * or invoke other undefined behavior if this function is not called 00246 * with an appropriate pool (such as the pool the module was loaded into) 00247 * when loaded dynamically. 00248 * 00249 * If this function is called multiple times before the pool passed to 00250 * the first call is destroyed or cleared, the later calls will have 00251 * no effect. 00252 * 00253 * @since New in 1.2. 00254 */ 00255 svn_error_t * 00256 svn_fs_initialize(apr_pool_t *pool); 00257 00258 00259 /** The type of a warning callback function. @a baton is the value specified 00260 * in the call to svn_fs_set_warning_func(); the filesystem passes it through 00261 * to the callback. @a err contains the warning message. 00262 * 00263 * The callback function should not clear the error that is passed to it; 00264 * its caller should do that. 00265 */ 00266 typedef void (*svn_fs_warning_callback_t)(void *baton, svn_error_t *err); 00267 00268 00269 /** Provide a callback function, @a warning, that @a fs should use to 00270 * report (non-fatal) errors. To print an error, the filesystem will call 00271 * @a warning, passing it @a warning_baton and the error. 00272 * 00273 * By default, this is set to a function that will crash the process. 00274 * Dumping to @c stderr or <tt>/dev/tty</tt> is not acceptable default 00275 * behavior for server processes, since those may both be equivalent to 00276 * <tt>/dev/null</tt>. 00277 */ 00278 void 00279 svn_fs_set_warning_func(svn_fs_t *fs, 00280 svn_fs_warning_callback_t warning, 00281 void *warning_baton); 00282 00283 00284 00285 /** 00286 * Create a new, empty Subversion filesystem, stored in the directory 00287 * @a path, and return a pointer to it in @a *fs_p. @a path must not 00288 * currently exist, but its parent must exist. If @a fs_config is not 00289 * @c NULL, the options it contains modify the behavior of the 00290 * filesystem. The interpretation of @a fs_config is specific to the 00291 * filesystem back-end. The new filesystem may be closed by 00292 * destroying @a result_pool. 00293 * 00294 * Use @a scratch_pool for temporary allocations. 00295 * 00296 * @note The lifetime of @a fs_config must not be shorter than @a 00297 * result_pool's. It's a good idea to allocate @a fs_config from 00298 * @a result_pool or one of its ancestors. 00299 * 00300 * If @a fs_config contains a value for #SVN_FS_CONFIG_FS_TYPE, that 00301 * value determines the filesystem type for the new filesystem. 00302 * Currently defined values are: 00303 * 00304 * SVN_FS_TYPE_BDB Berkeley-DB implementation 00305 * SVN_FS_TYPE_FSFS Native-filesystem implementation 00306 * SVN_FS_TYPE_FSX Experimental filesystem implementation 00307 * 00308 * If @a fs_config is @c NULL or does not contain a value for 00309 * #SVN_FS_CONFIG_FS_TYPE then the default filesystem type will be used. 00310 * This will typically be BDB for version 1.1 and FSFS for later versions, 00311 * though the caller should not rely upon any particular default if they 00312 * wish to ensure that a filesystem of a specific type is created. 00313 * 00314 * @since New in 1.10. 00315 */ 00316 svn_error_t * 00317 svn_fs_create2(svn_fs_t **fs_p, 00318 const char *path, 00319 apr_hash_t *fs_config, 00320 apr_pool_t *result_pool, 00321 apr_pool_t *scratch_pool); 00322 00323 /** 00324 * Like svn_fs_create2(), but without @a scratch_pool. 00325 * 00326 * @deprecated Provided for backward compatibility with the 1.9 API. 00327 * @since New in 1.1. 00328 */ 00329 SVN_DEPRECATED 00330 svn_error_t * 00331 svn_fs_create(svn_fs_t **fs_p, 00332 const char *path, 00333 apr_hash_t *fs_config, 00334 apr_pool_t *pool); 00335 00336 /** 00337 * Open a Subversion filesystem located in the directory @a path, and 00338 * return a pointer to it in @a *fs_p. If @a fs_config is not @c 00339 * NULL, the options it contains modify the behavior of the 00340 * filesystem. The interpretation of @a fs_config is specific to the 00341 * filesystem back-end. The opened filesystem will be allocated in 00342 * @a result_pool may be closed by clearing or destroying that pool. 00343 * Use @a scratch_pool for temporary allocations. 00344 * 00345 * @note The lifetime of @a fs_config must not be shorter than @a 00346 * result_pool's. It's a good idea to allocate @a fs_config from 00347 * @a result_pool or one of its ancestors. 00348 * 00349 * Only one thread may operate on any given filesystem object at once. 00350 * Two threads may access the same filesystem simultaneously only if 00351 * they open separate filesystem objects. 00352 * 00353 * @note You probably don't want to use this directly. Take a look at 00354 * svn_repos_open3() instead. 00355 * 00356 * @since New in 1.9. 00357 */ 00358 svn_error_t * 00359 svn_fs_open2(svn_fs_t **fs_p, 00360 const char *path, 00361 apr_hash_t *fs_config, 00362 apr_pool_t *result_pool, 00363 apr_pool_t *scratch_pool); 00364 00365 /** 00366 * Like svn_fs_open2(), but without @a scratch_pool. 00367 * 00368 * @deprecated Provided for backward compatibility with the 1.8 API. 00369 * @since New in 1.1. 00370 */ 00371 SVN_DEPRECATED 00372 svn_error_t * 00373 svn_fs_open(svn_fs_t **fs_p, 00374 const char *path, 00375 apr_hash_t *fs_config, 00376 apr_pool_t *pool); 00377 00378 /** The kind of action being taken by 'upgrade'. 00379 * 00380 * @since New in 1.9. 00381 */ 00382 typedef enum svn_fs_upgrade_notify_action_t 00383 { 00384 /** Packing of the revprop shard has completed. 00385 * The number parameter is the shard being processed. */ 00386 svn_fs_upgrade_pack_revprops = 0, 00387 00388 /** Removal of the non-packed revprop shard is completed. 00389 * The number parameter is the shard being processed */ 00390 svn_fs_upgrade_cleanup_revprops, 00391 00392 /** DB format has been set to the new value. 00393 * The number parameter is the new format number. */ 00394 svn_fs_upgrade_format_bumped 00395 } svn_fs_upgrade_notify_action_t; 00396 00397 /** The type of an upgrade notification function. @a number is specifc 00398 * to @a action (see #svn_fs_upgrade_notify_action_t); @a action is the 00399 * type of action being performed. @a baton is the corresponding baton 00400 * for the notification function, and @a scratch_pool can be used for 00401 * temporary allocations, but will be cleared between invocations. 00402 * 00403 * @since New in 1.9. 00404 */ 00405 typedef svn_error_t *(*svn_fs_upgrade_notify_t)(void *baton, 00406 apr_uint64_t number, 00407 svn_fs_upgrade_notify_action_t action, 00408 apr_pool_t *scratch_pool); 00409 00410 /** 00411 * Upgrade the Subversion filesystem located in the directory @a path 00412 * to the latest version supported by this library. Return 00413 * #SVN_ERR_FS_UNSUPPORTED_UPGRADE and make no changes to the 00414 * filesystem if the requested upgrade is not supported. Use 00415 * @a scratch_pool for temporary allocations. 00416 * 00417 * The optional @a notify_func callback is only a general feedback that 00418 * the operation is still in process but may be called in e.g. random shard 00419 * order and more than once for the same shard. 00420 * 00421 * The optional @a cancel_func callback will be invoked as usual to allow 00422 * the user to preempt this potentially lengthy operation. 00423 * 00424 * @note You probably don't want to use this directly. Take a look at 00425 * svn_repos_upgrade2() instead. 00426 * 00427 * @note Canceling an upgrade is legal but may leave remnants of previous 00428 * format data that may not be cleaned up automatically by later calls. 00429 * 00430 * @since New in 1.9. 00431 */ 00432 svn_error_t * 00433 svn_fs_upgrade2(const char *path, 00434 svn_fs_upgrade_notify_t notify_func, 00435 void *notify_baton, 00436 svn_cancel_func_t cancel_func, 00437 void *cancel_baton, 00438 apr_pool_t *scratch_pool); 00439 00440 /** 00441 * Like svn_fs_upgrade2 but with notify_func, notify_baton, cancel_func 00442 * and cancel_baton being set to NULL. 00443 * 00444 * @deprecated Provided for backward compatibility with the 1.8 API. 00445 * @since New in 1.5. 00446 */ 00447 SVN_DEPRECATED 00448 svn_error_t * 00449 svn_fs_upgrade(const char *path, 00450 apr_pool_t *pool); 00451 00452 /** 00453 * Callback function type for progress notification. 00454 * 00455 * @a revision is the number of the revision currently being processed, 00456 * #SVN_INVALID_REVNUM if the current stage is not linked to any specific 00457 * revision. @a baton is the callback baton. 00458 * 00459 * @since New in 1.8. 00460 */ 00461 typedef void (*svn_fs_progress_notify_func_t)(svn_revnum_t revision, 00462 void *baton, 00463 apr_pool_t *pool); 00464 00465 /** 00466 * Return, in @a *fs_type, a string identifying the back-end type of 00467 * the Subversion filesystem located in @a path. Allocate @a *fs_type 00468 * in @a pool. 00469 * 00470 * The string should be equal to one of the @c SVN_FS_TYPE_* defined 00471 * constants, unless the filesystem is a new back-end type added in 00472 * a later version of Subversion. 00473 * 00474 * In general, the type should make no difference in the filesystem's 00475 * semantics, but there are a few situations (such as backups) where 00476 * it might matter. 00477 * 00478 * @since New in 1.3. 00479 */ 00480 svn_error_t * 00481 svn_fs_type(const char **fs_type, 00482 const char *path, 00483 apr_pool_t *pool); 00484 00485 /** 00486 * Return the path to @a fs's repository, allocated in @a pool. 00487 * @note This is just what was passed to svn_fs_create() or 00488 * svn_fs_open() -- might be absolute, might not. 00489 * 00490 * @since New in 1.1. 00491 */ 00492 const char * 00493 svn_fs_path(svn_fs_t *fs, 00494 apr_pool_t *pool); 00495 00496 /** 00497 * Return a shallow copy of the configuration parameters used to open 00498 * @a fs, allocated in @a pool. It may be @c NULL. The contents of the 00499 * hash contents remains valid only for @a fs's lifetime. 00500 * 00501 * @note This is just what was passed to svn_fs_create() or svn_fs_open(). 00502 * You may not modify it. 00503 * 00504 * @since New in 1.8. 00505 */ 00506 apr_hash_t * 00507 svn_fs_config(svn_fs_t *fs, 00508 apr_pool_t *pool); 00509 00510 /** 00511 * Delete the filesystem at @a path. 00512 * 00513 * @note: Deleting a filesystem that has an open svn_fs_t is not 00514 * supported. Clear/destroy all pools used to create/open @a path. 00515 * See issue 4264. 00516 * 00517 * @since New in 1.1. 00518 */ 00519 svn_error_t * 00520 svn_fs_delete_fs(const char *path, 00521 apr_pool_t *pool); 00522 00523 /** The type of a hotcopy notification function. @a start_revision and 00524 * @a end_revision indicate the copied revision range. @a baton is the 00525 * corresponding baton for the notification function, and @a scratch_pool 00526 * can be used for temporary allocations, but will be cleared between 00527 * invocations. 00528 */ 00529 typedef void (*svn_fs_hotcopy_notify_t)(void *baton, 00530 svn_revnum_t start_revision, 00531 svn_revnum_t end_revision, 00532 apr_pool_t *scratch_pool); 00533 00534 /** 00535 * Copy a possibly live Subversion filesystem from @a src_path to 00536 * @a dest_path. If @a clean is @c TRUE, perform cleanup on the 00537 * source filesystem as part of the copy operation; currently, this 00538 * means deleting copied, unused logfiles for a Berkeley DB source 00539 * filesystem. 00540 * 00541 * If @a incremental is TRUE, make an effort to avoid re-copying 00542 * information already present in the destination where possible. If 00543 * incremental hotcopy is not implemented, raise 00544 * #SVN_ERR_UNSUPPORTED_FEATURE. 00545 * 00546 * For each revision range copied, @a notify_func will be called with 00547 * staring and ending revision numbers (both inclusive and not necessarily 00548 * different) and with the @a notify_baton. Currently, this notification 00549 * is not triggered by the BDB backend. @a notify_func may be @c NULL 00550 * if this notification is not required. 00551 * 00552 * The optional @a cancel_func callback will be invoked with 00553 * @a cancel_baton as usual to allow the user to preempt this potentially 00554 * lengthy operation. 00555 * 00556 * Use @a scratch_pool for temporary allocations. 00557 * 00558 * @since New in 1.9. 00559 */ 00560 svn_error_t * 00561 svn_fs_hotcopy3(const char *src_path, 00562 const char *dest_path, 00563 svn_boolean_t clean, 00564 svn_boolean_t incremental, 00565 svn_fs_hotcopy_notify_t notify_func, 00566 void *notify_baton, 00567 svn_cancel_func_t cancel_func, 00568 void *cancel_baton, 00569 apr_pool_t *scratch_pool); 00570 00571 /** 00572 * Like svn_fs_hotcopy3(), but with @a notify_func and @a notify_baton 00573 * always passed as @c NULL. 00574 * 00575 * @deprecated Provided for backward compatibility with the 1.8 API. 00576 * @since New in 1.8. 00577 */ 00578 SVN_DEPRECATED 00579 svn_error_t * 00580 svn_fs_hotcopy2(const char *src_path, 00581 const char *dest_path, 00582 svn_boolean_t clean, 00583 svn_boolean_t incremental, 00584 svn_cancel_func_t cancel_func, 00585 void *cancel_baton, 00586 apr_pool_t *scratch_pool); 00587 00588 /** 00589 * Like svn_fs_hotcopy2(), but with @a incremental always passed as @c 00590 * TRUE and without cancellation support. 00591 * 00592 * @deprecated Provided for backward compatibility with the 1.7 API. 00593 * @since New in 1.1. 00594 */ 00595 SVN_DEPRECATED 00596 svn_error_t * 00597 svn_fs_hotcopy(const char *src_path, 00598 const char *dest_path, 00599 svn_boolean_t clean, 00600 apr_pool_t *pool); 00601 00602 /** Perform any necessary non-catastrophic recovery on the Subversion 00603 * filesystem located at @a path. 00604 * 00605 * If @a cancel_func is not @c NULL, it is called periodically with 00606 * @a cancel_baton as argument to see if the client wishes to cancel 00607 * recovery. BDB filesystems do not currently support cancellation. 00608 * 00609 * Do any necessary allocation within @a pool. 00610 * 00611 * For FSFS filesystems, recovery is currently limited to recreating 00612 * the db/current file, and does not require exclusive access. 00613 * 00614 * For BDB filesystems, recovery requires exclusive access, and is 00615 * described in detail below. 00616 * 00617 * After an unexpected server exit, due to a server crash or a system 00618 * crash, a Subversion filesystem based on Berkeley DB needs to run 00619 * recovery procedures to bring the database back into a consistent 00620 * state and release any locks that were held by the deceased process. 00621 * The recovery procedures require exclusive access to the database 00622 * --- while they execute, no other process or thread may access the 00623 * database. 00624 * 00625 * In a server with multiple worker processes, like Apache, if a 00626 * worker process accessing the filesystem dies, you must stop the 00627 * other worker processes, and run recovery. Then, the other worker 00628 * processes can re-open the database and resume work. 00629 * 00630 * If the server exited cleanly, there is no need to run recovery, but 00631 * there is no harm in it, either, and it take very little time. So 00632 * it's a fine idea to run recovery when the server process starts, 00633 * before it begins handling any requests. 00634 * 00635 * @since New in 1.5. 00636 */ 00637 svn_error_t * 00638 svn_fs_recover(const char *path, 00639 svn_cancel_func_t cancel_func, 00640 void *cancel_baton, 00641 apr_pool_t *pool); 00642 00643 00644 /** 00645 * Callback for svn_fs_freeze(). 00646 * 00647 * @since New in 1.8. 00648 */ 00649 typedef svn_error_t *(*svn_fs_freeze_func_t)(void *baton, apr_pool_t *pool); 00650 00651 /** 00652 * Take an exclusive lock on @a fs to prevent commits and then invoke 00653 * @a freeze_func passing @a freeze_baton. 00654 * 00655 * @note @a freeze_func must not, directly or indirectly, call any function 00656 * that attempts to take out a lock on the underlying repository. These 00657 * include functions for packing, hotcopying, setting revprops and commits. 00658 * Attempts to do so may result in a deadlock. 00659 * 00660 * @note The BDB backend doesn't implement this feature so most 00661 * callers should not call this function directly but should use the 00662 * higher level svn_repos_freeze() instead. 00663 * 00664 * @see svn_repos_freeze() 00665 * 00666 * @since New in 1.8. 00667 */ 00668 svn_error_t * 00669 svn_fs_freeze(svn_fs_t *fs, 00670 svn_fs_freeze_func_t freeze_func, 00671 void *freeze_baton, 00672 apr_pool_t *pool); 00673 00674 00675 /** Subversion filesystems based on Berkeley DB. 00676 * 00677 * The following functions are specific to Berkeley DB filesystems. 00678 * 00679 * @defgroup svn_fs_bdb Berkeley DB filesystems 00680 * @{ 00681 */ 00682 00683 /** Register an error handling function for Berkeley DB error messages. 00684 * 00685 * @deprecated Provided for backward compatibility with the 1.2 API. 00686 * 00687 * Despite being first declared deprecated in Subversion 1.3, this API 00688 * is redundant in versions 1.1 and 1.2 as well. 00689 * 00690 * Berkeley DB's error codes are seldom sufficiently informative to allow 00691 * adequate troubleshooting. Berkeley DB provides extra messages through 00692 * a callback function - if an error occurs, the @a handler will be called 00693 * with two strings: an error message prefix, which will be zero, and 00694 * an error message. @a handler might print it out, log it somewhere, 00695 * etc. 00696 * 00697 * Subversion 1.1 and later install their own handler internally, and 00698 * wrap the messages from Berkeley DB into the standard svn_error_t object, 00699 * making any information gained through this interface redundant. 00700 * 00701 * It is only worth using this function if your program will be used 00702 * with Subversion 1.0. 00703 * 00704 * This function connects to the Berkeley DB @c DBENV->set_errcall interface. 00705 * Since that interface supports only a single callback, Subversion's internal 00706 * callback is registered with Berkeley DB, and will forward notifications to 00707 * a user provided callback after performing its own processing. 00708 */ 00709 SVN_DEPRECATED 00710 svn_error_t * 00711 svn_fs_set_berkeley_errcall(svn_fs_t *fs, 00712 void (*handler)(const char *errpfx, 00713 char *msg)); 00714 00715 /** Set @a *logfiles to an array of <tt>const char *</tt> log file names 00716 * of Berkeley DB-based Subversion filesystem. 00717 * 00718 * If @a only_unused is @c TRUE, set @a *logfiles to an array which 00719 * contains only the names of Berkeley DB log files no longer in use 00720 * by the filesystem. Otherwise, all log files (used and unused) are 00721 * returned. 00722 00723 * This function wraps the Berkeley DB 'log_archive' function 00724 * called by the db_archive binary. Repository administrators may 00725 * want to run this function periodically and delete the unused log 00726 * files, as a way of reclaiming disk space. 00727 */ 00728 svn_error_t * 00729 svn_fs_berkeley_logfiles(apr_array_header_t **logfiles, 00730 const char *path, 00731 svn_boolean_t only_unused, 00732 apr_pool_t *pool); 00733 00734 00735 /** 00736 * The following functions are similar to their generic counterparts. 00737 * 00738 * In Subversion 1.2 and earlier, they only work on Berkeley DB filesystems. 00739 * In Subversion 1.3 and later, they perform largely as aliases for their 00740 * generic counterparts (with the exception of recover, which only gained 00741 * a generic counterpart in 1.5). 00742 * 00743 * @defgroup svn_fs_bdb_deprecated Berkeley DB filesystem compatibility 00744 * @{ 00745 */ 00746 00747 /** @deprecated Provided for backward compatibility with the 1.0 API. */ 00748 SVN_DEPRECATED 00749 svn_fs_t * 00750 svn_fs_new(apr_hash_t *fs_config, 00751 apr_pool_t *pool); 00752 00753 /** @deprecated Provided for backward compatibility with the 1.0 API. */ 00754 SVN_DEPRECATED 00755 svn_error_t * 00756 svn_fs_create_berkeley(svn_fs_t *fs, 00757 const char *path); 00758 00759 /** @deprecated Provided for backward compatibility with the 1.0 API. */ 00760 SVN_DEPRECATED 00761 svn_error_t * 00762 svn_fs_open_berkeley(svn_fs_t *fs, 00763 const char *path); 00764 00765 /** @deprecated Provided for backward compatibility with the 1.0 API. */ 00766 SVN_DEPRECATED 00767 const char * 00768 svn_fs_berkeley_path(svn_fs_t *fs, 00769 apr_pool_t *pool); 00770 00771 /** @deprecated Provided for backward compatibility with the 1.0 API. */ 00772 SVN_DEPRECATED 00773 svn_error_t * 00774 svn_fs_delete_berkeley(const char *path, 00775 apr_pool_t *pool); 00776 00777 /** @deprecated Provided for backward compatibility with the 1.0 API. */ 00778 SVN_DEPRECATED 00779 svn_error_t * 00780 svn_fs_hotcopy_berkeley(const char *src_path, 00781 const char *dest_path, 00782 svn_boolean_t clean_logs, 00783 apr_pool_t *pool); 00784 00785 /** @deprecated Provided for backward compatibility with the 1.4 API. */ 00786 SVN_DEPRECATED 00787 svn_error_t * 00788 svn_fs_berkeley_recover(const char *path, 00789 apr_pool_t *pool); 00790 /** @} */ 00791 00792 /** @} */ 00793 00794 00795 /** Filesystem Access Contexts. 00796 * 00797 * @since New in 1.2. 00798 * 00799 * At certain times, filesystem functions need access to temporary 00800 * user data. For example, which user is changing a file? If the 00801 * file is locked, has an appropriate lock-token been supplied? 00802 * 00803 * This temporary user data is stored in an "access context" object, 00804 * and the access context is then connected to the filesystem object. 00805 * Whenever a filesystem function requires information, it can pull 00806 * things out of the context as needed. 00807 * 00808 * @defgroup svn_fs_access_ctx Filesystem access contexts 00809 * @{ 00810 */ 00811 00812 /** An opaque object representing temporary user data. */ 00813 typedef struct svn_fs_access_t svn_fs_access_t; 00814 00815 00816 /** Set @a *access_ctx to a new #svn_fs_access_t object representing 00817 * @a username, allocated in @a pool. @a username is presumed to 00818 * have been authenticated by the caller. 00819 * 00820 * Make a deep copy of @a username. 00821 */ 00822 svn_error_t * 00823 svn_fs_create_access(svn_fs_access_t **access_ctx, 00824 const char *username, 00825 apr_pool_t *pool); 00826 00827 00828 /** Associate @a access_ctx with an open @a fs. 00829 * 00830 * This function can be run multiple times on the same open 00831 * filesystem, in order to change the filesystem access context for 00832 * different filesystem operations. Pass a NULL value for @a 00833 * access_ctx to disassociate the current access context from the 00834 * filesystem. 00835 */ 00836 svn_error_t * 00837 svn_fs_set_access(svn_fs_t *fs, 00838 svn_fs_access_t *access_ctx); 00839 00840 00841 /** Set @a *access_ctx to the current @a fs access context, or NULL if 00842 * there is no current fs access context. 00843 */ 00844 svn_error_t * 00845 svn_fs_get_access(svn_fs_access_t **access_ctx, 00846 svn_fs_t *fs); 00847 00848 00849 /** Accessors for the access context: */ 00850 00851 /** Set @a *username to the name represented by @a access_ctx. */ 00852 svn_error_t * 00853 svn_fs_access_get_username(const char **username, 00854 svn_fs_access_t *access_ctx); 00855 00856 00857 /** Push a lock-token @a token associated with path @a path into the 00858 * context @a access_ctx. The context remembers all tokens it 00859 * receives, and makes them available to fs functions. The token and 00860 * path are not duplicated into @a access_ctx's pool; make sure the 00861 * token's lifetime is at least as long as @a access_ctx. 00862 * 00863 * @since New in 1.6. */ 00864 svn_error_t * 00865 svn_fs_access_add_lock_token2(svn_fs_access_t *access_ctx, 00866 const char *path, 00867 const char *token); 00868 00869 /** 00870 * Same as svn_fs_access_add_lock_token2(), but with @a path set to value 1. 00871 * 00872 * @deprecated Provided for backward compatibility with the 1.5 API. 00873 */ 00874 SVN_DEPRECATED 00875 svn_error_t * 00876 svn_fs_access_add_lock_token(svn_fs_access_t *access_ctx, 00877 const char *token); 00878 00879 /** @} */ 00880 00881 00882 /** Filesystem Nodes and Node-Revisions. 00883 * 00884 * In a Subversion filesystem, a `node' corresponds roughly to an 00885 * `inode' in a Unix filesystem: 00886 * - A node is either a file or a directory. 00887 * - A node's contents change over time. 00888 * - When you change a node's contents, it's still the same node; it's 00889 * just been changed. So a node's identity isn't bound to a specific 00890 * set of contents. 00891 * - If you rename a node, it's still the same node, just under a 00892 * different name. So a node's identity isn't bound to a particular 00893 * filename. 00894 * 00895 * A `node revision' refers to one particular version of a node's contents, 00896 * that existed over a specific period of time (one or more repository 00897 * revisions). Changing a node's contents always creates a new revision of 00898 * that node, which is to say creates a new `node revision'. Once created, 00899 * a node revision's contents never change. 00900 * 00901 * When we create a node, its initial contents are the initial revision of 00902 * the node. As users make changes to the node over time, we create new 00903 * revisions of that same node. When a user commits a change that deletes 00904 * a file from the filesystem, we don't delete the node, or any revision 00905 * of it --- those stick around to allow us to recreate prior revisions of 00906 * the filesystem. Instead, we just remove the reference to the node 00907 * from the directory. 00908 * 00909 * Each node revision is a part of exactly one node, and appears only once 00910 * in the history of that node. It is uniquely identified by a node 00911 * revision id, #svn_fs_id_t. Its node revision id also identifies which 00912 * node it is a part of. 00913 * 00914 * @note: Often when we talk about `the node' within the context of a single 00915 * revision (or transaction), we implicitly mean `the node as it appears in 00916 * this revision (or transaction)', or in other words `the node revision'. 00917 * 00918 * @note: Commonly, a node revision will have the same content as some other 00919 * node revisions in the same node and in different nodes. The FS libraries 00920 * allow different node revisions to share the same data without storing a 00921 * separate copy of the data. 00922 * 00923 * @defgroup svn_fs_nodes Filesystem nodes 00924 * @{ 00925 */ 00926 00927 /** Defines the possible ways two arbitrary (root, path)-pairs may be 00928 * related. 00929 * 00930 * @since New in 1.9. 00931 */ 00932 typedef enum svn_fs_node_relation_t 00933 { 00934 /** The (root, path)-pairs are not related, i.e. none of the other cases 00935 * apply. If the roots refer to different @c svn_fs_t instances, then 00936 * they are always considered unrelated - even if the underlying 00937 * repository is the same. 00938 */ 00939 svn_fs_node_unrelated = 0, 00940 00941 /** No changes have been made between the (root, path)-pairs, i.e. they 00942 * have the same (relative) nodes in their sub-trees, corresponding sub- 00943 * tree nodes have the same contents as well as properties and report the 00944 * same "created-path" and "created-rev" data. This implies having a 00945 * common ancestor. 00946 * 00947 * However, due to efficiency considerations, the FS implementation may 00948 * report some combinations as merely having a common ancestor 00949 * (@a svn_fs_node_common_ancestor) instead of actually being unchanged. 00950 */ 00951 svn_fs_node_unchanged, 00952 00953 /** The (root, path)-pairs have a common ancestor (which may be one of 00954 * them) but there are changes between them, i.e. they don't fall into 00955 * the @c svn_fs_node_unchanged category. 00956 * 00957 * Due to efficiency considerations, the FS implementation may falsely 00958 * classify some combinations as merely having a common ancestor that 00959 * are, in fact, unchanged (@a svn_fs_node_unchanged). 00960 */ 00961 svn_fs_node_common_ancestor 00962 00963 } svn_fs_node_relation_t; 00964 00965 /** An object representing a node-revision id. */ 00966 typedef struct svn_fs_id_t svn_fs_id_t; 00967 00968 00969 /** Return -1, 0, or 1 if node revisions @a a and @a b are respectively 00970 * unrelated, equivalent, or otherwise related (part of the same node). 00971 * 00972 * @note Consider using the more expressive #svn_fs_node_relation() instead. 00973 * 00974 * @see #svn_fs_node_relation 00975 */ 00976 int 00977 svn_fs_compare_ids(const svn_fs_id_t *a, 00978 const svn_fs_id_t *b); 00979 00980 00981 00982 /** Return TRUE if node revisions @a id1 and @a id2 are related (part of the 00983 * same node), else return FALSE. 00984 * 00985 * @note Consider using the more expressive #svn_fs_node_relation() instead. 00986 * 00987 * @see #svn_fs_node_relation 00988 */ 00989 svn_boolean_t 00990 svn_fs_check_related(const svn_fs_id_t *id1, 00991 const svn_fs_id_t *id2); 00992 00993 00994 /** 00995 * @note This function is not guaranteed to work with all filesystem 00996 * types. There is currently no un-deprecated equivalent; contact the 00997 * Subversion developers if you have a need for it. 00998 * 00999 * @deprecated Provided for backward compatibility with the 1.0 API. 01000 */ 01001 SVN_DEPRECATED 01002 svn_fs_id_t * 01003 svn_fs_parse_id(const char *data, 01004 apr_size_t len, 01005 apr_pool_t *pool); 01006 01007 01008 /** Return a Subversion string containing the unparsed form of the 01009 * node revision id @a id. Allocate the string containing the 01010 * unparsed form in @a pool. 01011 */ 01012 svn_string_t * 01013 svn_fs_unparse_id(const svn_fs_id_t *id, 01014 apr_pool_t *pool); 01015 01016 /** @} */ 01017 01018 01019 /** Filesystem Transactions. 01020 * 01021 * To make a change to a Subversion filesystem: 01022 * - Create a transaction object, using svn_fs_begin_txn(). 01023 * - Call svn_fs_txn_root(), to get the transaction's root directory. 01024 * - Make whatever changes you like in that tree. 01025 * - Commit the transaction, using svn_fs_commit_txn(). 01026 * 01027 * The filesystem implementation guarantees that your commit will 01028 * either: 01029 * - succeed completely, so that all of the changes are committed to 01030 * create a new revision of the filesystem, or 01031 * - fail completely, leaving the filesystem unchanged. 01032 * 01033 * Until you commit the transaction, any changes you make are 01034 * invisible. Only when your commit succeeds do they become visible 01035 * to the outside world, as a new revision of the filesystem. 01036 * 01037 * If you begin a transaction, and then decide you don't want to make 01038 * the change after all (say, because your net connection with the 01039 * client disappeared before the change was complete), you can call 01040 * svn_fs_abort_txn(), to cancel the entire transaction; this 01041 * leaves the filesystem unchanged. 01042 * 01043 * The only way to change the contents of files or directories, or 01044 * their properties, is by making a transaction and creating a new 01045 * revision, as described above. Once a revision has been committed, it 01046 * never changes again; the filesystem interface provides no means to 01047 * go back and edit the contents of an old revision. Once history has 01048 * been recorded, it is set in stone. Clients depend on this property 01049 * to do updates and commits reliably; proxies depend on this property 01050 * to cache changes accurately; and so on. 01051 * 01052 * There are two kinds of nodes in the filesystem: mutable, and 01053 * immutable. Revisions in the filesystem consist entirely of 01054 * immutable nodes, whose contents never change. A transaction in 01055 * progress, which the user is still constructing, uses mutable nodes 01056 * for those nodes which have been changed so far, and refers to 01057 * immutable nodes from existing revisions for portions of the tree 01058 * which haven't been changed yet in that transaction. 01059 * 01060 * Immutable nodes, as part of revisions, never refer to mutable 01061 * nodes, which are part of uncommitted transactions. Mutable nodes 01062 * may refer to immutable nodes, or other mutable nodes. 01063 * 01064 * Note that the terms "immutable" and "mutable" describe whether or 01065 * not the nodes have been changed as part of a transaction --- not 01066 * the permissions on the nodes they refer to. Even if you aren't 01067 * authorized to modify the filesystem's root directory, you might be 01068 * authorized to change some descendant of the root; doing so would 01069 * create a new mutable copy of the root directory. Mutability refers 01070 * to the role of the node: part of an existing revision, or part of a 01071 * new one. This is independent of your authorization to make changes 01072 * to a given node. 01073 * 01074 * Transactions are actually persistent objects, stored in the 01075 * database. You can open a filesystem, begin a transaction, and 01076 * close the filesystem, and then a separate process could open the 01077 * filesystem, pick up the same transaction, and continue work on it. 01078 * When a transaction is successfully committed, it is removed from 01079 * the database. 01080 * 01081 * Every transaction is assigned a name. You can open a transaction 01082 * by name, and resume work on it, or find out the name of a 01083 * transaction you already have open. You can also list all the 01084 * transactions currently present in the database. 01085 * 01086 * You may assign properties to transactions; these are name/value 01087 * pairs. When you commit a transaction, all of its properties become 01088 * unversioned revision properties of the new revision. (There is one 01089 * exception: the svn:date property will be automatically set on new 01090 * transactions to the date that the transaction was created, and can 01091 * be overwritten when the transaction is committed by the current 01092 * time; see svn_fs_commit_txn.) 01093 * 01094 * Transaction names are guaranteed to contain only letters (upper- 01095 * and lower-case), digits, `-', and `.', from the ASCII character 01096 * set. 01097 * 01098 * The Subversion filesystem will make a best effort to not reuse 01099 * transaction names. The BDB and FSFS backends generate transaction 01100 * names using a sequence, or a counter, which is stored in the 01101 * database. Each new transaction increments the counter. The 01102 * current value of the counter is not serialized into a filesystem 01103 * dump file, so dumping and restoring the repository will reset the 01104 * sequence and so may reuse transaction names. 01105 * 01106 * @defgroup svn_fs_txns Filesystem transactions 01107 * @{ 01108 */ 01109 01110 /** The type of a Subversion transaction object. */ 01111 typedef struct svn_fs_txn_t svn_fs_txn_t; 01112 01113 01114 /** @defgroup svn_fs_begin_txn2_flags Bitmask flags for svn_fs_begin_txn2() 01115 * @since New in 1.2. 01116 * @{ */ 01117 01118 /** Do on-the-fly out-of-dateness checks. That is, an fs routine may 01119 * throw error if a caller tries to edit an out-of-date item in the 01120 * transaction. 01121 * 01122 * @warning ### Not yet implemented. 01123 */ 01124 #define SVN_FS_TXN_CHECK_OOD 0x00001 01125 01126 /** Do on-the-fly lock checks. That is, an fs routine may throw error 01127 * if a caller tries to edit a locked item without having rights to the lock. 01128 */ 01129 #define SVN_FS_TXN_CHECK_LOCKS 0x00002 01130 01131 /** Allow the client to specify the final svn:date of the revision by 01132 * setting or deleting the corresponding transaction property rather 01133 * than have it set automatically when the transaction is committed. 01134 * 01135 * @since New in 1.9. 01136 */ 01137 #define SVN_FS_TXN_CLIENT_DATE 0x00004 01138 01139 /** @} */ 01140 01141 /** 01142 * Begin a new transaction on the filesystem @a fs, based on existing 01143 * revision @a rev. Set @a *txn_p to a pointer to the new transaction. 01144 * When committed, this transaction will create a new revision. 01145 * 01146 * Allocate the new transaction in @a pool; when @a pool is freed, the new 01147 * transaction will be closed (neither committed nor aborted). 01148 * 01149 * @a flags determines transaction enforcement behaviors, and is composed 01150 * from the constants SVN_FS_TXN_* (#SVN_FS_TXN_CHECK_OOD etc.). 01151 * 01152 * @note If you're building a txn for committing, you probably 01153 * don't want to call this directly. Instead, call 01154 * svn_repos_fs_begin_txn_for_commit(), which honors the 01155 * repository's hook configurations. 01156 * 01157 * @since New in 1.2. 01158 */ 01159 svn_error_t * 01160 svn_fs_begin_txn2(svn_fs_txn_t **txn_p, 01161 svn_fs_t *fs, 01162 svn_revnum_t rev, 01163 apr_uint32_t flags, 01164 apr_pool_t *pool); 01165 01166 01167 /** 01168 * Same as svn_fs_begin_txn2(), but with @a flags set to 0. 01169 * 01170 * @deprecated Provided for backward compatibility with the 1.1 API. 01171 */ 01172 SVN_DEPRECATED 01173 svn_error_t * 01174 svn_fs_begin_txn(svn_fs_txn_t **txn_p, 01175 svn_fs_t *fs, 01176 svn_revnum_t rev, 01177 apr_pool_t *pool); 01178 01179 01180 01181 /** Commit @a txn. 01182 * 01183 * @note You usually don't want to call this directly. 01184 * Instead, call svn_repos_fs_commit_txn(), which honors the 01185 * repository's hook configurations. 01186 * 01187 * If the transaction conflicts with other changes committed to the 01188 * repository, return an #SVN_ERR_FS_CONFLICT error. Otherwise, create 01189 * a new filesystem revision containing the changes made in @a txn, 01190 * storing that new revision number in @a *new_rev, and return zero. 01191 * 01192 * If #SVN_FS_TXN_CLIENT_DATE was passed to #svn_fs_begin_txn2 any 01193 * svn:date on the transaction will be become the unversioned property 01194 * svn:date on the revision. svn:date can have any value, it does not 01195 * have to be a timestamp. If the transaction has no svn:date the 01196 * revision will have no svn:date. 01197 * 01198 * If #SVN_FS_TXN_CLIENT_DATE was not passed to #svn_fs_begin_txn2 the 01199 * new revision will have svn:date set to the current time at some 01200 * point during the commit and any svn:date on the transaction will be 01201 * lost. 01202 * 01203 * If @a conflict_p is non-zero, use it to provide details on any 01204 * conflicts encountered merging @a txn with the most recent committed 01205 * revisions. If a conflict occurs, set @a *conflict_p to the path of 01206 * the conflict in @a txn, allocated within @a pool; 01207 * otherwise, set @a *conflict_p to NULL. 01208 * 01209 * If the commit succeeds, @a txn is invalid. 01210 * 01211 * If the commit fails for any reason, @a *new_rev is an invalid 01212 * revision number, an error other than #SVN_NO_ERROR is returned and 01213 * @a txn is still valid; you can make more operations to resolve the 01214 * conflict, or call svn_fs_abort_txn() to abort the transaction. 01215 * 01216 * @note Success or failure of the commit of @a txn is determined by 01217 * examining the value of @a *new_rev upon this function's return. If 01218 * the value is a valid revision number, the commit was successful, 01219 * even though a non-@c NULL function return value may indicate that 01220 * something else went wrong in post commit FS processing. 01221 * 01222 * @note See api-errata/1.8/fs001.txt for information on how this 01223 * function was documented in versions prior to 1.8. 01224 * 01225 * ### need to document this better. there are four combinations of 01226 * ### return values: 01227 * ### 1) err=NULL. conflict=NULL. new_rev is valid 01228 * ### 2) err=SVN_ERR_FS_CONFLICT. conflict is set. new_rev=SVN_INVALID_REVNUM 01229 * ### 3) err=!NULL. conflict=NULL. new_rev is valid 01230 * ### 4) err=!NULL. conflict=NULL. new_rev=SVN_INVALID_REVNUM 01231 * ### 01232 * ### some invariants: 01233 * ### *conflict_p will be non-NULL IFF SVN_ERR_FS_CONFLICT 01234 * ### if *conflict_p is set (and SVN_ERR_FS_CONFLICT), then new_rev 01235 * ### will always be SVN_INVALID_REVNUM 01236 * ### *conflict_p will always be initialized to NULL, or to a valid 01237 * ### conflict string 01238 * ### *new_rev will always be initialized to SVN_INVALID_REVNUM, or 01239 * ### to a valid, committed revision number 01240 * 01241 */ 01242 svn_error_t * 01243 svn_fs_commit_txn(const char **conflict_p, 01244 svn_revnum_t *new_rev, 01245 svn_fs_txn_t *txn, 01246 apr_pool_t *pool); 01247 01248 01249 /** Abort the transaction @a txn. Any changes made in @a txn are 01250 * discarded, and the filesystem is left unchanged. Use @a pool for 01251 * any necessary allocations. 01252 * 01253 * @note This function first sets the state of @a txn to "dead", and 01254 * then attempts to purge it and any related data from the filesystem. 01255 * If some part of the cleanup process fails, @a txn and some portion 01256 * of its data may remain in the database after this function returns. 01257 * Use svn_fs_purge_txn() to retry the transaction cleanup. 01258 */ 01259 svn_error_t * 01260 svn_fs_abort_txn(svn_fs_txn_t *txn, 01261 apr_pool_t *pool); 01262 01263 01264 /** Cleanup the dead transaction in @a fs whose ID is @a txn_id. Use 01265 * @a pool for all allocations. If the transaction is not yet dead, 01266 * the error #SVN_ERR_FS_TRANSACTION_NOT_DEAD is returned. (The 01267 * caller probably forgot to abort the transaction, or the cleanup 01268 * step of that abort failed for some reason.) 01269 */ 01270 svn_error_t * 01271 svn_fs_purge_txn(svn_fs_t *fs, 01272 const char *txn_id, 01273 apr_pool_t *pool); 01274 01275 01276 /** Set @a *name_p to the name of the transaction @a txn, as a 01277 * NULL-terminated string. Allocate the name in @a pool. 01278 */ 01279 svn_error_t * 01280 svn_fs_txn_name(const char **name_p, 01281 svn_fs_txn_t *txn, 01282 apr_pool_t *pool); 01283 01284 /** Return @a txn's base revision. */ 01285 svn_revnum_t 01286 svn_fs_txn_base_revision(svn_fs_txn_t *txn); 01287 01288 01289 01290 /** Open the transaction named @a name in the filesystem @a fs. Set @a *txn 01291 * to the transaction. 01292 * 01293 * If there is no such transaction, #SVN_ERR_FS_NO_SUCH_TRANSACTION is 01294 * the error returned. 01295 * 01296 * Allocate the new transaction in @a pool; when @a pool is freed, the new 01297 * transaction will be closed (neither committed nor aborted). 01298 */ 01299 svn_error_t * 01300 svn_fs_open_txn(svn_fs_txn_t **txn, 01301 svn_fs_t *fs, 01302 const char *name, 01303 apr_pool_t *pool); 01304 01305 01306 /** Set @a *names_p to an array of <tt>const char *</tt> ids which are the 01307 * names of all the currently active transactions in the filesystem @a fs. 01308 * Allocate the array in @a pool. 01309 */ 01310 svn_error_t * 01311 svn_fs_list_transactions(apr_array_header_t **names_p, 01312 svn_fs_t *fs, 01313 apr_pool_t *pool); 01314 01315 /* Transaction properties */ 01316 01317 /** Set @a *value_p to the value of the property named @a propname on 01318 * transaction @a txn. If @a txn has no property by that name, set 01319 * @a *value_p to zero. Allocate the result in @a pool. 01320 */ 01321 svn_error_t * 01322 svn_fs_txn_prop(svn_string_t **value_p, 01323 svn_fs_txn_t *txn, 01324 const char *propname, 01325 apr_pool_t *pool); 01326 01327 01328 /** Set @a *table_p to the entire property list of transaction @a txn, as 01329 * an APR hash table allocated in @a pool. The resulting table maps property 01330 * names to pointers to #svn_string_t objects containing the property value. 01331 */ 01332 svn_error_t * 01333 svn_fs_txn_proplist(apr_hash_t **table_p, 01334 svn_fs_txn_t *txn, 01335 apr_pool_t *pool); 01336 01337 01338 /** Change a transactions @a txn's property's value, or add/delete a 01339 * property. @a name is the name of the property to change, and @a value 01340 * is the new value of the property, or zero if the property should be 01341 * removed altogether. Do any necessary temporary allocation in @a pool. 01342 */ 01343 svn_error_t * 01344 svn_fs_change_txn_prop(svn_fs_txn_t *txn, 01345 const char *name, 01346 const svn_string_t *value, 01347 apr_pool_t *pool); 01348 01349 01350 /** Change, add, and/or delete transaction property values in 01351 * transaction @a txn. @a props is an array of <tt>svn_prop_t</tt> 01352 * elements. This is equivalent to calling svn_fs_change_txn_prop() 01353 * multiple times with the @c name and @c value fields of each 01354 * successive <tt>svn_prop_t</tt>, but may be more efficient. 01355 * (Properties not mentioned are left alone.) Do any necessary 01356 * temporary allocation in @a pool. 01357 * 01358 * @since New in 1.5. 01359 */ 01360 svn_error_t * 01361 svn_fs_change_txn_props(svn_fs_txn_t *txn, 01362 const apr_array_header_t *props, 01363 apr_pool_t *pool); 01364 01365 /** @} */ 01366 01367 01368 /** Roots. 01369 * 01370 * An #svn_fs_root_t object represents the root directory of some 01371 * revision or transaction in a filesystem. To refer to particular 01372 * node or node revision, you provide a root, and a directory path 01373 * relative to that root. 01374 * 01375 * @defgroup svn_fs_roots Filesystem roots 01376 * @{ 01377 */ 01378 01379 /** The Filesystem Root object. */ 01380 typedef struct svn_fs_root_t svn_fs_root_t; 01381 01382 01383 /** Set @a *root_p to the root directory of revision @a rev in filesystem @a fs. 01384 * Allocate @a *root_p in a private subpool of @a pool; the root can be 01385 * destroyed earlier than @a pool by calling #svn_fs_close_root. 01386 */ 01387 svn_error_t * 01388 svn_fs_revision_root(svn_fs_root_t **root_p, 01389 svn_fs_t *fs, 01390 svn_revnum_t rev, 01391 apr_pool_t *pool); 01392 01393 01394 /** Set @a *root_p to the root directory of @a txn. Allocate @a *root_p in a 01395 * private subpool of @a pool; the root can be destroyed earlier than @a pool by 01396 * calling #svn_fs_close_root. 01397 */ 01398 svn_error_t * 01399 svn_fs_txn_root(svn_fs_root_t **root_p, 01400 svn_fs_txn_t *txn, 01401 apr_pool_t *pool); 01402 01403 01404 /** Free the root directory @a root; this only needs to be used if you want to 01405 * free the memory associated with @a root earlier than the time you destroy 01406 * the pool passed to the function that created it (svn_fs_revision_root() or 01407 * svn_fs_txn_root()). 01408 */ 01409 void 01410 svn_fs_close_root(svn_fs_root_t *root); 01411 01412 01413 /** Return the filesystem to which @a root belongs. */ 01414 svn_fs_t * 01415 svn_fs_root_fs(svn_fs_root_t *root); 01416 01417 01418 /** Return @c TRUE iff @a root is a transaction root. */ 01419 svn_boolean_t 01420 svn_fs_is_txn_root(svn_fs_root_t *root); 01421 01422 /** Return @c TRUE iff @a root is a revision root. */ 01423 svn_boolean_t 01424 svn_fs_is_revision_root(svn_fs_root_t *root); 01425 01426 01427 /** If @a root is the root of a transaction, return the name of the 01428 * transaction, allocated in @a pool; otherwise, return NULL. 01429 */ 01430 const char * 01431 svn_fs_txn_root_name(svn_fs_root_t *root, 01432 apr_pool_t *pool); 01433 01434 /** If @a root is the root of a transaction, return the number of the 01435 * revision on which is was based when created. Otherwise, return 01436 * #SVN_INVALID_REVNUM. 01437 * 01438 * @since New in 1.5. 01439 */ 01440 svn_revnum_t 01441 svn_fs_txn_root_base_revision(svn_fs_root_t *root); 01442 01443 /** If @a root is the root of a revision, return the revision number. 01444 * Otherwise, return #SVN_INVALID_REVNUM. 01445 */ 01446 svn_revnum_t 01447 svn_fs_revision_root_revision(svn_fs_root_t *root); 01448 01449 /** @} */ 01450 01451 01452 /** Directory entry names and directory paths. 01453 * 01454 * Here are the rules for directory entry names, and directory paths: 01455 * 01456 * A directory entry name is a Unicode string encoded in UTF-8, and 01457 * may not contain the NULL character (U+0000). The name should be in 01458 * Unicode canonical decomposition and ordering. No directory entry 01459 * may be named '.', '..', or the empty string. Given a directory 01460 * entry name which fails to meet these requirements, a filesystem 01461 * function returns an #SVN_ERR_FS_PATH_SYNTAX error. 01462 * 01463 * A directory path is a sequence of zero or more directory entry 01464 * names, separated by slash characters (U+002f), and possibly ending 01465 * with slash characters. Sequences of two or more consecutive slash 01466 * characters are treated as if they were a single slash. If a path 01467 * ends with a slash, it refers to the same node it would without the 01468 * slash, but that node must be a directory, or else the function 01469 * may return an #SVN_ERR_FS_NOT_DIRECTORY error. 01470 * 01471 * A path consisting of the empty string, or a string containing only 01472 * slashes, refers to the root directory. 01473 * 01474 * @defgroup svn_fs_directories Filesystem directories 01475 * @{ 01476 */ 01477 01478 01479 01480 /** The kind of change that occurred on the path. */ 01481 typedef enum svn_fs_path_change_kind_t 01482 { 01483 /** path modified in txn */ 01484 svn_fs_path_change_modify = 0, 01485 01486 /** path added in txn */ 01487 svn_fs_path_change_add, 01488 01489 /** path removed in txn */ 01490 svn_fs_path_change_delete, 01491 01492 /** path removed and re-added in txn */ 01493 svn_fs_path_change_replace, 01494 01495 /** ignore all previous change items for path (internal-use only) */ 01496 svn_fs_path_change_reset 01497 } svn_fs_path_change_kind_t; 01498 01499 /** Change descriptor. 01500 * 01501 * @note Fields may be added to the end of this structure in future 01502 * versions. Therefore, to preserve binary compatibility, users 01503 * should not directly allocate structures of this type. 01504 * 01505 * @note The @c text_mod, @c prop_mod and @c mergeinfo_mod flags mean the 01506 * text, properties and mergeinfo property (respectively) were "touched" 01507 * by the commit API; this does not mean the new value is different from 01508 * the old value. 01509 * 01510 * @since New in 1.10. */ 01511 typedef struct svn_fs_path_change3_t 01512 { 01513 /** path of the node that got changed. */ 01514 svn_string_t path; 01515 01516 /** kind of change */ 01517 svn_fs_path_change_kind_t change_kind; 01518 01519 /** what node kind is the path? 01520 (Note: it is legal for this to be #svn_node_unknown.) */ 01521 svn_node_kind_t node_kind; 01522 01523 /** was the text touched? 01524 * For node_kind=dir: always false. For node_kind=file: 01525 * modify: true iff text touched. 01526 * add (copy): true iff text touched. 01527 * add (plain): always true. 01528 * delete: always false. 01529 * replace: as for the add/copy part of the replacement. 01530 */ 01531 svn_boolean_t text_mod; 01532 01533 /** were the properties touched? 01534 * modify: true iff props touched. 01535 * add (copy): true iff props touched. 01536 * add (plain): true iff props touched. 01537 * delete: always false. 01538 * replace: as for the add/copy part of the replacement. 01539 */ 01540 svn_boolean_t prop_mod; 01541 01542 /** was the mergeinfo property touched? 01543 * modify: } true iff svn:mergeinfo property add/del/mod 01544 * add (copy): } and fs format supports this flag. 01545 * add (plain): } 01546 * delete: always false. 01547 * replace: as for the add/copy part of the replacement. 01548 * (Note: Pre-1.9 repositories will report #svn_tristate_unknown.) 01549 */ 01550 svn_tristate_t mergeinfo_mod; 01551 01552 /** Copyfrom revision and path; this is only valid if copyfrom_known 01553 * is true. */ 01554 svn_boolean_t copyfrom_known; 01555 svn_revnum_t copyfrom_rev; 01556 const char *copyfrom_path; 01557 01558 /* NOTE! Please update svn_fs_path_change3_create() when adding new 01559 fields here. */ 01560 } svn_fs_path_change3_t; 01561 01562 01563 /** Similar to #svn_fs_path_change3_t, but with @a node_rev_id and without 01564 * path information. 01565 * 01566 * @note Fields may be added to the end of this structure in future 01567 * versions. Therefore, to preserve binary compatibility, users 01568 * should not directly allocate structures of this type. 01569 * 01570 * @note The @c text_mod, @c prop_mod and @c mergeinfo_mod flags mean the 01571 * text, properties and mergeinfo property (respectively) were "touched" 01572 * by the commit API; this does not mean the new value is different from 01573 * the old value. 01574 * 01575 * @since New in 1.6. 01576 * 01577 * @deprecated Provided for backwards compatibility with the 1.9 API. 01578 */ 01579 typedef struct svn_fs_path_change2_t 01580 { 01581 /** node revision id of changed path */ 01582 const svn_fs_id_t *node_rev_id; 01583 01584 /** kind of change */ 01585 svn_fs_path_change_kind_t change_kind; 01586 01587 /** was the text touched? 01588 * For node_kind=dir: always false. For node_kind=file: 01589 * modify: true iff text touched. 01590 * add (copy): true iff text touched. 01591 * add (plain): always true. 01592 * delete: always false. 01593 * replace: as for the add/copy part of the replacement. 01594 */ 01595 svn_boolean_t text_mod; 01596 01597 /** were the properties touched? 01598 * modify: true iff props touched. 01599 * add (copy): true iff props touched. 01600 * add (plain): true iff props touched. 01601 * delete: always false. 01602 * replace: as for the add/copy part of the replacement. 01603 */ 01604 svn_boolean_t prop_mod; 01605 01606 /** what node kind is the path? 01607 (Note: it is legal for this to be #svn_node_unknown.) */ 01608 svn_node_kind_t node_kind; 01609 01610 /** Copyfrom revision and path; this is only valid if copyfrom_known 01611 * is true. */ 01612 svn_boolean_t copyfrom_known; 01613 svn_revnum_t copyfrom_rev; 01614 const char *copyfrom_path; 01615 01616 /** was the mergeinfo property touched? 01617 * modify: } true iff svn:mergeinfo property add/del/mod 01618 * add (copy): } and fs format supports this flag. 01619 * add (plain): } 01620 * delete: always false. 01621 * replace: as for the add/copy part of the replacement. 01622 * (Note: Pre-1.9 repositories will report #svn_tristate_unknown.) 01623 * @since New in 1.9. */ 01624 svn_tristate_t mergeinfo_mod; 01625 /* NOTE! Please update svn_fs_path_change2_create() when adding new 01626 fields here. */ 01627 } svn_fs_path_change2_t; 01628 01629 01630 /** Similar to #svn_fs_path_change2_t, but without kind and copyfrom 01631 * information. 01632 * 01633 * @deprecated Provided for backwards compatibility with the 1.5 API. 01634 */ 01635 01636 typedef struct svn_fs_path_change_t 01637 { 01638 /** node revision id of changed path */ 01639 const svn_fs_id_t *node_rev_id; 01640 01641 /** kind of change */ 01642 svn_fs_path_change_kind_t change_kind; 01643 01644 /** were there text mods? */ 01645 svn_boolean_t text_mod; 01646 01647 /** were there property mods? */ 01648 svn_boolean_t prop_mod; 01649 01650 } svn_fs_path_change_t; 01651 01652 /** 01653 * Allocate an #svn_fs_path_change2_t structure in @a pool, initialize and 01654 * return it. 01655 * 01656 * Set the @c node_rev_id field of the created struct to @a node_rev_id, and 01657 * @c change_kind to @a change_kind. Set all other fields to their 01658 * @c _unknown, @c NULL or invalid value, respectively. 01659 * 01660 * @since New in 1.6. 01661 */ 01662 svn_fs_path_change2_t * 01663 svn_fs_path_change2_create(const svn_fs_id_t *node_rev_id, 01664 svn_fs_path_change_kind_t change_kind, 01665 apr_pool_t *pool); 01666 01667 /** 01668 * Allocate an #svn_fs_path_change3_t structure in @a result_pool, 01669 * initialize and return it. 01670 * 01671 * Set the @c change_kind field to @a change_kind. Set all other fields 01672 * to their @c _unknown, @c NULL or invalid value, respectively. 01673 * 01674 * @since New in 1.10. 01675 */ 01676 svn_fs_path_change3_t * 01677 svn_fs_path_change3_create(svn_fs_path_change_kind_t change_kind, 01678 apr_pool_t *result_pool); 01679 01680 /** 01681 * Return a deep copy of @a *change, allocated in @a result_pool. 01682 * 01683 * @since New in 1.10. 01684 */ 01685 svn_fs_path_change3_t * 01686 svn_fs_path_change3_dup(svn_fs_path_change3_t *change, 01687 apr_pool_t *result_pool); 01688 01689 /** 01690 * Opaque iterator object type for a changed paths list. 01691 * 01692 * @since New in 1.10. 01693 */ 01694 typedef struct svn_fs_path_change_iterator_t svn_fs_path_change_iterator_t; 01695 01696 /** 01697 * Set @a *change to the path change that @a iterator currently points to 01698 * and advance the @a iterator. If the change list has been exhausted, 01699 * @a change will be set to @c NULL. 01700 * 01701 * You may modify @a **change but its content becomes invalid as soon as 01702 * either @a iterator becomes invalid or you call this function again. 01703 * 01704 * @note The @c node_kind field in @a change may be #svn_node_unknown and 01705 * the @c copyfrom_known fields may be FALSE. 01706 * 01707 * @since New in 1.10. 01708 */ 01709 svn_error_t * 01710 svn_fs_path_change_get(svn_fs_path_change3_t **change, 01711 svn_fs_path_change_iterator_t *iterator); 01712 01713 01714 /** Determine what has changed under a @a root. 01715 * 01716 * Set @a *iterator to an iterator object, allocated in @a result_pool, 01717 * which will give access to the full list of changed paths under @a root. 01718 * Each call to @a svn_fs_path_change_get will return a new unique path 01719 * change and has amortized O(1) runtime. The iteration order is undefined 01720 * and may change even for the same @a root. 01721 * 01722 * If @a root becomes invalid, @a *iterator becomes invalid, too. 01723 * 01724 * Use @a scratch_pool for temporary allocations. 01725 * 01726 * @note The @a *iterator may be a large object and bind limited system 01727 * resources such as file handles. Be sure to clear the owning 01728 * pool once you don't need that iterator anymore. 01729 * 01730 * @since New in 1.10. 01731 */ 01732 svn_error_t * 01733 svn_fs_paths_changed3(svn_fs_path_change_iterator_t **iterator, 01734 svn_fs_root_t *root, 01735 apr_pool_t *result_pool, 01736 apr_pool_t *scratch_pool); 01737 01738 /** Same as svn_fs_paths_changed3() but returning all changes in a single, 01739 * large data structure and using a single pool for all allocations. 01740 * 01741 * Allocate and return a hash @a *changed_paths2_p containing descriptions 01742 * of the paths changed under @a root. The hash is keyed with 01743 * <tt>const char *</tt> paths, and has #svn_fs_path_change2_t * values. 01744 * 01745 * Use @a pool for all allocations, including the hash and its values. 01746 * 01747 * @note Retrieving the #node_rev_id element of #svn_fs_path_change2_t may 01748 * be expensive in some FS backends. 01749 * 01750 * @since New in 1.6. 01751 * 01752 * @deprecated Provided for backward compatibility with the 1.9 API. 01753 */ 01754 SVN_DEPRECATED 01755 svn_error_t * 01756 svn_fs_paths_changed2(apr_hash_t **changed_paths2_p, 01757 svn_fs_root_t *root, 01758 apr_pool_t *pool); 01759 01760 01761 /** Same as svn_fs_paths_changed2(), only with #svn_fs_path_change_t * values 01762 * in the hash (and thus no kind or copyfrom data). 01763 * 01764 * @deprecated Provided for backward compatibility with the 1.5 API. 01765 */ 01766 SVN_DEPRECATED 01767 svn_error_t * 01768 svn_fs_paths_changed(apr_hash_t **changed_paths_p, 01769 svn_fs_root_t *root, 01770 apr_pool_t *pool); 01771 01772 /** @} */ 01773 01774 01775 /* Operations appropriate to all kinds of nodes. */ 01776 01777 /** Set @a *kind_p to the type of node present at @a path under @a 01778 * root. If @a path does not exist under @a root, set @a *kind_p to 01779 * #svn_node_none. Use @a pool for temporary allocation. 01780 */ 01781 svn_error_t * 01782 svn_fs_check_path(svn_node_kind_t *kind_p, 01783 svn_fs_root_t *root, 01784 const char *path, 01785 apr_pool_t *pool); 01786 01787 01788 /** An opaque node history object. */ 01789 typedef struct svn_fs_history_t svn_fs_history_t; 01790 01791 01792 /** Set @a *history_p to an opaque node history object which 01793 * represents @a path under @a root. @a root must be a revision root. 01794 * Allocate the result in @a result_pool and use @a scratch_pool for 01795 * temporary allocations. 01796 * 01797 * @since New in 1.9. 01798 */ 01799 svn_error_t * 01800 svn_fs_node_history2(svn_fs_history_t **history_p, 01801 svn_fs_root_t *root, 01802 const char *path, 01803 apr_pool_t *result_pool, 01804 apr_pool_t *scratch_pool); 01805 01806 /** Same as svn_fs_node_history2() but using a single @a pool for all 01807 * allocations. 01808 * 01809 * @deprecated Provided for backward compatibility with the 1.8 API. 01810 */ 01811 SVN_DEPRECATED 01812 svn_error_t * 01813 svn_fs_node_history(svn_fs_history_t **history_p, 01814 svn_fs_root_t *root, 01815 const char *path, 01816 apr_pool_t *pool); 01817 01818 01819 /** Set @a *prev_history_p to an opaque node history object which 01820 * represents the previous (or "next oldest") interesting history 01821 * location for the filesystem node represented by @a history, or @c 01822 * NULL if no such previous history exists. If @a cross_copies is @c 01823 * FALSE, also return @c NULL if stepping backwards in history to @a 01824 * *prev_history_p would cross a filesystem copy operation. 01825 * 01826 * @note If this is the first call to svn_fs_history_prev() for the @a 01827 * history object, it could return a history object whose location is 01828 * the same as the original. This will happen if the original 01829 * location was an interesting one (where the node was modified, or 01830 * took place in a copy event). This behavior allows looping callers 01831 * to avoid the calling svn_fs_history_location() on the object 01832 * returned by svn_fs_node_history(), and instead go ahead and begin 01833 * calling svn_fs_history_prev(). 01834 * 01835 * @note This function uses node-id ancestry alone to determine 01836 * modifiedness, and therefore does NOT claim that in any of the 01837 * returned revisions file contents changed, properties changed, 01838 * directory entries lists changed, etc. 01839 * 01840 * @note The revisions returned for @a path will be older than or 01841 * the same age as the revision of that path in @a root. That is, if 01842 * @a root is a revision root based on revision X, and @a path was 01843 * modified in some revision(s) younger than X, those revisions 01844 * younger than X will not be included for @a path. 01845 * 01846 * Allocate the result in @a result_pool and use @a scratch_pool for 01847 * temporary allocations. 01848 * 01849 * @since New in 1.9. */ 01850 svn_error_t * 01851 svn_fs_history_prev2(svn_fs_history_t **prev_history_p, 01852 svn_fs_history_t *history, 01853 svn_boolean_t cross_copies, 01854 apr_pool_t *result_pool, 01855 apr_pool_t *scratch_pool); 01856 01857 /** Same as svn_fs_history_prev2() but using a single @a pool for all 01858 * allocations. 01859 * 01860 * @deprecated Provided for backward compatibility with the 1.8 API. 01861 */ 01862 SVN_DEPRECATED 01863 svn_error_t * 01864 svn_fs_history_prev(svn_fs_history_t **prev_history_p, 01865 svn_fs_history_t *history, 01866 svn_boolean_t cross_copies, 01867 apr_pool_t *pool); 01868 01869 01870 /** Set @a *path and @a *revision to the path and revision, 01871 * respectively, of the @a history object. Use @a pool for all 01872 * allocations. 01873 */ 01874 svn_error_t * 01875 svn_fs_history_location(const char **path, 01876 svn_revnum_t *revision, 01877 svn_fs_history_t *history, 01878 apr_pool_t *pool); 01879 01880 01881 /** Set @a *is_dir to @c TRUE iff @a path in @a root is a directory. 01882 * Do any necessary temporary allocation in @a pool. 01883 */ 01884 svn_error_t * 01885 svn_fs_is_dir(svn_boolean_t *is_dir, 01886 svn_fs_root_t *root, 01887 const char *path, 01888 apr_pool_t *pool); 01889 01890 01891 /** Set @a *is_file to @c TRUE iff @a path in @a root is a file. 01892 * Do any necessary temporary allocation in @a pool. 01893 */ 01894 svn_error_t * 01895 svn_fs_is_file(svn_boolean_t *is_file, 01896 svn_fs_root_t *root, 01897 const char *path, 01898 apr_pool_t *pool); 01899 01900 01901 /** Get the id of a node. 01902 * 01903 * Set @a *id_p to the node revision ID of @a path in @a root, allocated in 01904 * @a pool. 01905 * 01906 * If @a root is the root of a transaction, keep in mind that other 01907 * changes to the transaction can change which node @a path refers to, 01908 * and even whether the path exists at all. 01909 */ 01910 svn_error_t * 01911 svn_fs_node_id(const svn_fs_id_t **id_p, 01912 svn_fs_root_t *root, 01913 const char *path, 01914 apr_pool_t *pool); 01915 01916 /** Determine how @a path_a under @a root_a and @a path_b under @a root_b 01917 * are related and return the result in @a relation. There is no restriction 01918 * concerning the roots: They may refer to different repositories, be in 01919 * arbitrary revision order and any of them may pertain to a transaction. 01920 * @a scratch_pool is used for temporary allocations. 01921 * 01922 * @note Paths from different svn_fs_t will be reported as unrelated even 01923 * if the underlying physical repository is the same. 01924 * 01925 * @since New in 1.9. 01926 */ 01927 svn_error_t * 01928 svn_fs_node_relation(svn_fs_node_relation_t *relation, 01929 svn_fs_root_t *root_a, 01930 const char *path_a, 01931 svn_fs_root_t *root_b, 01932 const char *path_b, 01933 apr_pool_t *scratch_pool); 01934 01935 /** Set @a *revision to the revision in which the node-revision identified 01936 * by @a path under @a root was created; that is, to the revision in which 01937 * @a path under @a root was last modified. @a *revision will 01938 * be set to #SVN_INVALID_REVNUM for uncommitted nodes (i.e. modified nodes 01939 * under a transaction root). Note that the root of an unmodified transaction 01940 * is not itself considered to be modified; in that case, return the revision 01941 * upon which the transaction was based. 01942 * 01943 * Use @a pool for any temporary allocations. 01944 */ 01945 svn_error_t * 01946 svn_fs_node_created_rev(svn_revnum_t *revision, 01947 svn_fs_root_t *root, 01948 const char *path, 01949 apr_pool_t *pool); 01950 01951 /** Set @a *revision to the revision in which the line of history 01952 * represented by @a path under @a root originated. Use @a pool for 01953 * any temporary allocations. If @a root is a transaction root, @a 01954 * *revision will be set to #SVN_INVALID_REVNUM for any nodes newly 01955 * added in that transaction (brand new files or directories created 01956 * using #svn_fs_make_dir or #svn_fs_make_file). 01957 * 01958 * @since New in 1.5. 01959 */ 01960 svn_error_t * 01961 svn_fs_node_origin_rev(svn_revnum_t *revision, 01962 svn_fs_root_t *root, 01963 const char *path, 01964 apr_pool_t *pool); 01965 01966 /** Set @a *created_path to the path at which @a path under @a root was 01967 * created. Use @a pool for all allocations. Callers may use this 01968 * function in conjunction with svn_fs_node_created_rev() to perform a 01969 * reverse lookup of the mapping of (path, revision) -> node-id that 01970 * svn_fs_node_id() performs. 01971 */ 01972 svn_error_t * 01973 svn_fs_node_created_path(const char **created_path, 01974 svn_fs_root_t *root, 01975 const char *path, 01976 apr_pool_t *pool); 01977 01978 01979 /** Set @a *value_p to the value of the property named @a propname of 01980 * @a path in @a root. If the node has no property by that name, set 01981 * @a *value_p to zero. Allocate the result in @a pool. 01982 */ 01983 svn_error_t * 01984 svn_fs_node_prop(svn_string_t **value_p, 01985 svn_fs_root_t *root, 01986 const char *path, 01987 const char *propname, 01988 apr_pool_t *pool); 01989 01990 01991 /** Set @a *table_p to the entire property list of @a path in @a root, 01992 * as an APR hash table allocated in @a pool. The resulting table maps 01993 * property names to pointers to #svn_string_t objects containing the 01994 * property value. 01995 */ 01996 svn_error_t * 01997 svn_fs_node_proplist(apr_hash_t **table_p, 01998 svn_fs_root_t *root, 01999 const char *path, 02000 apr_pool_t *pool); 02001 02002 /** Set @a *has_props to TRUE if the node @a path in @a root has properties 02003 * and to FALSE if it doesn't have properties. Perform temporary allocations 02004 * in @a scratch_pool. 02005 * 02006 * @since New in 1.9. 02007 */ 02008 svn_error_t * 02009 svn_fs_node_has_props(svn_boolean_t *has_props, 02010 svn_fs_root_t *root, 02011 const char *path, 02012 apr_pool_t *scratch_pool); 02013 02014 02015 /** Change a node's property's value, or add/delete a property. 02016 * 02017 * - @a root and @a path indicate the node whose property should change. 02018 * @a root must be the root of a transaction, not the root of a revision. 02019 * - @a name is the name of the property to change. 02020 * - @a value is the new value of the property, or zero if the property should 02021 * be removed altogether. 02022 * Do any necessary temporary allocation in @a pool. 02023 */ 02024 svn_error_t * 02025 svn_fs_change_node_prop(svn_fs_root_t *root, 02026 const char *path, 02027 const char *name, 02028 const svn_string_t *value, 02029 apr_pool_t *pool); 02030 02031 02032 /** Determine if the properties of two path/root combinations are different. 02033 * 02034 * Set @a *different_p to #TRUE if the properties at @a path1 under @a root1 02035 * differ from those at @a path2 under @a root2, or set it to #FALSE if they 02036 * are the same. Both paths must exist under their respective roots, and 02037 * both roots must be in the same filesystem. 02038 * Do any necessary temporary allocation in @a scratch_pool. 02039 * 02040 * @note For the purposes of preserving accurate history, certain bits of 02041 * code (such as the repository dump code) need to care about the distinction 02042 * between situations when the properties are "different" and "have changed 02043 * across two points in history". We have a pair of functions that can 02044 * answer both of these questions, svn_fs_props_different() and 02045 * svn_fs_props_changed(). See issue 4598 for more details. 02046 * 02047 * @see svn_fs_props_changed 02048 * 02049 * @since New in 1.9. 02050 */ 02051 svn_error_t * 02052 svn_fs_props_different(svn_boolean_t *different_p, 02053 svn_fs_root_t *root1, 02054 const char *path1, 02055 svn_fs_root_t *root2, 02056 const char *path2, 02057 apr_pool_t *scratch_pool); 02058 02059 02060 /** Determine if the properties of two path/root combinations have changed. 02061 * 02062 * Set @a *changed_p to #TRUE if the properties at @a path1 under @a root1 02063 * differ from those at @a path2 under @a root2, or set it to #FALSE if they 02064 * are the same. Both paths must exist under their respective roots, and 02065 * both roots must be in the same filesystem. 02066 * Do any necessary temporary allocation in @a pool. 02067 * 02068 * @note For the purposes of preserving accurate history, certain bits of 02069 * code (such as the repository dump code) need to care about the distinction 02070 * between situations when the properties are "different" and "have changed 02071 * across two points in history". We have a pair of functions that can 02072 * answer both of these questions, svn_fs_props_different() and 02073 * svn_fs_props_changed(). See issue 4598 for more details. 02074 * 02075 * @note This function can currently return false negatives for FSFS: 02076 * If @a root1 and @a root2 were both transaction roots and the proplists 02077 * of both paths had been changed in their respective transactions, 02078 * @a changed_p would be set to #FALSE. 02079 * 02080 * @see svn_fs_props_different 02081 */ 02082 svn_error_t * 02083 svn_fs_props_changed(svn_boolean_t *changed_p, 02084 svn_fs_root_t *root1, 02085 const char *path1, 02086 svn_fs_root_t *root2, 02087 const char *path2, 02088 apr_pool_t *pool); 02089 02090 02091 /** Discover a node's copy ancestry, if any. 02092 * 02093 * If the node at @a path in @a root was copied from some other node, set 02094 * @a *rev_p and @a *path_p to the revision and path (expressed as an 02095 * absolute filesystem path) of the other node, allocating @a *path_p 02096 * in @a pool. 02097 * 02098 * Else if there is no copy ancestry for the node, set @a *rev_p to 02099 * #SVN_INVALID_REVNUM and @a *path_p to NULL. 02100 * 02101 * If an error is returned, the values of @a *rev_p and @a *path_p are 02102 * undefined, but otherwise, if one of them is set as described above, 02103 * you may assume the other is set correspondingly. 02104 * 02105 * @a root may be a revision root or a transaction root. 02106 * 02107 * Notes: 02108 * - Copy ancestry does not descend. After copying directory D to 02109 * E, E will have copy ancestry referring to D, but E's children 02110 * may not. See also svn_fs_copy(). 02111 * 02112 * - Copy ancestry *under* a copy is preserved. That is, if you 02113 * copy /A/D/G/pi to /A/D/G/pi2, and then copy /A/D/G to /G, then 02114 * /G/pi2 will still have copy ancestry pointing to /A/D/G/pi. 02115 * We don't know if this is a feature or a bug yet; if it turns 02116 * out to be a bug, then the fix is to make svn_fs_copied_from() 02117 * observe the following logic, which currently callers may 02118 * choose to follow themselves: if node X has copy history, but 02119 * its ancestor A also has copy history, then you may ignore X's 02120 * history if X's revision-of-origin is earlier than A's -- 02121 * because that would mean that X's copy history was preserved in 02122 * a copy-under-a-copy scenario. If X's revision-of-origin is 02123 * the same as A's, then it was copied under A during the same 02124 * transaction that created A. (X's revision-of-origin cannot be 02125 * greater than A's, if X has copy history.) @todo See how 02126 * people like this, it can always be hidden behind the curtain 02127 * if necessary. 02128 * 02129 * - Copy ancestry is not stored as a regular subversion property 02130 * because it is not inherited. Copying foo to bar results in a 02131 * revision of bar with copy ancestry; but committing a text 02132 * change to bar right after that results in a new revision of 02133 * bar without copy ancestry. 02134 */ 02135 svn_error_t * 02136 svn_fs_copied_from(svn_revnum_t *rev_p, 02137 const char **path_p, 02138 svn_fs_root_t *root, 02139 const char *path, 02140 apr_pool_t *pool); 02141 02142 02143 /** Set @a *root_p and @a *path_p to the revision root and path of the 02144 * destination of the most recent copy event that caused @a path to 02145 * exist where it does in @a root, or to NULL if no such copy exists. 02146 * 02147 * @a *path_p might be a parent of @a path, rather than @a path 02148 * itself. However, it will always be the deepest relevant path. 02149 * That is, if a copy occurs underneath another copy in the same txn, 02150 * this function makes sure to set @a *path_p to the longest copy 02151 * destination path that is still a parent of or equal to @a path. 02152 * 02153 * Values returned in @a *root_p and @a *path_p will be allocated 02154 * from @a pool. 02155 * 02156 * @since New in 1.3. 02157 */ 02158 svn_error_t * 02159 svn_fs_closest_copy(svn_fs_root_t **root_p, 02160 const char **path_p, 02161 svn_fs_root_t *root, 02162 const char *path, 02163 apr_pool_t *pool); 02164 02165 /** Receives parsed @a mergeinfo for the file system path @a path. 02166 * 02167 * The user-provided @a baton is being passed through by the retrieval 02168 * function and @a scratch_pool will be cleared between invocations. 02169 * 02170 * @since New in 1.10. 02171 */ 02172 typedef svn_error_t * 02173 (*svn_fs_mergeinfo_receiver_t)(const char *path, 02174 svn_mergeinfo_t mergeinfo, 02175 void *baton, 02176 apr_pool_t *scratch_pool); 02177 02178 /** Retrieve mergeinfo for multiple nodes. 02179 * 02180 * For each node found with mergeinfo on it, invoke @a receiver with 02181 * the provided @a baton. 02182 * 02183 * @a root is revision root to use when looking up paths. 02184 * 02185 * @a paths are the paths you are requesting information for. 02186 * 02187 * @a inherit indicates whether to retrieve explicit, 02188 * explicit-or-inherited, or only inherited mergeinfo. 02189 * 02190 * If @a adjust_inherited_mergeinfo is @c TRUE, then any inherited 02191 * mergeinfo reported to @a *receiver is normalized to represent the 02192 * inherited mergeinfo on the path which inherits it. This adjusted 02193 * mergeinfo is keyed by the path which inherits it. If 02194 * @a adjust_inherited_mergeinfo is @c FALSE, then any inherited 02195 * mergeinfo is the raw explicit mergeinfo from the nearest parent 02196 * of the path with explicit mergeinfo, unadjusted for the path-wise 02197 * difference between the path and its parent. This may include 02198 * non-inheritable mergeinfo. This unadjusted mergeinfo is keyed by 02199 * the path at which it was found. 02200 * 02201 * If @a include_descendants is TRUE, then additionally return the 02202 * mergeinfo for any descendant of any element of @a paths which has 02203 * the #SVN_PROP_MERGEINFO property explicitly set on it. (Note 02204 * that inheritance is only taken into account for the elements in @a 02205 * paths; descendants of the elements in @a paths which get their 02206 * mergeinfo via inheritance are not reported to @a receiver.) 02207 * 02208 * Do any necessary temporary allocations in @a scratch_pool. 02209 * 02210 * @since New in 1.10. 02211 */ 02212 svn_error_t * 02213 svn_fs_get_mergeinfo3(svn_fs_root_t *root, 02214 const apr_array_header_t *paths, 02215 svn_mergeinfo_inheritance_t inherit, 02216 svn_boolean_t include_descendants, 02217 svn_boolean_t adjust_inherited_mergeinfo, 02218 svn_fs_mergeinfo_receiver_t receiver, 02219 void *baton, 02220 apr_pool_t *scratch_pool); 02221 02222 /** 02223 * Same as svn_fs_get_mergeinfo3(), but all mergeinfo is being collected 02224 * and returned in @a *catalog. It will never be @c NULL, but may be empty. 02225 * 02226 * @since New in 1.8. 02227 * 02228 * @deprecated Provided for backward compatibility with the 1.9 API. 02229 */ 02230 SVN_DEPRECATED 02231 svn_error_t * 02232 svn_fs_get_mergeinfo2(svn_mergeinfo_catalog_t *catalog, 02233 svn_fs_root_t *root, 02234 const apr_array_header_t *paths, 02235 svn_mergeinfo_inheritance_t inherit, 02236 svn_boolean_t include_descendants, 02237 svn_boolean_t adjust_inherited_mergeinfo, 02238 apr_pool_t *result_pool, 02239 apr_pool_t *scratch_pool); 02240 02241 /** 02242 * Same as svn_fs_get_mergeinfo2(), but with @a adjust_inherited_mergeinfo 02243 * set always set to @c TRUE and with only one pool. 02244 * 02245 * @deprecated Provided for backward compatibility with the 1.5 API. 02246 */ 02247 SVN_DEPRECATED 02248 svn_error_t * 02249 svn_fs_get_mergeinfo(svn_mergeinfo_catalog_t *catalog, 02250 svn_fs_root_t *root, 02251 const apr_array_header_t *paths, 02252 svn_mergeinfo_inheritance_t inherit, 02253 svn_boolean_t include_descendants, 02254 apr_pool_t *pool); 02255 02256 /** Merge changes between two nodes into a third node. 02257 * 02258 * Given nodes @a source and @a target, and a common ancestor @a ancestor, 02259 * modify @a target to contain all the changes made between @a ancestor and 02260 * @a source, as well as the changes made between @a ancestor and @a target. 02261 * @a target_root must be the root of a transaction, not a revision. 02262 * 02263 * @a source, @a target, and @a ancestor are generally directories; this 02264 * function recursively merges the directories' contents. If they are 02265 * files, this function simply returns an error whenever @a source, 02266 * @a target, and @a ancestor are all distinct node revisions. 02267 * 02268 * If there are differences between @a ancestor and @a source that conflict 02269 * with changes between @a ancestor and @a target, this function returns an 02270 * #SVN_ERR_FS_CONFLICT error. 02271 * 02272 * If the merge is successful, @a target is left in the merged state, and 02273 * the base root of @a target's txn is set to the root node of @a source. 02274 * If an error is returned (whether for conflict or otherwise), @a target 02275 * is left unaffected. 02276 * 02277 * If @a conflict_p is non-NULL, then: a conflict error sets @a *conflict_p 02278 * to the name of the node in @a target which couldn't be merged, 02279 * otherwise, success sets @a *conflict_p to NULL. 02280 * 02281 * Do any necessary temporary allocation in @a pool. 02282 */ 02283 svn_error_t * 02284 svn_fs_merge(const char **conflict_p, 02285 svn_fs_root_t *source_root, 02286 const char *source_path, 02287 svn_fs_root_t *target_root, 02288 const char *target_path, 02289 svn_fs_root_t *ancestor_root, 02290 const char *ancestor_path, 02291 apr_pool_t *pool); 02292 02293 02294 02295 /* Directories. */ 02296 02297 02298 /** The type of a Subversion directory entry. */ 02299 typedef struct svn_fs_dirent_t 02300 { 02301 02302 /** The name of this directory entry. */ 02303 const char *name; 02304 02305 /** The node revision ID it names. */ 02306 const svn_fs_id_t *id; 02307 02308 /** The node kind. */ 02309 svn_node_kind_t kind; 02310 02311 } svn_fs_dirent_t; 02312 02313 02314 /** Set @a *entries_p to a newly allocated APR hash table containing the 02315 * entries of the directory at @a path in @a root. The keys of the table 02316 * are entry names, as byte strings, excluding the final NULL 02317 * character; the table's values are pointers to #svn_fs_dirent_t 02318 * structures. Allocate the table and its contents in @a pool. 02319 */ 02320 svn_error_t * 02321 svn_fs_dir_entries(apr_hash_t **entries_p, 02322 svn_fs_root_t *root, 02323 const char *path, 02324 apr_pool_t *pool); 02325 02326 /** Take the #svn_fs_dirent_t structures in @a entries as returned by 02327 * #svn_fs_dir_entries for @a root and determine an optimized ordering 02328 * in which data access would most likely be efficient. Set @a *ordered_p 02329 * to a newly allocated APR array of pointers to these #svn_fs_dirent_t 02330 * structures. Allocate the array (but not its contents) in @a result_pool 02331 * and use @a scratch_pool for temporaries. 02332 * 02333 * @since New in 1.9. 02334 */ 02335 svn_error_t * 02336 svn_fs_dir_optimal_order(apr_array_header_t **ordered_p, 02337 svn_fs_root_t *root, 02338 apr_hash_t *entries, 02339 apr_pool_t *result_pool, 02340 apr_pool_t *scratch_pool); 02341 02342 /** Create a new directory named @a path in @a root. The new directory has 02343 * no entries, and no properties. @a root must be the root of a transaction, 02344 * not a revision. 02345 * 02346 * Do any necessary temporary allocation in @a pool. 02347 */ 02348 svn_error_t * 02349 svn_fs_make_dir(svn_fs_root_t *root, 02350 const char *path, 02351 apr_pool_t *pool); 02352 02353 02354 /** Delete the node named @a path in @a root. If the node being deleted is 02355 * a directory, its contents will be deleted recursively. @a root must be 02356 * the root of a transaction, not of a revision. Use @a pool for 02357 * temporary allocation. 02358 * 02359 * If return #SVN_ERR_FS_NO_SUCH_ENTRY, then the basename of @a path is 02360 * missing from its parent, that is, the final target of the deletion 02361 * is missing. 02362 * 02363 * Attempting to remove the root dir also results in an error, 02364 * #SVN_ERR_FS_ROOT_DIR, even if the dir is empty. 02365 */ 02366 svn_error_t * 02367 svn_fs_delete(svn_fs_root_t *root, 02368 const char *path, 02369 apr_pool_t *pool); 02370 02371 02372 /** Create a copy of @a from_path in @a from_root named @a to_path in 02373 * @a to_root. If @a from_path in @a from_root is a directory, copy the 02374 * tree it refers to recursively. 02375 * 02376 * The copy will remember its source; use svn_fs_copied_from() to 02377 * access this information. 02378 * 02379 * @a to_root must be the root of a transaction; @a from_root must be the 02380 * root of a revision. (Requiring @a from_root to be the root of a 02381 * revision makes the implementation trivial: there is no detectable 02382 * difference (modulo node revision ID's) between copying @a from and 02383 * simply adding a reference to it. So the operation takes place in 02384 * constant time. However, there's no reason not to extend this to 02385 * mutable nodes --- it's just more code.) Further, @a to_root and @a 02386 * from_root must represent the same filesystem. 02387 * 02388 * @note To do a copy without preserving copy history, use 02389 * svn_fs_revision_link(). 02390 * 02391 * Do any necessary temporary allocation in @a pool. 02392 */ 02393 svn_error_t * 02394 svn_fs_copy(svn_fs_root_t *from_root, 02395 const char *from_path, 02396 svn_fs_root_t *to_root, 02397 const char *to_path, 02398 apr_pool_t *pool); 02399 02400 02401 /** Like svn_fs_copy(), but doesn't record copy history, and preserves 02402 * the PATH. You cannot use svn_fs_copied_from() later to find out 02403 * where this copy came from. 02404 * 02405 * Use svn_fs_revision_link() in situations where you don't care 02406 * about the copy history, and where @a to_path and @a from_path are 02407 * the same, because it is cheaper than svn_fs_copy(). 02408 */ 02409 svn_error_t * 02410 svn_fs_revision_link(svn_fs_root_t *from_root, 02411 svn_fs_root_t *to_root, 02412 const char *path, 02413 apr_pool_t *pool); 02414 02415 02416 /* Files. */ 02417 02418 /** Set @a *length_p to the length of the file @a path in @a root, in bytes. 02419 * Do any necessary temporary allocation in @a pool. 02420 */ 02421 svn_error_t * 02422 svn_fs_file_length(svn_filesize_t *length_p, 02423 svn_fs_root_t *root, 02424 const char *path, 02425 apr_pool_t *pool); 02426 02427 02428 /** Set @a *checksum to the checksum of type @a kind for the file @a path. 02429 * @a *checksum will be allocated out of @a pool, which will also be used 02430 * for temporary allocations. 02431 * 02432 * If the filesystem does not have a prerecorded checksum of @a kind for 02433 * @a path, and @a force is not TRUE, do not calculate a checksum 02434 * dynamically, just put NULL into @a checksum. (By convention, the NULL 02435 * checksum is considered to match any checksum.) 02436 * 02437 * Notes: 02438 * 02439 * You might wonder, why do we only provide this interface for file 02440 * contents, and not for properties or directories? 02441 * 02442 * The answer is that property lists and directory entry lists are 02443 * essentially data structures, not text. We serialize them for 02444 * transmission, but there is no guarantee that the consumer will 02445 * parse them into the same form, or even the same order, as the 02446 * producer. It's difficult to find a checksumming method that 02447 * reaches the same result given such variation in input. (I suppose 02448 * we could calculate an independent MD5 sum for each propname and 02449 * value, and XOR them together; same with directory entry names. 02450 * Maybe that's the solution?) Anyway, for now we punt. The most 02451 * important data, and the only data that goes through svndiff 02452 * processing, is file contents, so that's what we provide 02453 * checksumming for. 02454 * 02455 * Internally, of course, the filesystem checksums everything, because 02456 * it has access to the lowest level storage forms: strings behind 02457 * representations. 02458 * 02459 * @since New in 1.6. 02460 */ 02461 svn_error_t * 02462 svn_fs_file_checksum(svn_checksum_t **checksum, 02463 svn_checksum_kind_t kind, 02464 svn_fs_root_t *root, 02465 const char *path, 02466 svn_boolean_t force, 02467 apr_pool_t *pool); 02468 02469 /** 02470 * Same as svn_fs_file_checksum(), only always put the MD5 checksum of file 02471 * @a path into @a digest, which should point to @c APR_MD5_DIGESTSIZE bytes 02472 * of storage. If the checksum doesn't exist, put all 0's into @a digest. 02473 * 02474 * @deprecated Provided for backward compatibility with the 1.5 API. 02475 */ 02476 SVN_DEPRECATED 02477 svn_error_t * 02478 svn_fs_file_md5_checksum(unsigned char digest[], 02479 svn_fs_root_t *root, 02480 const char *path, 02481 apr_pool_t *pool); 02482 02483 02484 /** Set @a *contents to a readable generic stream that will yield the 02485 * contents of the file @a path in @a root. Allocate the stream in 02486 * @a pool. You can only use @a *contents for as long as the underlying 02487 * filesystem is open. If @a path is not a file, return 02488 * #SVN_ERR_FS_NOT_FILE. 02489 * 02490 * If @a root is the root of a transaction, it is possible that the 02491 * contents of the file @a path will change between calls to 02492 * svn_fs_file_contents(). In that case, the result of reading from 02493 * @a *contents is undefined. 02494 * 02495 * ### @todo kff: I am worried about lifetime issues with this pool vs 02496 * the trail created farther down the call stack. Trace this function 02497 * to investigate... 02498 */ 02499 svn_error_t * 02500 svn_fs_file_contents(svn_stream_t **contents, 02501 svn_fs_root_t *root, 02502 const char *path, 02503 apr_pool_t *pool); 02504 02505 /** 02506 * Callback function type used with svn_fs_try_process_file_contents() 02507 * that delivers the immutable, non-NULL @a contents of @a len bytes. 02508 * @a baton is an implementation-specific closure. 02509 * 02510 * Use @a scratch_pool for allocations. 02511 * 02512 * @since New in 1.8. 02513 */ 02514 typedef svn_error_t * 02515 (*svn_fs_process_contents_func_t)(const unsigned char *contents, 02516 apr_size_t len, 02517 void *baton, 02518 apr_pool_t *scratch_pool); 02519 02520 /** Efficiently deliver the contents of the file @a path in @a root 02521 * via @a processor (with @a baton), setting @a *success to @c TRUE 02522 * upon doing so. Use @a pool for allocations. 02523 * 02524 * This function is intended to support zero copy data processing. It may 02525 * not be implemented for all data backends or not be applicable for certain 02526 * content. In those cases, @a *success will always be @c FALSE. Also, 02527 * this is a best-effort function which means that there is no guarantee 02528 * that @a processor gets called at all. 02529 * 02530 * @note @a processor is expected to be a relatively simple function with 02531 * a runtime of O(content size) or less. 02532 * 02533 * @since New in 1.8. 02534 */ 02535 svn_error_t * 02536 svn_fs_try_process_file_contents(svn_boolean_t *success, 02537 svn_fs_root_t *root, 02538 const char *path, 02539 svn_fs_process_contents_func_t processor, 02540 void* baton, 02541 apr_pool_t *pool); 02542 02543 /** Create a new file named @a path in @a root. The file's initial contents 02544 * are the empty string, and it has no properties. @a root must be the 02545 * root of a transaction, not a revision. 02546 * 02547 * Do any necessary temporary allocation in @a pool. 02548 */ 02549 svn_error_t * 02550 svn_fs_make_file(svn_fs_root_t *root, 02551 const char *path, 02552 apr_pool_t *pool); 02553 02554 02555 /** Apply a text delta to the file @a path in @a root. @a root must be the 02556 * root of a transaction, not a revision. 02557 * 02558 * Set @a *contents_p to a function ready to receive text delta windows 02559 * describing how to change the file's contents, relative to its 02560 * current contents. Set @a *contents_baton_p to a baton to pass to 02561 * @a *contents_p. 02562 * 02563 * If @a path does not exist in @a root, return an error. (You cannot use 02564 * this routine to create new files; use svn_fs_make_file() to create 02565 * an empty file first.) 02566 * 02567 * @a base_checksum is the hex MD5 digest for the base text against 02568 * which the delta is to be applied; it is ignored if NULL, and may be 02569 * ignored even if not NULL. If it is not ignored, it must match the 02570 * checksum of the base text against which svndiff data is being 02571 * applied; if not, svn_fs_apply_textdelta() or the @a *contents_p call 02572 * which detects the mismatch will return the error 02573 * #SVN_ERR_CHECKSUM_MISMATCH (if there is no base text, there may 02574 * still be an error if @a base_checksum is neither NULL nor the 02575 * checksum of the empty string). 02576 * 02577 * @a result_checksum is the hex MD5 digest for the fulltext that 02578 * results from this delta application. It is ignored if NULL, but if 02579 * not NULL, it must match the checksum of the result; if it does not, 02580 * then the @a *contents_p call which detects the mismatch will return 02581 * the error #SVN_ERR_CHECKSUM_MISMATCH. 02582 * 02583 * The caller must send all delta windows including the terminating 02584 * NULL window to @a *contents_p before making further changes to the 02585 * transaction. 02586 * 02587 * Do temporary allocation in @a pool. 02588 */ 02589 svn_error_t * 02590 svn_fs_apply_textdelta(svn_txdelta_window_handler_t *contents_p, 02591 void **contents_baton_p, 02592 svn_fs_root_t *root, 02593 const char *path, 02594 const char *base_checksum, 02595 const char *result_checksum, 02596 apr_pool_t *pool); 02597 02598 02599 /** Write data directly to the file @a path in @a root. @a root must be the 02600 * root of a transaction, not a revision. 02601 * 02602 * Set @a *contents_p to a stream ready to receive full textual data. 02603 * When the caller closes this stream, the data replaces the previous 02604 * contents of the file. The caller must write all file data and close 02605 * the stream before making further changes to the transaction. 02606 * 02607 * If @a path does not exist in @a root, return an error. (You cannot use 02608 * this routine to create new files; use svn_fs_make_file() to create 02609 * an empty file first.) 02610 * 02611 * @a result_checksum is the hex MD5 digest for the final fulltext 02612 * written to the stream. It is ignored if NULL, but if not null, it 02613 * must match the checksum of the result; if it does not, then the @a 02614 * *contents_p call which detects the mismatch will return the error 02615 * #SVN_ERR_CHECKSUM_MISMATCH. 02616 * 02617 * Do any necessary temporary allocation in @a pool. 02618 * 02619 * @note This is like svn_fs_apply_textdelta(), but takes the text 02620 * straight. 02621 */ 02622 svn_error_t * 02623 svn_fs_apply_text(svn_stream_t **contents_p, 02624 svn_fs_root_t *root, 02625 const char *path, 02626 const char *result_checksum, 02627 apr_pool_t *pool); 02628 02629 02630 /** Check if the contents of two root/path combos are different. 02631 * 02632 * Set @a *different_p to #TRUE if the file contents at @a path1 under 02633 * @a root1 differ from those at @a path2 under @a root2, or set it to 02634 * #FALSE if they are the same. Both paths must exist under their 02635 * respective roots, and both roots must be in the same filesystem. 02636 * Do any necessary temporary allocation in @a scratch_pool. 02637 * 02638 * @note For the purposes of preserving accurate history, certain bits of 02639 * code (such as the repository dump code) need to care about the distinction 02640 * between situations when two files have "different" content and when the 02641 * contents of a given file "have changed" across two points in its history. 02642 * We have a pair of functions that can answer both of these questions, 02643 * svn_fs_contents_different() and svn_fs_contents_changed(). See issue 02644 * 4598 for more details. 02645 * 02646 * @see svn_fs_contents_changed 02647 * 02648 * @since New in 1.9. 02649 */ 02650 svn_error_t * 02651 svn_fs_contents_different(svn_boolean_t *different_p, 02652 svn_fs_root_t *root1, 02653 const char *path1, 02654 svn_fs_root_t *root2, 02655 const char *path2, 02656 apr_pool_t *scratch_pool); 02657 02658 /** Check if the contents of two root/path combos have changed. 02659 * 02660 * Set @a *changed_p to #TRUE if the file contents at @a path1 under 02661 * @a root1 differ from those at @a path2 under @a root2, or set it to 02662 * #FALSE if they are the same. Both paths must exist under their 02663 * respective roots, and both roots must be in the same filesystem. 02664 * Do any necessary temporary allocation in @a pool. 02665 * 02666 * @note svn_fs_contents_changed() was not designed to be used to detect 02667 * when two files have different content, but really to detect when the 02668 * contents of a given file have changed across two points in its history. 02669 * For the purposes of preserving accurate history, certain bits of code 02670 * (such as the repository dump code) need to care about this distinction. 02671 * For example, it's not an error from the FS API point of view to call 02672 * svn_fs_apply_textdelta() and explicitly set a file's contents to exactly 02673 * what they were before the edit was made. We have a pair of functions 02674 * that can answer both of these questions, svn_fs_contents_changed() and 02675 * svn_fs_contents_different(). See issue 4598 for more details. 02676 * 02677 * @see svn_fs_contents_different 02678 */ 02679 svn_error_t * 02680 svn_fs_contents_changed(svn_boolean_t *changed_p, 02681 svn_fs_root_t *root1, 02682 const char *path1, 02683 svn_fs_root_t *root2, 02684 const char *path2, 02685 apr_pool_t *pool); 02686 02687 02688 02689 /* Filesystem revisions. */ 02690 02691 02692 /** Set @a *youngest_p to the number of the youngest revision in filesystem 02693 * @a fs. Use @a pool for all temporary allocation. 02694 * 02695 * The oldest revision in any filesystem is numbered zero. 02696 */ 02697 svn_error_t * 02698 svn_fs_youngest_rev(svn_revnum_t *youngest_p, 02699 svn_fs_t *fs, 02700 apr_pool_t *pool); 02701 02702 02703 /** 02704 * Return filesystem format information for @a fs. 02705 * 02706 * Set @a *fs_format to the filesystem format number of @a fs, which is 02707 * an integer that increases when incompatible changes are made (such as 02708 * by #svn_fs_upgrade). 02709 * 02710 * Set @a *supports_version to the version number of the minimum Subversion GA 02711 * release that can read and write @a fs. 02712 * 02713 * @see svn_repos_info_format 02714 * 02715 * @since New in 1.9. 02716 */ 02717 svn_error_t * 02718 svn_fs_info_format(int *fs_format, 02719 svn_version_t **supports_version, 02720 svn_fs_t *fs, 02721 apr_pool_t *result_pool, 02722 apr_pool_t *scratch_pool); 02723 02724 /** 02725 * Return a list of admin-serviceable config files for @a fs. @a *files 02726 * will be set to an array containing paths as C strings. 02727 * 02728 * @since New in 1.9. 02729 */ 02730 svn_error_t * 02731 svn_fs_info_config_files(apr_array_header_t **files, 02732 svn_fs_t *fs, 02733 apr_pool_t *result_pool, 02734 apr_pool_t *scratch_pool); 02735 02736 02737 02738 /** Provide filesystem @a fs the opportunity to compress storage relating to 02739 * associated with @a revision in filesystem @a fs. Use @a pool for all 02740 * allocations. 02741 * 02742 * @note This can be a time-consuming process, depending the breadth 02743 * of the changes made in @a revision, and the depth of the history of 02744 * those changed paths. This may also be a no op. 02745 */ 02746 svn_error_t * 02747 svn_fs_deltify_revision(svn_fs_t *fs, 02748 svn_revnum_t revision, 02749 apr_pool_t *pool); 02750 02751 /** Make sure that all completed revision property changes to the filesystem 02752 * underlying @a fs are actually visible through @a fs. Use @a scratch_pool 02753 * for temporary allocations. 02754 * 02755 * This is an explicit synchronization barrier for revprop changes made 02756 * through different #svn_fs_t for the same underlying filesystem. Any 02757 * revprop change through @a fs acts as an implicit barrier, i.e. that 02758 * object will see all completed revprop changes up to an including its own. 02759 * Only #svn_fs_revision_prop2 and #svn_fs_revision_proplist2 have an option 02760 * to not synchronize with on-disk data and potentially return outdated data 02761 * as old as the last barrier. 02762 * 02763 * The intended use of this is implementing efficient queries in upper layers 02764 * where the result only needs to include all changes up to the start of 02765 * that query but does not need to pick up on changes while the query is 02766 * running: 02767 * 02768 * @code 02769 SVN_ERR(svn_fs_deltify_revision(fs, pool); 02770 for (i = 0; i < n; i++) 02771 SVN_ERR(svn_fs_revision_prop2(&authors[i], fs, revs[i], "svn:author", 02772 FALSE, pool, pool)); @endcode 02773 * 02774 * @see svn_fs_revision_prop2, svn_fs_revision_proplist2 02775 * 02776 * @since New in 1.10. 02777 */ 02778 svn_error_t * 02779 svn_fs_refresh_revision_props(svn_fs_t *fs, 02780 apr_pool_t *scratch_pool); 02781 02782 /** Set @a *value_p to the value of the property named @a propname on 02783 * revision @a rev in the filesystem @a fs. If @a rev has no property by 02784 * that name, set @a *value_p to zero. 02785 * 02786 * If @a refresh is set, this call acts as a read barrier and is guaranteed 02787 * to return the latest value. Otherwise, it may return data as old as the 02788 * last synchronization point but can be much faster to access - in 02789 * particular for packed repositories. 02790 * 02791 * Allocate the result in @a result_pool and use @a scratch_pool for 02792 * temporary allocations. 02793 * 02794 * @see svn_fs_refresh_revision_props 02795 * 02796 * @since New in 1.10. 02797 */ 02798 svn_error_t * 02799 svn_fs_revision_prop2(svn_string_t **value_p, 02800 svn_fs_t *fs, 02801 svn_revnum_t rev, 02802 const char *propname, 02803 svn_boolean_t refresh, 02804 apr_pool_t *result_pool, 02805 apr_pool_t *scratch_pool); 02806 02807 /** Like #svn_fs_revision_prop2 but using @a pool for @a scratch_pool as 02808 * well as @a result_pool and setting @a refresh to #TRUE. 02809 * 02810 * @see svn_fs_refresh_revision_props 02811 * 02812 * @deprecated For backward compatibility with 1.9. 02813 */ 02814 SVN_DEPRECATED 02815 svn_error_t * 02816 svn_fs_revision_prop(svn_string_t **value_p, 02817 svn_fs_t *fs, 02818 svn_revnum_t rev, 02819 const char *propname, 02820 apr_pool_t *pool); 02821 02822 02823 /** Set @a *table_p to the entire property list of revision @a rev in 02824 * filesystem @a fs, as an APR hash table allocated in @a pool. The table 02825 * maps <tt>char *</tt> property names to #svn_string_t * values; the names 02826 * and values are allocated in @a result_pool. Use @a scratch_pool for 02827 * temporary allocations. 02828 * 02829 * If @a refresh is set, this call acts as a read barrier and is guaranteed 02830 * to return the latest value. Otherwise, it may return data as old as the 02831 * last synchronization point but can be much faster to access - in 02832 * particular for packed repositories. 02833 * 02834 * @see svn_fs_refresh_revision_props 02835 * 02836 * @since New in 1.10. 02837 * 02838 */ 02839 svn_error_t * 02840 svn_fs_revision_proplist2(apr_hash_t **table_p, 02841 svn_fs_t *fs, 02842 svn_revnum_t rev, 02843 svn_boolean_t refresh, 02844 apr_pool_t *result_pool, 02845 apr_pool_t *scratch_pool); 02846 02847 /** Like svn_fs_revision_proplist2 but using @a pool for @a scratch_pool as 02848 * well as @a result_pool and setting @a refresh to #TRUE. 02849 * 02850 * @see svn_fs_refresh_revision_props 02851 * 02852 * @deprecated For backward compatibility with 1.9. 02853 */ 02854 SVN_DEPRECATED 02855 svn_error_t * 02856 svn_fs_revision_proplist(apr_hash_t **table_p, 02857 svn_fs_t *fs, 02858 svn_revnum_t rev, 02859 apr_pool_t *pool); 02860 02861 /** Change a revision's property's value, or add/delete a property. 02862 * 02863 * - @a fs is a filesystem, and @a rev is the revision in that filesystem 02864 * whose property should change. 02865 * - @a name is the name of the property to change. 02866 * - if @a old_value_p is not @c NULL, then changing the property will fail with 02867 * error #SVN_ERR_FS_PROP_BASEVALUE_MISMATCH if the present value of the 02868 * property is not @a *old_value_p. (This is an atomic test-and-set). 02869 * @a *old_value_p may be @c NULL, representing that the property must be not 02870 * already set. 02871 * - @a value is the new value of the property, or zero if the property should 02872 * be removed altogether. 02873 * 02874 * Note that revision properties are non-historied --- you can change 02875 * them after the revision has been committed. They are not protected 02876 * via transactions. 02877 * 02878 * Do any necessary temporary allocation in @a pool. 02879 * 02880 * @since New in 1.7. 02881 */ 02882 svn_error_t * 02883 svn_fs_change_rev_prop2(svn_fs_t *fs, 02884 svn_revnum_t rev, 02885 const char *name, 02886 const svn_string_t *const *old_value_p, 02887 const svn_string_t *value, 02888 apr_pool_t *pool); 02889 02890 02891 /** 02892 * Similar to svn_fs_change_rev_prop2(), but with @a old_value_p passed as 02893 * @c NULL. 02894 * 02895 * @deprecated Provided for backward compatibility with the 1.6 API. 02896 */ 02897 SVN_DEPRECATED 02898 svn_error_t * 02899 svn_fs_change_rev_prop(svn_fs_t *fs, 02900 svn_revnum_t rev, 02901 const char *name, 02902 const svn_string_t *value, 02903 apr_pool_t *pool); 02904 02905 02906 02907 /* Computing deltas. */ 02908 02909 02910 /** Set @a *stream_p to a pointer to a delta stream that will turn the 02911 * contents of the file @a source into the contents of the file @a target. 02912 * If @a source_root is zero, use a file with zero length as the source. 02913 * 02914 * This function does not compare the two files' properties. 02915 * 02916 * Allocate @a *stream_p, and do any necessary temporary allocation, in 02917 * @a pool. 02918 */ 02919 svn_error_t * 02920 svn_fs_get_file_delta_stream(svn_txdelta_stream_t **stream_p, 02921 svn_fs_root_t *source_root, 02922 const char *source_path, 02923 svn_fs_root_t *target_root, 02924 const char *target_path, 02925 apr_pool_t *pool); 02926 02927 02928 02929 /* UUID manipulation. */ 02930 02931 /** Populate @a *uuid with the UUID associated with @a fs. Allocate 02932 @a *uuid in @a pool. */ 02933 svn_error_t * 02934 svn_fs_get_uuid(svn_fs_t *fs, 02935 const char **uuid, 02936 apr_pool_t *pool); 02937 02938 02939 /** If not @c NULL, associate @a *uuid with @a fs. Otherwise (if @a 02940 * uuid is @c NULL), generate a new UUID for @a fs. Use @a pool for 02941 * any scratch work. 02942 */ 02943 svn_error_t * 02944 svn_fs_set_uuid(svn_fs_t *fs, 02945 const char *uuid, 02946 apr_pool_t *pool); 02947 02948 02949 /** @defgroup svn_fs_locks Filesystem locks 02950 * @{ 02951 * @since New in 1.2. */ 02952 02953 /** A lock represents one user's exclusive right to modify a path in a 02954 * filesystem. In order to create or destroy a lock, a username must 02955 * be associated with the filesystem's access context (see 02956 * #svn_fs_access_t). 02957 * 02958 * When a lock is created, a 'lock-token' is returned. The lock-token 02959 * is a unique URI that represents the lock (treated as an opaque 02960 * string by the client), and is required to make further use of the 02961 * lock (including removal of the lock.) A lock-token can also be 02962 * queried to return a svn_lock_t structure that describes the details 02963 * of the lock. lock-tokens must not contain any newline character, 02964 * mainly due to the serialization for tokens for pre-commit hook. 02965 * 02966 * Locks are not secret; anyone can view existing locks in a 02967 * filesystem. Locks are not omnipotent: they can be broken and stolen 02968 * by people who don't "own" the lock. (Though admins can tailor a 02969 * custom break/steal policy via libsvn_repos pre-lock hook script.) 02970 * 02971 * Locks can be created with an optional expiration date. If a lock 02972 * has an expiration date, then the act of fetching/reading it might 02973 * cause it to automatically expire, returning either nothing or an 02974 * expiration error (depending on the API). 02975 */ 02976 02977 /** Lock information for use with svn_fs_lock_many() [and svn_repos_fs_...]. 02978 * 02979 * @see svn_fs_lock_target_create 02980 * 02981 * @since New in 1.9. 02982 */ 02983 typedef struct svn_fs_lock_target_t svn_fs_lock_target_t; 02984 02985 /** Create an <tt>svn_fs_lock_target_t</tt> allocated in @a result_pool. 02986 * @a token can be NULL and @a current_rev can be SVN_INVALID_REVNUM. 02987 * 02988 * The @a token is not duplicated and so must have a lifetime at least as 02989 * long as the returned target object. 02990 * 02991 * @since New in 1.9. 02992 */ 02993 svn_fs_lock_target_t *svn_fs_lock_target_create(const char *token, 02994 svn_revnum_t current_rev, 02995 apr_pool_t *result_pool); 02996 02997 /** Update @a target changing the token to @a token, @a token can be NULL. 02998 * 02999 * The @a token is not duplicated and so must have a lifetime at least as 03000 * long as @a target. 03001 * 03002 * @since New in 1.9. 03003 */ 03004 void svn_fs_lock_target_set_token(svn_fs_lock_target_t *target, 03005 const char *token); 03006 03007 /** The callback invoked by svn_fs_lock_many() and svn_fs_unlock_many(). 03008 * 03009 * @a path and @a lock are allocated in the result_pool passed to 03010 * svn_fs_lock_many/svn_fs_unlock_many and so will persist beyond the 03011 * callback invocation. @a fs_err will be cleared after the callback 03012 * returns, use svn_error_dup() to preserve the error. 03013 * 03014 * If the callback returns an error no further callbacks will be made 03015 * and svn_fs_lock_many/svn_fs_unlock_many will return an error. The 03016 * caller cannot rely on any particular order for these callbacks and 03017 * cannot rely on interrupting the underlying operation by returning 03018 * an error. Returning an error stops the callbacks but any locks 03019 * that would have been reported in further callbacks may, or may not, 03020 * still be created/released. 03021 * 03022 * @since New in 1.9. 03023 */ 03024 typedef svn_error_t *(*svn_fs_lock_callback_t)(void *baton, 03025 const char *path, 03026 const svn_lock_t *lock, 03027 svn_error_t *fs_err, 03028 apr_pool_t *scratch_pool); 03029 03030 /** Lock the paths in @a lock_targets in @a fs. 03031 * 03032 * @a fs must have a username associated with it (see 03033 * #svn_fs_access_t), else return #SVN_ERR_FS_NO_USER. Set the 03034 * 'owner' field in each new lock to the fs username. 03035 * 03036 * @a comment is optional: it's either an xml-escapable UTF8 string 03037 * which describes the lock, or it is @c NULL. 03038 * 03039 * @a is_dav_comment describes whether the comment was created by a 03040 * generic DAV client; only mod_dav_svn's autoversioning feature needs 03041 * to use it. If in doubt, pass 0. 03042 * 03043 * The paths to be locked are passed as the <tt>const char *</tt> keys 03044 * of the @a lock_targets hash. The hash values are 03045 * <tt>svn_fs_lock_target_t *</tt> and provide the token and 03046 * @a current_rev for each path. The token is a lock token such as can 03047 * be generated using svn_fs_generate_lock_token() (indicating that 03048 * the caller wants to dictate the lock token used), or it is @c NULL 03049 * (indicating that the caller wishes to have a new token generated by 03050 * this function). If the token is not @c NULL, and represents an 03051 * existing lock, then the path must match the path associated with 03052 * that existing lock. If @a current_rev is a valid revnum, then do an 03053 * out-of-dateness check. If the revnum is less than the 03054 * last-changed-revision of the path (or if the path doesn't exist in 03055 * HEAD), yield an #SVN_ERR_FS_OUT_OF_DATE error for this path. 03056 * 03057 * If a path is already locked, then yield #SVN_ERR_FS_PATH_ALREADY_LOCKED, 03058 * unless @a steal_lock is TRUE, in which case "steal" the existing 03059 * lock, even if the FS access-context's username does not match the 03060 * current lock's owner: delete the existing lock on the path, and 03061 * create a new one. 03062 * 03063 * If @a expiration_date is zero, then create a non-expiring lock. 03064 * Else, the lock will expire at @a expiration_date. 03065 * 03066 * For each path in @a lock_targets @a lock_callback will be invoked 03067 * passing @a lock_baton and the lock and error that apply to path. 03068 * @a lock_callback can be NULL in which case it is not called and any 03069 * errors that would have been passed to the callback are not reported. 03070 * 03071 * The lock and path passed to @a lock_callback will be allocated in 03072 * @a result_pool. Use @a scratch_pool for temporary allocations. 03073 * 03074 * @note At this time, only files can be locked. 03075 * 03076 * @note This function is not atomic. If it returns an error, some targets 03077 * may remain unlocked while others may have been locked. 03078 * 03079 * @note You probably don't want to use this directly. Take a look at 03080 * svn_repos_fs_lock_many() instead. 03081 * 03082 * @since New in 1.9. 03083 */ 03084 svn_error_t * 03085 svn_fs_lock_many(svn_fs_t *fs, 03086 apr_hash_t *lock_targets, 03087 const char *comment, 03088 svn_boolean_t is_dav_comment, 03089 apr_time_t expiration_date, 03090 svn_boolean_t steal_lock, 03091 svn_fs_lock_callback_t lock_callback, 03092 void *lock_baton, 03093 apr_pool_t *result_pool, 03094 apr_pool_t *scratch_pool); 03095 03096 /** Similar to svn_fs_lock_many() but locks only a single @a path and 03097 * returns the lock in @a *lock, allocated in @a pool, or an error. 03098 * 03099 * @since New in 1.2. 03100 */ 03101 svn_error_t * 03102 svn_fs_lock(svn_lock_t **lock, 03103 svn_fs_t *fs, 03104 const char *path, 03105 const char *token, 03106 const char *comment, 03107 svn_boolean_t is_dav_comment, 03108 apr_time_t expiration_date, 03109 svn_revnum_t current_rev, 03110 svn_boolean_t steal_lock, 03111 apr_pool_t *pool); 03112 03113 03114 /** Generate a unique lock-token using @a fs. Return in @a *token, 03115 * allocated in @a pool. 03116 * 03117 * This can be used in to populate lock->token before calling 03118 * svn_fs_attach_lock(). 03119 */ 03120 svn_error_t * 03121 svn_fs_generate_lock_token(const char **token, 03122 svn_fs_t *fs, 03123 apr_pool_t *pool); 03124 03125 03126 /** Remove the locks on the paths in @a unlock_targets in @a fs. 03127 * 03128 * The paths to be unlocked are passed as <tt>const char *</tt> keys 03129 * of the @a unlock_targets hash with the corresponding lock tokens as 03130 * <tt>const char *</tt> values. If the token doesn't point to a 03131 * lock, yield an #SVN_ERR_FS_BAD_LOCK_TOKEN error for this path. If 03132 * the token points to an expired lock, yield an 03133 * #SVN_ERR_FS_LOCK_EXPIRED error for this path. If @a fs has no 03134 * username associated with it, yield an #SVN_ERR_FS_NO_USER unless @a 03135 * break_lock is specified. 03136 * 03137 * If the token points to a lock, but the username of @a fs's access 03138 * context doesn't match the lock's owner, yield an 03139 * #SVN_ERR_FS_LOCK_OWNER_MISMATCH. If @a break_lock is TRUE, 03140 * however, don't return error; allow the lock to be "broken" in any 03141 * case. In the latter case, the token shall be @c NULL. 03142 * 03143 * For each path in @a unlock_targets @a lock_callback will be invoked 03144 * passing @a lock_baton and error that apply to path. The @a lock 03145 * passed to the callback will be NULL. @a lock_callback can be NULL 03146 * in which case it is not called and any errors that would have been 03147 * passed to the callback are not reported. 03148 * 03149 * The path passed to lock_callback will be allocated in @a result_pool. 03150 * Use @a scratch_pool for temporary allocations. 03151 * 03152 * @note This function is not atomic. If it returns an error, some targets 03153 * may remain locked while others may have been unlocked. 03154 * 03155 * @note You probably don't want to use this directly. Take a look at 03156 * svn_repos_fs_unlock_many() instead. 03157 * 03158 * @since New in 1.9. 03159 */ 03160 svn_error_t * 03161 svn_fs_unlock_many(svn_fs_t *fs, 03162 apr_hash_t *unlock_targets, 03163 svn_boolean_t break_lock, 03164 svn_fs_lock_callback_t lock_callback, 03165 void *lock_baton, 03166 apr_pool_t *result_pool, 03167 apr_pool_t *scratch_pool); 03168 03169 /** Similar to svn_fs_unlock_many() but only unlocks a single path. 03170 * 03171 * @since New in 1.2. 03172 */ 03173 svn_error_t * 03174 svn_fs_unlock(svn_fs_t *fs, 03175 const char *path, 03176 const char *token, 03177 svn_boolean_t break_lock, 03178 apr_pool_t *pool); 03179 03180 03181 /** If @a path is locked in @a fs, set @a *lock to an svn_lock_t which 03182 * represents the lock, allocated in @a pool. 03183 * 03184 * If @a path is not locked or does not exist in HEAD, set @a *lock to NULL. 03185 */ 03186 svn_error_t * 03187 svn_fs_get_lock(svn_lock_t **lock, 03188 svn_fs_t *fs, 03189 const char *path, 03190 apr_pool_t *pool); 03191 03192 03193 /** The type of a lock discovery callback function. @a baton is the 03194 * value specified in the call to svn_fs_get_locks(); the filesystem 03195 * passes it through to the callback. @a lock is a lock structure. 03196 * @a pool is a temporary subpool for use by the callback 03197 * implementation -- it is cleared after invocation of the callback. 03198 */ 03199 typedef svn_error_t *(*svn_fs_get_locks_callback_t)(void *baton, 03200 svn_lock_t *lock, 03201 apr_pool_t *pool); 03202 03203 03204 /** Report locks on or below @a path in @a fs using the @a 03205 * get_locks_func / @a get_locks_baton. Use @a pool for necessary 03206 * allocations. 03207 * 03208 * @a depth limits the reported locks to those associated with paths 03209 * within the specified depth of @a path, and must be one of the 03210 * following values: #svn_depth_empty, #svn_depth_files, 03211 * #svn_depth_immediates, or #svn_depth_infinity. 03212 * 03213 * If the @a get_locks_func callback implementation returns an error, 03214 * lock iteration will terminate and that error will be returned by 03215 * this function. 03216 * 03217 * @note Over the course of this function's invocation, locks might be 03218 * added, removed, or modified by concurrent processes. Callers need 03219 * to anticipate and gracefully handle the transience of this 03220 * information. 03221 * 03222 * @since New in 1.7. 03223 */ 03224 svn_error_t * 03225 svn_fs_get_locks2(svn_fs_t *fs, 03226 const char *path, 03227 svn_depth_t depth, 03228 svn_fs_get_locks_callback_t get_locks_func, 03229 void *get_locks_baton, 03230 apr_pool_t *pool); 03231 03232 /** Similar to svn_fs_get_locks2(), but with @a depth always passed as 03233 * svn_depth_infinity, and with the following known problem (which is 03234 * not present in svn_fs_get_locks2()): 03235 * 03236 * @note On Berkeley-DB-backed filesystems in Subversion 1.6 and 03237 * prior, the @a get_locks_func callback will be invoked from within a 03238 * Berkeley-DB transaction trail. Implementors of the callback are, 03239 * as a result, forbidden from calling any svn_fs API functions which 03240 * might themselves attempt to start a new Berkeley DB transaction 03241 * (which is most of this svn_fs API). Yes, this is a nasty 03242 * implementation detail to have to be aware of. 03243 * 03244 * @deprecated Provided for backward compatibility with the 1.6 API. 03245 */ 03246 SVN_DEPRECATED 03247 svn_error_t * 03248 svn_fs_get_locks(svn_fs_t *fs, 03249 const char *path, 03250 svn_fs_get_locks_callback_t get_locks_func, 03251 void *get_locks_baton, 03252 apr_pool_t *pool); 03253 03254 /** @} */ 03255 03256 /** 03257 * Append a textual list of all available FS modules to the stringbuf 03258 * @a output. Third-party modules are only included if repository 03259 * access has caused them to be loaded. 03260 * 03261 * @since New in 1.2. 03262 */ 03263 svn_error_t * 03264 svn_fs_print_modules(svn_stringbuf_t *output, 03265 apr_pool_t *pool); 03266 03267 03268 /** The kind of action being taken by 'pack'. */ 03269 typedef enum svn_fs_pack_notify_action_t 03270 { 03271 /** packing of the shard has commenced */ 03272 svn_fs_pack_notify_start = 0, 03273 03274 /** packing of the shard is completed */ 03275 svn_fs_pack_notify_end, 03276 03277 /** packing of the shard revprops has commenced 03278 @since New in 1.7. */ 03279 svn_fs_pack_notify_start_revprop, 03280 03281 /** packing of the shard revprops has completed 03282 @since New in 1.7. */ 03283 svn_fs_pack_notify_end_revprop, 03284 03285 /** pack has been a no-op for this repository. The next / future packable 03286 shard will be given. If the shard is -1, then the repository does not 03287 support packing at all. 03288 @since New in 1.10. */ 03289 svn_fs_pack_notify_noop 03290 03291 } svn_fs_pack_notify_action_t; 03292 03293 /** The type of a pack notification function. @a shard is the shard being 03294 * acted upon; @a action is the type of action being performed. @a baton is 03295 * the corresponding baton for the notification function, and @a pool can 03296 * be used for temporary allocations, but will be cleared between invocations. 03297 */ 03298 typedef svn_error_t *(*svn_fs_pack_notify_t)(void *baton, 03299 apr_int64_t shard, 03300 svn_fs_pack_notify_action_t action, 03301 apr_pool_t *pool); 03302 03303 /** 03304 * Possibly update the filesystem located in the directory @a path 03305 * to use disk space more efficiently. 03306 * 03307 * @since New in 1.6. 03308 */ 03309 svn_error_t * 03310 svn_fs_pack(const char *db_path, 03311 svn_fs_pack_notify_t notify_func, 03312 void *notify_baton, 03313 svn_cancel_func_t cancel_func, 03314 void *cancel_baton, 03315 apr_pool_t *pool); 03316 03317 03318 /** 03319 * Perform backend-specific data consistency and correctness validations 03320 * to the Subversion filesystem (mainly the meta-data) located in the 03321 * directory @a path. Use the backend-specific configuration @a fs_config 03322 * when opening the filesystem. @a NULL is valid for all backends. 03323 * Use @a scratch_pool for temporary allocations. 03324 * 03325 * @a start and @a end define the (minimum) range of revisions to check. 03326 * If @a start is #SVN_INVALID_REVNUM, it defaults to @c r0. Likewise, 03327 * @a end will default to the current youngest repository revision when 03328 * given as #SVN_INVALID_REVNUM. Since meta data checks may have to touch 03329 * other revisions as well, you may receive notifications for revisions 03330 * outside the specified range. In fact, it is perfectly legal for a FS 03331 * implementation to always check all revisions. 03332 * 03333 * Global invariants are only guaranteed to get verified when @a r0 has 03334 * been included in the range of revisions to check. 03335 * 03336 * The optional @a notify_func callback is only a general feedback that 03337 * the operation is still in process but may be called in random revisions 03338 * order and more than once for the same revision, i.e. r2, r1, r2 would 03339 * be a valid sequence. 03340 * 03341 * The optional @a cancel_func callback will be invoked as usual to allow 03342 * the user to preempt this potentially lengthy operation. 03343 * 03344 * @note You probably don't want to use this directly. Take a look at 03345 * svn_repos_verify_fs2() instead, which does non-backend-specific 03346 * verifications as well. 03347 * 03348 * @note To ensure a full verification using all tests and covering all 03349 * revisions, you must call this function *and* #svn_fs_verify_root. 03350 * 03351 * @note Implementors, please do tests that can be done efficiently for 03352 * a single revision in #svn_fs_verify_root. This function is meant for 03353 * global checks or tests that require an expensive context setup. 03354 * 03355 * @see svn_repos_verify_fs2() 03356 * @see svn_fs_verify_root() 03357 * 03358 * @since New in 1.8. 03359 */ 03360 svn_error_t * 03361 svn_fs_verify(const char *path, 03362 apr_hash_t *fs_config, 03363 svn_revnum_t start, 03364 svn_revnum_t end, 03365 svn_fs_progress_notify_func_t notify_func, 03366 void *notify_baton, 03367 svn_cancel_func_t cancel_func, 03368 void *cancel_baton, 03369 apr_pool_t *scratch_pool); 03370 03371 /** 03372 * Perform backend-specific data consistency and correctness validations 03373 * of @a root in the Subversion filesystem @a fs. @a root is typically 03374 * a revision root (see svn_fs_revision_root()), but may be a 03375 * transaction root. Use @a scratch_pool for temporary allocations. 03376 * 03377 * @note You probably don't want to use this directly. Take a look at 03378 * svn_repos_verify_fs2() instead, which does non-backend-specific 03379 * verifications as well. 03380 * 03381 * @note To ensure a full verification using all available tests and 03382 * covering all revisions, you must call both this function and 03383 * #svn_fs_verify. 03384 * 03385 * @note Implementors, please perform tests that cannot be done 03386 * efficiently for a single revision in #svn_fs_verify. This function 03387 * is intended for local checks that don't require an expensive context 03388 * setup. 03389 * 03390 * @see svn_repos_verify_fs2() 03391 * @see svn_fs_verify() 03392 * 03393 * @since New in 1.8. 03394 */ 03395 svn_error_t * 03396 svn_fs_verify_root(svn_fs_root_t *root, 03397 apr_pool_t *scratch_pool); 03398 03399 /** @} */ 03400 03401 /** 03402 * @defgroup fs_info Filesystem information subsystem 03403 * @{ 03404 */ 03405 03406 /** 03407 * A structure that provides some information about a filesystem. 03408 * Returned by svn_fs_info() for #SVN_FS_TYPE_FSFS filesystems. 03409 * 03410 * @note Fields may be added to the end of this structure in future 03411 * versions. Therefore, users shouldn't allocate structures of this 03412 * type, to preserve binary compatibility. 03413 * 03414 * @since New in 1.9. 03415 */ 03416 typedef struct svn_fs_fsfs_info_t { 03417 03418 /** Filesystem backend (#fs_type), i.e., the string #SVN_FS_TYPE_FSFS. */ 03419 const char *fs_type; 03420 03421 /** Shard size, or 0 if the filesystem is not currently sharded. */ 03422 int shard_size; 03423 03424 /** The smallest revision (as #svn_revnum_t) which is not in a pack file. 03425 * @note Zero (0) if (but not iff) the format does not support packing. */ 03426 svn_revnum_t min_unpacked_rev; 03427 03428 /** TRUE if logical addressing is enabled for this repository. 03429 * FALSE if repository uses physical addressing. */ 03430 svn_boolean_t log_addressing; 03431 /* ### TODO: information about fsfs.conf? rep-cache.db? write locks? */ 03432 03433 /* If you add fields here, check whether you need to extend svn_fs_info() 03434 or svn_fs_info_dup(). */ 03435 } svn_fs_fsfs_info_t; 03436 03437 /** 03438 * A structure that provides some information about a filesystem. 03439 * Returned by svn_fs_info() for #SVN_FS_TYPE_FSX filesystems. 03440 * 03441 * @note Fields may be added to the end of this structure in future 03442 * versions. Therefore, users shouldn't allocate structures of this 03443 * type, to preserve binary compatibility. 03444 * 03445 * @since New in 1.9. 03446 */ 03447 typedef struct svn_fs_fsx_info_t { 03448 03449 /** Filesystem backend (#fs_type), i.e., the string #SVN_FS_TYPE_FSX. */ 03450 const char *fs_type; 03451 03452 /** Shard size, always > 0. */ 03453 int shard_size; 03454 03455 /** The smallest revision which is not in a pack file. */ 03456 svn_revnum_t min_unpacked_rev; 03457 03458 /* If you add fields here, check whether you need to extend svn_fs_info() 03459 or svn_fs_info_dup(). */ 03460 03461 } svn_fs_fsx_info_t; 03462 03463 /** @see svn_fs_info 03464 * @since New in 1.9. */ 03465 typedef struct svn_fs_info_placeholder_t { 03466 /** @see svn_fs_type */ 03467 const char *fs_type; 03468 03469 /* Do not add new fields here, to maintain compatibility with the first 03470 released version of svn_fs_fsfs_info_t. */ 03471 } svn_fs_info_placeholder_t; 03472 03473 /** 03474 * Set @a *fs_info to a struct describing @a fs. The type of the 03475 * struct depends on the backend: for #SVN_FS_TYPE_FSFS, the struct will be 03476 * of type #svn_fs_fsfs_info_t; for #SVN_FS_TYPE_FSX, it will be of type 03477 * #svn_fs_fsx_info_t; otherwise, the struct is guaranteed to be 03478 * (compatible with) #svn_fs_info_placeholder_t. 03479 * 03480 * @see #svn_fs_fsfs_info_t, #svn_fs_fsx_info_t 03481 * 03482 * @since New in 1.9. 03483 */ 03484 svn_error_t * 03485 svn_fs_info(const svn_fs_info_placeholder_t **fs_info, 03486 svn_fs_t *fs, 03487 apr_pool_t *result_pool, 03488 apr_pool_t *scratch_pool); 03489 03490 /** 03491 * Return a duplicate of @a info, allocated in @a result_pool. The returned 03492 * struct will be of the same type as the passed-in struct, which itself 03493 * must have been returned from svn_fs_info() or svn_fs_info_dup(). No part 03494 * of the new structure will be shared with @a info (except static string 03495 * constants). Use @a scratch_pool for temporary allocations. 03496 * 03497 * @see #svn_fs_info_placeholder_t, #svn_fs_fsfs_info_t 03498 * 03499 * @since New in 1.9. 03500 */ 03501 void * 03502 svn_fs_info_dup(const void *info, 03503 apr_pool_t *result_pool, 03504 apr_pool_t *scratch_pool); 03505 03506 /** @} */ 03507 03508 #ifdef __cplusplus 03509 } 03510 #endif /* __cplusplus */ 03511 03512 #endif /* SVN_FS_H */
1.6.1