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