00001 /** 00002 * @copyright 00003 * ==================================================================== 00004 * Copyright (c) 2000-2004 CollabNet. All rights reserved. 00005 * 00006 * This software is licensed as described in the file COPYING, which 00007 * you should have received as part of this distribution. The terms 00008 * are also available at http://subversion.tigris.org/license-1.html. 00009 * If newer versions of this license are posted there, you may use a 00010 * newer version instead, at your option. 00011 * 00012 * This software consists of voluntary contributions made by many 00013 * individuals. For exact contribution history, see the revision 00014 * history and logs, available at http://subversion.tigris.org/. 00015 * ==================================================================== 00016 * @endcopyright 00017 * 00018 * @file svn_fs.h 00019 * @brief Interface to the Subversion filesystem. 00020 */ 00021 00022 00023 #ifndef SVN_FS_H 00024 #define SVN_FS_H 00025 00026 #include <apr_pools.h> 00027 #include <apr_hash.h> 00028 #include <apr_tables.h> 00029 #include "svn_types.h" 00030 #include "svn_error.h" 00031 #include "svn_delta.h" 00032 #include "svn_io.h" 00033 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif /* __cplusplus */ 00038 00039 00040 /** 00041 * Get libsvn_fs version information. 00042 * @since New in 1.1. 00043 */ 00044 const svn_version_t *svn_fs_version (void); 00045 00046 00047 /* Opening and creating filesystems. */ 00048 00049 00050 /** An object representing a Subversion filesystem. */ 00051 typedef struct svn_fs_t svn_fs_t; 00052 00053 00054 /** Filesystem configuration options. */ 00055 #define SVN_FS_CONFIG_BDB_TXN_NOSYNC "bdb-txn-nosync" 00056 #define SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE "bdb-log-autoremove" 00057 00058 /* @since New in 1.1. */ 00059 #define SVN_FS_CONFIG_FS_TYPE "fs-type" 00060 /* @since New in 1.1. */ 00061 #define SVN_FS_TYPE_BDB "bdb" 00062 /* @since New in 1.1. */ 00063 #define SVN_FS_TYPE_FSFS "fsfs" 00064 00065 00066 /** The type of a warning callback function. @a baton is the value specified 00067 * in the call to @c svn_fs_set_warning_func; the filesystem passes it through 00068 * to the callback. @a err contains the warning message. 00069 * 00070 * The callback function should not clear the error that is passed to it; 00071 * its caller should do that. 00072 */ 00073 typedef void (*svn_fs_warning_callback_t) (void *baton, svn_error_t *err); 00074 00075 00076 /** Provide a callback function, @a warning, that @a fs should use to 00077 * report (non-fatal) errors. To print an error, the filesystem will call 00078 * @a warning, passing it @a warning_baton and the error. 00079 * 00080 * By default, this is set to a function that will crash the process. 00081 * Dumping to @c stderr or <tt>/dev/tty</tt> is not acceptable default 00082 * behavior for server processes, since those may both be equivalent to 00083 * <tt>/dev/null</tt>. 00084 */ 00085 void svn_fs_set_warning_func (svn_fs_t *fs, 00086 svn_fs_warning_callback_t warning, 00087 void *warning_baton); 00088 00089 00090 00091 00092 /** 00093 * @since New in 1.1. 00094 * 00095 * Create a new, empty Subversion filesystem, stored in the directory 00096 * @a path, and return a pointer to it in @a *fs_p. @a path must not 00097 * currently exist, but its parent must exist. If @a fs_config is not 00098 * @c NULL, the options it contains modify the behavior of the 00099 * filesystem. The interpretation of @a fs_config is specific to the 00100 * filesystem back-end. The new filesystem may be closed by 00101 * destroying @a pool. 00102 * 00103 * @note The lifetime of @a fs_config must not be shorter than @a 00104 * pool's. It's a good idea to allocate @a fs_config from @a pool or 00105 * one of its ancestors. 00106 * 00107 * If @a fs_config contains a value for @c SVN_FS_CONFIG_FS_TYPE, that 00108 * value determines the filesystem type for the new filesystem. 00109 * Currently defined values are: 00110 * 00111 * SVN_FS_TYPE_BDB Berkeley-DB implementation 00112 * SVN_FS_TYPE_FSFS Native-filesystem implementation 00113 * 00114 * Otherwise, the BDB filesystem type is assumed. Once the filesystem 00115 * is created, its type will be recorded so that other functions will 00116 * know how to operate on it. 00117 */ 00118 svn_error_t *svn_fs_create (svn_fs_t **fs_p, const char *path, 00119 apr_hash_t *fs_config, apr_pool_t *pool); 00120 00121 /** 00122 * @since New in 1.1. 00123 * 00124 * Open a Subversion filesystem located in the directory @a path, and 00125 * return a pointer to it in @a *fs_p. If @a fs_config is not @c 00126 * NULL, the options it contains modify the behavior of the 00127 * filesystem. The interpretation of @a fs_config is specific to the 00128 * filesystem back-end. The opened filesystem may be closed by 00129 * destroying @a pool. 00130 * 00131 * @note The lifetime of @a fs_config must not be shorter than @a 00132 * pool's. It's a good idea to allocate @a fs_config from @a pool or 00133 * one of its ancestors. 00134 * 00135 * Only one thread may operate on any given filesystem object at once. 00136 * Two threads may access the same filesystem simultaneously only if 00137 * they open separate filesystem objects. 00138 * 00139 * NOTE: you probably don't want to use this directly. Take a look at 00140 * @c svn_repos_open() instead. 00141 */ 00142 svn_error_t *svn_fs_open (svn_fs_t **fs_p, const char *path, 00143 apr_hash_t *config, apr_pool_t *pool); 00144 00145 /** 00146 * @since New in 1.1. 00147 * 00148 * Return the path to @a fs's repository, allocated in @a pool. 00149 * Note: this is just what was passed to @c svn_fs_create() or 00150 * @a svn_fs_open() -- might be absolute, might not. 00151 */ 00152 const char *svn_fs_path (svn_fs_t *fs, apr_pool_t *pool); 00153 00154 /** 00155 * @since New in 1.1. 00156 * 00157 * Delete the filesystem at @a path. */ 00158 svn_error_t *svn_fs_delete_fs (const char *path, apr_pool_t *pool); 00159 00160 /** 00161 * @since New in 1.1. 00162 * 00163 * Copy a possibly live Subversion filesystem from @a src_path to 00164 * @a dest_path. If @a clean is @c TRUE, perform cleanup on the 00165 * source filesystem as part of the copy operation; currently, this 00166 * means deleting copied, unused logfiles for a Berkeley DB source 00167 * filesystem. 00168 */ 00169 svn_error_t *svn_fs_hotcopy (const char *src_path, const char *dest_path, 00170 svn_boolean_t clean, apr_pool_t *pool); 00171 00172 /** Subversion filesystems based on Berkeley DB. 00173 * 00174 * The following functions are specific to Berkeley DB filesystems. 00175 * 00176 * @defgroup svn_fs_bdb berkeley db filesystems 00177 * @{ 00178 */ 00179 00180 /** Register an error handling function for Berkeley DB error messages. 00181 * If a Berkeley DB error occurs, the filesystem will call @a handler 00182 * with two strings: an error message prefix, which will be zero, and 00183 * an error message. @a handler should print it out, log it somewhere, 00184 * etc. 00185 * 00186 * Since Berkeley DB's error messages are sometimes much more 00187 * informative than the error codes the functions return, it's worth 00188 * calling this function and providing some kind of error message 00189 * handler. 00190 * 00191 * This function calls @c DBENV->set_errcall, with @a handler as the 00192 * @c db_errcall_fcn argument. 00193 */ 00194 svn_error_t *svn_fs_set_berkeley_errcall (svn_fs_t *fs, 00195 void (*handler) (const char *errpfx, 00196 char *msg)); 00197 00198 /** Perform any necessary non-catastrophic recovery on a Berkeley 00199 * DB-based Subversion filesystem, stored in the environment @a path. 00200 * Do any necessary allocation within @a pool. 00201 * 00202 * After an unexpected server exit, due to a server crash or a system 00203 * crash, a Subversion filesystem based on Berkeley DB needs to run 00204 * recovery procedures to bring the database back into a consistent 00205 * state and release any locks that were held by the deceased process. 00206 * The recovery procedures require exclusive access to the database 00207 * --- while they execute, no other process or thread may access the 00208 * database. 00209 * 00210 * In a server with multiple worker processes, like Apache, if a 00211 * worker process accessing the filesystem dies, you must stop the 00212 * other worker processes, and run recovery. Then, the other worker 00213 * processes can re-open the database and resume work. 00214 * 00215 * If the server exited cleanly, there is no need to run recovery, but 00216 * there is no harm in it, either, and it take very little time. So 00217 * it's a fine idea to run recovery when the server process starts, 00218 * before it begins handling any requests. 00219 */ 00220 svn_error_t *svn_fs_berkeley_recover (const char *path, 00221 apr_pool_t *pool); 00222 00223 00224 /** Set @a *logfiles to array of <tt>const char *</tt> log file names 00225 * of Berkeley DB-based Subversion filesystem. 00226 * 00227 * If @a only_unused is used is @c TRUE, @a *logfiles will contain 00228 * only the names of Berkeley DB log files still in use by the 00229 * filesystem. Otherwise, all log files (used and unused) are returned. 00230 * 00231 * This function wraps the Berkeley DB 'log_archive' function 00232 * called by the db_archive binary. Repository administrators may 00233 * want to run this function periodically and delete the unused log 00234 * files, as a way of reclaiming disk space. 00235 */ 00236 svn_error_t *svn_fs_berkeley_logfiles (apr_array_header_t **logfiles, 00237 const char *path, 00238 svn_boolean_t only_unused, 00239 apr_pool_t *pool); 00240 00241 00242 /** 00243 * The following functions are similar to their generic counterparts, 00244 * but only work on Berkeley DB filesystems. 00245 * 00246 * @defgroup svn_fs_bdb_deprecated berkeley db filesystem compatibility 00247 * @{ 00248 */ 00249 00250 /** @deprecated Provided for backward compatibility with the 1.0.0 API. */ 00251 svn_fs_t *svn_fs_new (apr_hash_t *fs_config, apr_pool_t *pool); 00252 00253 /** @deprecated Provided for backward compatibility with the 1.0.0 API. */ 00254 svn_error_t *svn_fs_create_berkeley (svn_fs_t *fs, const char *path); 00255 00256 /** @deprecated Provided for backward compatibility with the 1.0.0 API. */ 00257 svn_error_t *svn_fs_open_berkeley (svn_fs_t *fs, const char *path); 00258 00259 /** @deprecated Provided for backward compatibility with the 1.0.0 API. */ 00260 const char *svn_fs_berkeley_path (svn_fs_t *fs, apr_pool_t *pool); 00261 00262 /** @deprecated Provided for backward compatibility with the 1.0.0 API. */ 00263 svn_error_t *svn_fs_delete_berkeley (const char *path, apr_pool_t *pool); 00264 00265 /** @deprecated Provided for backward compatibility with the 1.0.0 API. */ 00266 svn_error_t *svn_fs_hotcopy_berkeley (const char *src_path, 00267 const char *dest_path, 00268 svn_boolean_t clean_logs, 00269 apr_pool_t *pool); 00270 /** @} */ 00271 00272 /** @} */ 00273 00274 00275 /** Filesystem Nodes. 00276 * 00277 * In a Subversion filesystem, a `node' corresponds roughly to an 00278 * `inode' in a Unix filesystem: 00279 * - A node is either a file or a directory. 00280 * - A node's contents change over time. 00281 * - When you change a node's contents, it's still the same node; it's 00282 * just been changed. So a node's identity isn't bound to a specific 00283 * set of contents. 00284 * - If you rename a node, it's still the same node, just under a 00285 * different name. So a node's identity isn't bound to a particular 00286 * filename. 00287 * 00288 * A `node revision' refers to a node's contents at a specific point in 00289 * time. Changing a node's contents always creates a new revision of that 00290 * node. Once created, a node revision's contents never change. 00291 * 00292 * When we create a node, its initial contents are the initial revision of 00293 * the node. As users make changes to the node over time, we create new 00294 * revisions of that same node. When a user commits a change that deletes 00295 * a file from the filesystem, we don't delete the node, or any revision 00296 * of it --- those stick around to allow us to recreate prior revisions of 00297 * the filesystem. Instead, we just remove the reference to the node 00298 * from the directory. 00299 * 00300 * @defgroup svn_fs_nodes filesystem nodes 00301 * @{ 00302 */ 00303 00304 /** An object representing a node-id. */ 00305 typedef struct svn_fs_id_t svn_fs_id_t; 00306 00307 00308 /** Return -1, 0, or 1 if node revisions @a a and @a B are unrelated, 00309 * equivalent, or otherwise related (respectively). 00310 */ 00311 int svn_fs_compare_ids (const svn_fs_id_t *a, const svn_fs_id_t *b); 00312 00313 00314 00315 /** Return non-zero IFF the nodes associated with @a id1 and @a id2 are 00316 * related, else return zero. 00317 */ 00318 svn_boolean_t svn_fs_check_related (const svn_fs_id_t *id1, 00319 const svn_fs_id_t *id2); 00320 00321 00322 /** @deprecated Provided for backward compatibility with the 1.0.0 API. 00323 * 00324 * NOTE: This function is not guaranteed to work with all filesystem 00325 * types. There is currently no un-deprecated equivalent; contact the 00326 * Subversion developers if you have a need for it. 00327 */ 00328 svn_fs_id_t *svn_fs_parse_id (const char *data, 00329 apr_size_t len, 00330 apr_pool_t *pool); 00331 00332 00333 /** Return a Subversion string containing the unparsed form of the 00334 * node or node revision id @a id. Allocate the string containing the 00335 * unparsed form in @a pool. 00336 */ 00337 svn_string_t *svn_fs_unparse_id (const svn_fs_id_t *id, 00338 apr_pool_t *pool); 00339 00340 /** @} */ 00341 00342 00343 /** Filesystem Transactions. 00344 * 00345 * To make a change to a Subversion filesystem: 00346 * - Create a transaction object, using @c svn_fs_begin_txn. 00347 * - Call @c svn_fs_txn_root, to get the transaction's root directory. 00348 * - Make whatever changes you like in that tree. 00349 * - Commit the transaction, using @c svn_fs_commit_txn. 00350 * 00351 * The filesystem implementation guarantees that your commit will 00352 * either: 00353 * - succeed completely, so that all of the changes are committed to 00354 * create a new revision of the filesystem, or 00355 * - fail completely, leaving the filesystem unchanged. 00356 * 00357 * Until you commit the transaction, any changes you make are 00358 * invisible. Only when your commit succeeds do they become visible 00359 * to the outside world, as a new revision of the filesystem. 00360 * 00361 * If you begin a transaction, and then decide you don't want to make 00362 * the change after all (say, because your net connection with the 00363 * client disappeared before the change was complete), you can call 00364 * @c svn_fs_abort_txn, to cancel the entire transaction; this 00365 * leaves the filesystem unchanged. 00366 * 00367 * The only way to change the contents of files or directories, or 00368 * their properties, is by making a transaction and creating a new 00369 * revision, as described above. Once a revision has been committed, it 00370 * never changes again; the filesystem interface provides no means to 00371 * go back and edit the contents of an old revision. Once history has 00372 * been recorded, it is set in stone. Clients depend on this property 00373 * to do updates and commits reliably; proxies depend on this property 00374 * to cache changes accurately; and so on. 00375 * 00376 * There are two kinds of nodes in the filesystem: mutable, and 00377 * immutable. Revisions in the filesystem consist entirely of 00378 * immutable nodes, whose contents never change. A transaction in 00379 * progress, which the user is still constructing, uses mutable nodes 00380 * for those nodes which have been changed so far, and refers to 00381 * immutable nodes from existing revisions for portions of the tree 00382 * which haven't been changed yet in that transaction. 00383 * 00384 * Immutable nodes, as part of revisions, never refer to mutable 00385 * nodes, which are part of uncommitted transactions. Mutable nodes 00386 * may refer to immutable nodes, or other mutable nodes. 00387 * 00388 * Note that the terms "immutable" and "mutable" describe whether or 00389 * not the nodes have been changed as part of a transaction --- not 00390 * the permissions on the nodes they refer to. Even if you aren't 00391 * authorized to modify the filesystem's root directory, you might be 00392 * authorized to change some descendant of the root; doing so would 00393 * create a new mutable copy of the root directory. Mutability refers 00394 * to the role of the node: part of an existing revision, or part of a 00395 * new one. This is independent of your authorization to make changes 00396 * to a given node. 00397 * 00398 * Transactions are actually persistent objects, stored in the 00399 * database. You can open a filesystem, begin a transaction, and 00400 * close the filesystem, and then a separate process could open the 00401 * filesystem, pick up the same transaction, and continue work on it. 00402 * When a transaction is successfully committed, it is removed from 00403 * the database. 00404 * 00405 * Every transaction is assigned a name. You can open a transaction 00406 * by name, and resume work on it, or find out the name of a 00407 * transaction you already have open. You can also list all the 00408 * transactions currently present in the database. 00409 * 00410 * Transaction names are guaranteed to contain only letters (upper- 00411 * and lower-case), digits, `-', and `.', from the ASCII character 00412 * set. 00413 * 00414 * @defgroup svn_fs_txns filesystem transactions 00415 * @{ 00416 */ 00417 00418 /** The type of a Subversion transaction object. */ 00419 typedef struct svn_fs_txn_t svn_fs_txn_t; 00420 00421 00422 /** Begin a new transaction on the filesystem @a fs, based on existing 00423 * revision @a rev. Set @a *txn_p to a pointer to the new transaction. 00424 * When committed, this transaction will create a new revision. 00425 * 00426 * Allocate the new transaction in @a pool; when @a pool is freed, the new 00427 * transaction will be closed (neither committed nor aborted). 00428 * 00429 *<pre> >> Note: if you're building a txn for committing, you probably << 00430 * >> don't want to call this directly. Instead, call << 00431 * >> @c svn_repos_fs_begin_txn_for_commit(), which honors the << 00432 * >> repository's hook configurations. <<</pre> 00433 */ 00434 svn_error_t *svn_fs_begin_txn (svn_fs_txn_t **txn_p, 00435 svn_fs_t *fs, 00436 svn_revnum_t rev, 00437 apr_pool_t *pool); 00438 00439 00440 /** Commit @a txn. 00441 * 00442 *<pre> >> Note: you usually don't want to call this directly. << 00443 * >> Instead, call @c svn_repos_fs_commit_txn(), which honors the << 00444 * >> repository's hook configurations. <<</pre> 00445 * 00446 * If the transaction conflicts with other changes committed to the 00447 * repository, return an @c SVN_ERR_FS_CONFLICT error. Otherwise, create 00448 * a new filesystem revision containing the changes made in @a txn, 00449 * storing that new revision number in @a *new_rev, and return zero. 00450 * 00451 * If @a conflict_p is non-zero, use it to provide details on any 00452 * conflicts encountered merging @a txn with the most recent committed 00453 * revisions. If a conflict occurs, set @a *conflict_p to the path of 00454 * the conflict in @a txn, with the same lifetime as @a txn; 00455 * otherwise, set @a *conflict_p to null. 00456 * 00457 * If the commit succeeds, @a txn is invalid. 00458 * 00459 * If the commit fails, @a txn is still valid; you can make more 00460 * operations to resolve the conflict, or call @c svn_fs_abort_txn to 00461 * abort the transaction. 00462 * 00463 * NOTE: Success or failure of the commit of @a txn is determined by 00464 * examining the value of @a *new_rev upon this function's return. If 00465 * the value is a valid revision number, the commit was successful, 00466 * even though a non-@c NULL function return value may indicate that 00467 * something else went wrong. 00468 */ 00469 svn_error_t *svn_fs_commit_txn (const char **conflict_p, 00470 svn_revnum_t *new_rev, 00471 svn_fs_txn_t *txn, 00472 apr_pool_t *pool); 00473 00474 00475 /** Abort the transaction @a txn. Any changes made in @a txn are 00476 * discarded, and the filesystem is left unchanged. Use @a pool for 00477 * any necessary allocations. 00478 * 00479 * Use @a pool for any necessary allocations. 00480 * 00481 * NOTE: This function first sets the state of the transaction to 00482 * "dead", and then attempts to the purge the txn and any related data 00483 * from the filesystem. If some part of the cleanup process fails, 00484 * the transaction and some portion of its data may remain in the 00485 * database after this function returns. Use @c svn_fs_purge_txn() to 00486 * retry the transaction cleanup. 00487 */ 00488 svn_error_t *svn_fs_abort_txn (svn_fs_txn_t *txn, 00489 apr_pool_t *pool); 00490 00491 00492 /** Cleanup the dead transaction in @a fs whose ID is @a txn_id. Use 00493 * @a pool for all allocations. If the transaction is not yet dead, 00494 * the error @c SVN_ERR_FS_TRANSACTION_NOT_DEAD is returned. (The 00495 * caller probably forgot to abort the transaction, or the cleanup 00496 * step of that abort failed for some reason.) 00497 */ 00498 svn_error_t *svn_fs_purge_txn (svn_fs_t *fs, 00499 const char *txn_id, 00500 apr_pool_t *pool); 00501 00502 00503 /** Set @a *name_p to the name of the transaction @a txn, as a 00504 * null-terminated string. Allocate the name in @a pool. 00505 */ 00506 svn_error_t *svn_fs_txn_name (const char **name_p, 00507 svn_fs_txn_t *txn, 00508 apr_pool_t *pool); 00509 00510 00511 /** Return @a txn's base revision. If @a txn's base root id is an mutable 00512 * node, return 0. 00513 */ 00514 svn_revnum_t svn_fs_txn_base_revision (svn_fs_txn_t *txn); 00515 00516 00517 00518 /** Open the transaction named @a name in the filesystem @a fs. Set @a *txn 00519 * to the transaction. 00520 * 00521 * If there is no such transaction, @c SVN_ERR_FS_NO_SUCH_TRANSACTION is 00522 * the error returned. 00523 * 00524 * Allocate the new transaction in @a pool; when @a pool is freed, the new 00525 * transaction will be closed (neither committed nor aborted). 00526 */ 00527 svn_error_t *svn_fs_open_txn (svn_fs_txn_t **txn, 00528 svn_fs_t *fs, 00529 const char *name, 00530 apr_pool_t *pool); 00531 00532 00533 /** Set @a *names_p to an array of <tt>const char *</tt> @a ids which are the 00534 * names of all the currently active transactions in the filesystem @a fs. 00535 * Allocate the array in @a pool. 00536 */ 00537 svn_error_t *svn_fs_list_transactions (apr_array_header_t **names_p, 00538 svn_fs_t *fs, 00539 apr_pool_t *pool); 00540 00541 /* Transaction properties */ 00542 00543 /** Set @a *value_p to the value of the property named @a propname on 00544 * transaction @a txn. If @a txn has no property by that name, set 00545 * @a *value_p to zero. Allocate the result in @a pool. 00546 */ 00547 svn_error_t *svn_fs_txn_prop (svn_string_t **value_p, 00548 svn_fs_txn_t *txn, 00549 const char *propname, 00550 apr_pool_t *pool); 00551 00552 00553 /** Set @a *table_p to the entire property list of transaction @a txn in 00554 * filesystem @a fs, as an APR hash table allocated in @a pool. The 00555 * resulting table maps property names to pointers to @c svn_string_t 00556 * objects containing the property value. 00557 */ 00558 svn_error_t *svn_fs_txn_proplist (apr_hash_t **table_p, 00559 svn_fs_txn_t *txn, 00560 apr_pool_t *pool); 00561 00562 00563 /** Change a transactions @a txn's property's value, or add/delete a 00564 * property. @a name is the name of the property to change, and @a value 00565 * is the new value of the property, or zero if the property should be 00566 * removed altogether. Do any necessary temporary allocation in @a pool. 00567 */ 00568 svn_error_t *svn_fs_change_txn_prop (svn_fs_txn_t *txn, 00569 const char *name, 00570 const svn_string_t *value, 00571 apr_pool_t *pool); 00572 00573 /** @} */ 00574 00575 00576 /** Roots. 00577 * 00578 * An @c svn_fs_root_t object represents the root directory of some 00579 * revision or transaction in a filesystem. To refer to particular 00580 * node, you provide a root, and a directory path relative that root. 00581 * 00582 * @defgroup svn_fs_roots filesystem roots 00583 * @{ 00584 */ 00585 00586 /** The Filesystem Root object. */ 00587 typedef struct svn_fs_root_t svn_fs_root_t; 00588 00589 00590 /** Set @a *root_p to the root directory of revision @a rev in filesystem 00591 * @a fs. Allocate @a *root_p in @a pool. 00592 */ 00593 svn_error_t *svn_fs_revision_root (svn_fs_root_t **root_p, 00594 svn_fs_t *fs, 00595 svn_revnum_t rev, 00596 apr_pool_t *pool); 00597 00598 00599 /** Set @a *root_p to the root directory of @a txn. Allocate @a *root_p in 00600 * @a pool. 00601 */ 00602 svn_error_t *svn_fs_txn_root (svn_fs_root_t **root_p, 00603 svn_fs_txn_t *txn, 00604 apr_pool_t *pool); 00605 00606 00607 /** Free the root directory @a root. Simply clearing or destroying the 00608 * pool @a root was allocated in will have the same effect as calling 00609 * this function. 00610 */ 00611 void svn_fs_close_root (svn_fs_root_t *root); 00612 00613 00614 /** Return the filesystem to which @a root belongs. */ 00615 svn_fs_t *svn_fs_root_fs (svn_fs_root_t *root); 00616 00617 00618 /** Return @c TRUE iff @a root is a transaction root. */ 00619 svn_boolean_t svn_fs_is_txn_root (svn_fs_root_t *root); 00620 00621 /** Return @c TRUE iff @a root is a revision root. */ 00622 svn_boolean_t svn_fs_is_revision_root (svn_fs_root_t *root); 00623 00624 00625 /** If @a root is the root of a transaction, return the name of the 00626 * transaction, allocated in @a pool; otherwise, return null. 00627 */ 00628 const char *svn_fs_txn_root_name (svn_fs_root_t *root, 00629 apr_pool_t *pool); 00630 00631 00632 /** If @a root is the root of a revision, return the revision number. 00633 * Otherwise, return @c SVN_INVALID_REVNUM. 00634 */ 00635 svn_revnum_t svn_fs_revision_root_revision (svn_fs_root_t *root); 00636 00637 /** @} */ 00638 00639 00640 /** Directory entry names and directory paths. 00641 * 00642 * Here are the rules for directory entry names, and directory paths: 00643 * 00644 * A directory entry name is a Unicode string encoded in UTF-8, and 00645 * may not contain the null character (U+0000). The name should be in 00646 * Unicode canonical decomposition and ordering. No directory entry 00647 * may be named '.', '..', or the empty string. Given a directory 00648 * entry name which fails to meet these requirements, a filesystem 00649 * function returns an SVN_ERR_FS_PATH_SYNTAX error. 00650 * 00651 * A directory path is a sequence of zero or more directory entry 00652 * names, separated by slash characters (U+002f), and possibly ending 00653 * with slash characters. Sequences of two or more consecutive slash 00654 * characters are treated as if they were a single slash. If a path 00655 * ends with a slash, it refers to the same node it would without the 00656 * slash, but that node must be a directory, or else the function 00657 * returns an SVN_ERR_FS_NOT_DIRECTORY error. 00658 * 00659 * A path consisting of the empty string, or a string containing only 00660 * slashes, refers to the root directory. 00661 * 00662 * @defgroup svn_fs_directories filesystem directories 00663 * @{ 00664 */ 00665 00666 00667 00668 /** The kind of change that occurred on the path. */ 00669 typedef enum 00670 { 00671 /** default value */ 00672 svn_fs_path_change_modify = 0, 00673 00674 /** path added in txn */ 00675 svn_fs_path_change_add, 00676 00677 /** path removed in txn */ 00678 svn_fs_path_change_delete, 00679 00680 /** path removed and re-added in txn */ 00681 svn_fs_path_change_replace, 00682 00683 /** ignore all previous change items for path (internal-use only) */ 00684 svn_fs_path_change_reset 00685 00686 } svn_fs_path_change_kind_t; 00687 00688 /** Change descriptor. */ 00689 typedef struct svn_fs_path_change_t 00690 { 00691 /** node revision id of changed path */ 00692 const svn_fs_id_t *node_rev_id; 00693 00694 /** kind of change (see above) */ 00695 svn_fs_path_change_kind_t change_kind; 00696 00697 /** were there text mods? */ 00698 svn_boolean_t text_mod; 00699 00700 /** were there property mods? */ 00701 svn_boolean_t prop_mod; 00702 00703 } svn_fs_path_change_t; 00704 00705 00706 /** Determine what has changed under a @a root. 00707 * 00708 * Allocate and return a hash @a *changed_paths_p containing descriptions 00709 * of the paths changed under @a root. The hash is keyed with 00710 * <tt>const char *</tt> paths, and has @c svn_fs_path_change_t * values. 00711 * Use @c pool for all allocations, including the hash and its values. 00712 */ 00713 svn_error_t *svn_fs_paths_changed (apr_hash_t **changed_paths_p, 00714 svn_fs_root_t *root, 00715 apr_pool_t *pool); 00716 00717 /** @} */ 00718 00719 00720 /* Operations appropriate to all kinds of nodes. */ 00721 00722 /** Set @a *kind_p to the type of node present at @a path under @a 00723 * root. If @a path does not exist under @a root, set @a *kind to @c 00724 * svn_node_none. Use @a pool for temporary allocation. 00725 */ 00726 svn_error_t *svn_fs_check_path (svn_node_kind_t *kind_p, 00727 svn_fs_root_t *root, 00728 const char *path, 00729 apr_pool_t *pool); 00730 00731 00732 /** An opaque node history object. */ 00733 typedef struct svn_fs_history_t svn_fs_history_t; 00734 00735 00736 /** Set @a *history_p to an opaque node history object which 00737 * represents @a path under @a root. @a root must be a revision root. 00738 * Use @a pool for all allocations. 00739 */ 00740 svn_error_t *svn_fs_node_history (svn_fs_history_t **history_p, 00741 svn_fs_root_t *root, 00742 const char *path, 00743 apr_pool_t *pool); 00744 00745 00746 /** Set @a *prev_history_t to an opaque node history object which 00747 * represents the previous (or "next oldest") interesting history 00748 * location for the filesystem node represented by @a history, or @c 00749 * NULL if no such previous history exists. If @a cross_copies is @c 00750 * FALSE, also return @c NULL if stepping backwards in history to @a 00751 * prev_history_t would cross a filesystem copy operation. 00752 * 00753 * NOTE: If this is the first call to svn_fs_history_prev() for the @a 00754 * history object, it could return a history object whose location is 00755 * the same as the original. This will happen if the original 00756 * location was an interested one (where the node was modified, or 00757 * took place in a copy event). This behavior allows looping callers 00758 * to avoid the calling svn_fs_history_location() on the object 00759 * returned by svn_fs_node_history(), and instead go ahead and begin 00760 * calling svn_fs_history_prev(). 00761 * 00762 * NOTE: This function uses node-id ancestry alone to determine 00763 * modifiedness, and therefore does NOT claim that in any of the 00764 * returned revisions file contents changed, properties changed, 00765 * directory entries lists changed, etc. 00766 * 00767 * ALSO NOTE: The revisions returned for @a path will be older than or 00768 * the same age as the revision of that path in @a root. That is, if 00769 * @a root is a revision root based on revision X, and @a path was 00770 * modified in some revision(s) younger than X, those revisions 00771 * younger than X will not be included for @a path. */ 00772 svn_error_t *svn_fs_history_prev (svn_fs_history_t **prev_history_p, 00773 svn_fs_history_t *history, 00774 svn_boolean_t cross_copies, 00775 apr_pool_t *pool); 00776 00777 00778 /** Set @a *path and @a *revision to the path and revision, 00779 * respectively, of the @a history object. Use @a pool for all 00780 * allocations. 00781 */ 00782 svn_error_t *svn_fs_history_location (const char **path, 00783 svn_revnum_t *revision, 00784 svn_fs_history_t *history, 00785 apr_pool_t *pool); 00786 00787 00788 /** Set @a *is_dir to @c TRUE iff @a path in @a root is a directory. 00789 * Do any necessary temporary allocation in @a pool. 00790 */ 00791 svn_error_t *svn_fs_is_dir (svn_boolean_t *is_dir, 00792 svn_fs_root_t *root, 00793 const char *path, 00794 apr_pool_t *pool); 00795 00796 00797 /** Set @a *is_file to @c TRUE iff @a path in @a root is a file. 00798 * Do any necessary temporary allocation in @a pool. 00799 */ 00800 svn_error_t *svn_fs_is_file (svn_boolean_t *is_file, 00801 svn_fs_root_t *root, 00802 const char *path, 00803 apr_pool_t *pool); 00804 00805 00806 /** Get the id of a node. 00807 * 00808 * Set @a *id_p to the node revision ID of @a path in @a root, allocated in 00809 * @a pool. 00810 * 00811 * If @a root is the root of a transaction, keep in mind that other 00812 * changes to the transaction can change which node @a path refers to, 00813 * and even whether the path exists at all. 00814 */ 00815 svn_error_t *svn_fs_node_id (const svn_fs_id_t **id_p, 00816 svn_fs_root_t *root, 00817 const char *path, 00818 apr_pool_t *pool); 00819 00820 /** Set @a *revision to the revision in which @a path under @a root was 00821 * created. Use @a pool for any temporary allocations. @a *revision will 00822 * be set to @c SVN_INVALID_REVNUM for uncommitted nodes (i.e. modified nodes 00823 * under a transaction root). 00824 */ 00825 svn_error_t *svn_fs_node_created_rev (svn_revnum_t *revision, 00826 svn_fs_root_t *root, 00827 const char *path, 00828 apr_pool_t *pool); 00829 00830 /** Set @a *created_path to the path at which @a path under @a root was 00831 * created. Use @a pool for all allocations. Callers may use this 00832 * function in conjunction with svn_fs_node_created_rev() perform a 00833 * reverse lookup of the mapping of (path, revision) -> node-id that 00834 * svn_fs_node_id() performs. 00835 */ 00836 svn_error_t *svn_fs_node_created_path (const char **created_path, 00837 svn_fs_root_t *root, 00838 const char *path, 00839 apr_pool_t *pool); 00840 00841 00842 /** Set @a *value_p to the value of the property named @a propname of 00843 * @a path in @a root. If the node has no property by that name, set 00844 * @a *value_p to zero. Allocate the result in @a pool. 00845 */ 00846 svn_error_t *svn_fs_node_prop (svn_string_t **value_p, 00847 svn_fs_root_t *root, 00848 const char *path, 00849 const char *propname, 00850 apr_pool_t *pool); 00851 00852 00853 /** Set @a *table_p to the entire property list of @a path in @a root, 00854 * as an APR hash table allocated in @a pool. The resulting table maps 00855 * property names to pointers to @c svn_string_t objects containing the 00856 * property value. 00857 */ 00858 svn_error_t *svn_fs_node_proplist (apr_hash_t **table_p, 00859 svn_fs_root_t *root, 00860 const char *path, 00861 apr_pool_t *pool); 00862 00863 00864 /** Change a node's property's value, or add/delete a property. 00865 * 00866 * - @a root and @a path indicate the node whose property should change. 00867 * @a root must be the root of a transaction, not the root of a revision. 00868 * - @a name is the name of the property to change. 00869 * - @a value is the new value of the property, or zero if the property should 00870 * be removed altogether. 00871 * Do any necessary temporary allocation in @a pool. 00872 */ 00873 svn_error_t *svn_fs_change_node_prop (svn_fs_root_t *root, 00874 const char *path, 00875 const char *name, 00876 const svn_string_t *value, 00877 apr_pool_t *pool); 00878 00879 00880 /** Determine if the properties of two path/root combinations are different. 00881 * 00882 * Set @a *changed_p to 1 if the properties at @a path1 under @a root1 differ 00883 * from those at @a path2 under @a root2, or set it to 0 if they are the 00884 * same. Both paths must exist under their respective roots, and both 00885 * roots must be in the same filesystem. 00886 */ 00887 svn_error_t *svn_fs_props_changed (svn_boolean_t *changed_p, 00888 svn_fs_root_t *root1, 00889 const char *path1, 00890 svn_fs_root_t *root2, 00891 const char *path2, 00892 apr_pool_t *pool); 00893 00894 00895 /** Discover a node's copy ancestry, if any. 00896 * 00897 * If the node at @a path in @a root was copied from some other node, set 00898 * @a *rev_p and @a *path_p to the revision and path of the other node, 00899 * allocating @a *path_p in @a pool. 00900 * 00901 * Else if there is no copy ancestry for the node, set @a *rev_p to 00902 * @c SVN_INVALID_REVNUM and @a *path_p to null. 00903 * 00904 * If an error is returned, the values of @a *rev_p and @a *path_p are 00905 * undefined, but otherwise, if one of them is set as described above, 00906 * you may assume the other is set correspondingly. 00907 * 00908 * @a root may be a revision root or a transaction root. 00909 * 00910 * Notes: 00911 * - Copy ancestry does not descend. After copying directory D to 00912 * E, E will have copy ancestry referring to D, but E's children 00913 * may not. See also @c svn_fs_copy(). 00914 * 00915 * - Copy ancestry *under* a copy is preserved. That is, if you 00916 * copy /A/D/G/pi to /A/D/G/pi2, and then copy /A/D/G to /G, then 00917 * /G/pi2 will still have copy ancestry pointing to /A/D/G/pi. 00918 * We don't know if this is a feature or a bug yet; if it turns 00919 * out to be a bug, then the fix is to make @c svn_fs_copied_from() 00920 * observe the following logic, which currently callers may 00921 * choose to follow themselves: if node X has copy history, but 00922 * its ancestor A also has copy history, then you may ignore X's 00923 * history if X's revision-of-origin is earlier than A's -- 00924 * because that would mean that X's copy history was preserved in 00925 * a copy-under-a-copy scenario. If X's revision-of-origin is 00926 * the same as A's, then it was copied under A during the same 00927 * transaction that created A. (X's revision-of-origin cannot be 00928 * greater than A's, if X has copy history.) ### todo: See how 00929 * people like this, it can always be hidden behind the curtain 00930 * if necessary. 00931 * 00932 * - Copy ancestry is not stored as a regular subversion property 00933 * because it is not inherited. Copying foo to bar results in a 00934 * revision of bar with copy ancestry; but committing a text 00935 * change to bar right after that results in a new revision of 00936 * bar without copy ancestry. 00937 */ 00938 svn_error_t *svn_fs_copied_from (svn_revnum_t *rev_p, 00939 const char **path_p, 00940 svn_fs_root_t *root, 00941 const char *path, 00942 apr_pool_t *pool); 00943 00944 00945 /** Merge changes between two nodes into a third node. 00946 * 00947 * Given nodes @a source and @a target, and a common ancestor @a ancestor, 00948 * modify @a target to contain all the changes made between @a ancestor and 00949 * @a source, as well as the changes made between @a ancestor and @a target. 00950 * @a target_root must be the root of a transaction, not a revision. 00951 * 00952 * @a source, @a target, and @a ancestor are generally directories; this 00953 * function recursively merges the directories' contents. If they are 00954 * files, this function simply returns an error whenever @a source, 00955 * @a target, and @a ancestor are all distinct node revisions. 00956 * 00957 * If there are differences between @a ancestor and @a source that conflict 00958 * with changes between @a ancestor and @a target, this function returns an 00959 * @c SVN_ERR_FS_CONFLICT error. 00960 * 00961 * If the merge is successful, @a target is left in the merged state, and 00962 * the base root of @a target's txn is set to the root node of @a source. 00963 * If an error is returned (whether for conflict or otherwise), @a target 00964 * is left unaffected. 00965 * 00966 * If @a conflict_p is non-null, then: a conflict error sets @a *conflict_p 00967 * to the name of the node in @a target which couldn't be merged, 00968 * otherwise, success sets @a *conflict_p to null. 00969 * 00970 * Do any necessary temporary allocation in @a pool. 00971 */ 00972 svn_error_t *svn_fs_merge (const char **conflict_p, 00973 svn_fs_root_t *source_root, 00974 const char *source_path, 00975 svn_fs_root_t *target_root, 00976 const char *target_path, 00977 svn_fs_root_t *ancestor_root, 00978 const char *ancestor_path, 00979 apr_pool_t *pool); 00980 00981 00982 00983 /* Directories. */ 00984 00985 00986 /** The type of a Subversion directory entry. */ 00987 typedef struct svn_fs_dirent_t 00988 { 00989 00990 /** The name of this directory entry. */ 00991 const char *name; 00992 00993 /** The node revision ID it names. */ 00994 const svn_fs_id_t *id; 00995 00996 /** The node kind. */ 00997 svn_node_kind_t kind; 00998 00999 } svn_fs_dirent_t; 01000 01001 01002 /** Set @a *entries_p to a newly allocated APR hash table containing the 01003 * entries of the directory at @a path in @a root. The keys of the table 01004 * are entry names, as byte strings, excluding the final null 01005 * character; the table's values are pointers to @c svn_fs_dirent_t 01006 * structures. Allocate the table and its contents in @a pool. 01007 */ 01008 svn_error_t *svn_fs_dir_entries (apr_hash_t **entries_p, 01009 svn_fs_root_t *root, 01010 const char *path, 01011 apr_pool_t *pool); 01012 01013 01014 /** Create a new directory named @a path in @a root. The new directory has 01015 * no entries, and no properties. @a root must be the root of a transaction, 01016 * not a revision. 01017 * 01018 * Do any necessary temporary allocation in @a pool. 01019 */ 01020 svn_error_t *svn_fs_make_dir (svn_fs_root_t *root, 01021 const char *path, 01022 apr_pool_t *pool); 01023 01024 01025 /** Delete the node named @a path in @a root. If the node being deleted is 01026 * a directory, its contents will be deleted recursively. @a root must be 01027 * the root of a transaction, not of a revision. Use @a pool for 01028 * temporary allocation. 01029 * 01030 * This function may be more efficient than making the equivalent 01031 * series of calls to @c svn_fs_delete, because it takes advantage of the 01032 * fact that, to delete an immutable subtree, shared with some 01033 * committed revision, you need only remove the directory entry. The 01034 * dumb algorithm would recurse into the subtree and end up cloning 01035 * each non-empty directory it contains, only to delete it later. 01036 * 01037 * If return @c SVN_ERR_FS_NO_SUCH_ENTRY, then the basename of @a path is 01038 * missing from its parent, that is, the final target of the deletion 01039 * is missing. 01040 * 01041 * Attempting to remove the root dir also results in an error, 01042 * @c SVN_ERR_FS_ROOT_DIR, even if the dir is empty. 01043 */ 01044 svn_error_t *svn_fs_delete (svn_fs_root_t *root, 01045 const char *path, 01046 apr_pool_t *pool); 01047 01048 01049 /** Create a copy of @a from_path in @a from_root named @a to_path in 01050 * @a to_root. If @a from_path in @a from_root is a directory, copy the 01051 * tree it refers to recursively. 01052 * 01053 * The copy will remember its source; use @c svn_fs_copied_from() to 01054 * access this information. 01055 * 01056 * @a to_root must be the root of a transaction; @a from_path must be the 01057 * root of a revision. (Requiring @a from_path to be the root of a 01058 * revision makes the implementation trivial: there is no detectable 01059 * difference (modulo node revision ID's) between copying @a from and 01060 * simply adding a reference to it. So the operation takes place in 01061 * constant time. However, there's no reason not to extend this to 01062 * mutable nodes --- it's just more code.) Further, @a to_root and @a 01063 * from_root must represent the same filesystem. 01064 * 01065 * Note: to do a copy without preserving copy history, use 01066 * @c svn_fs_revision_link(). 01067 * 01068 * Do any necessary temporary allocation in @a pool. 01069 */ 01070 svn_error_t *svn_fs_copy (svn_fs_root_t *from_root, 01071 const char *from_path, 01072 svn_fs_root_t *to_root, 01073 const char *to_path, 01074 apr_pool_t *pool); 01075 01076 01077 /** Like @c svn_fs_copy(), but doesn't record copy history, and preserves 01078 * the PATH. You cannot use @c svn_fs_copied_from() later to find out 01079 * where this copy came from. 01080 * 01081 * Use @c svn_fs_revision_link() in situations where you don't care 01082 * about the copy history, and where @a to_path and @a from_path are 01083 * the same, because it is cheaper than @c svn_fs_copy(). 01084 */ 01085 svn_error_t *svn_fs_revision_link (svn_fs_root_t *from_root, 01086 svn_fs_root_t *to_root, 01087 const char *path, 01088 apr_pool_t *pool); 01089 01090 /* Files. */ 01091 01092 /** Set @a *length_p to the length of the file @a path in @a root, in bytes. 01093 * Do any necessary temporary allocation in @a pool. 01094 */ 01095 svn_error_t *svn_fs_file_length (svn_filesize_t *length_p, 01096 svn_fs_root_t *root, 01097 const char *path, 01098 apr_pool_t *pool); 01099 01100 01101 /** Put the MD5 checksum of file @a path into @a digest, which points 01102 * to @c APR_MD5_DIGESTSIZE bytes of storage. Use @a pool only for temporary 01103 * allocations. 01104 * 01105 * If the filesystem does not have a prerecorded checksum for @a path, 01106 * do not calculate a checksum dynamically, just put all 0's into @a 01107 * digest. (By convention, the all-zero checksum is considered to 01108 * match any checksum.) 01109 * 01110 * Notes: 01111 * 01112 * You might wonder, why do we only provide this interface for file 01113 * contents, and not for properties or directories? 01114 * 01115 * The answer is that property lists and directory entry lists are 01116 * essentially data structures, not text. We serialize them for 01117 * transmission, but there is no guarantee that the consumer will 01118 * parse them into the same form, or even the same order, as the 01119 * producer. It's difficult to find a checksumming method that 01120 * reaches the same result given such variation in input. (I suppose 01121 * we could calculate an independent MD5 sum for each propname and 01122 * value, and XOR them together; same with directory entry names. 01123 * Maybe that's the solution?) Anyway, for now we punt. The most 01124 * important data, and the only data that goes through svndiff 01125 * processing, is file contents, so that's what we provide 01126 * checksumming for. 01127 * 01128 * Internally, of course, the filesystem checksums everything, because 01129 * it has access to the lowest level storage forms: strings behind 01130 * representations. 01131 */ 01132 svn_error_t *svn_fs_file_md5_checksum (unsigned char digest[], 01133 svn_fs_root_t *root, 01134 const char *path, 01135 apr_pool_t *pool); 01136 01137 01138 /** Set @a *contents to a readable generic stream that will yield the 01139 * contents of the file @a path in @a root. Allocate the stream in 01140 * @a pool. You can only use @a *contents for as long as the underlying 01141 * filesystem is open. If @a path is not a file, return 01142 * @c SVN_ERR_FS_NOT_FILE. 01143 * 01144 * If @a root is the root of a transaction, it is possible that the 01145 * contents of the file @a path will change between calls to 01146 * @c svn_fs_file_contents(). In that case, the result of reading from 01147 * @a *contents is undefined. 01148 * 01149 * ### kff todo: I am worried about lifetime issues with this pool vs 01150 * the trail created farther down the call stack. Trace this function 01151 * to investigate... 01152 */ 01153 svn_error_t *svn_fs_file_contents (svn_stream_t **contents, 01154 svn_fs_root_t *root, 01155 const char *path, 01156 apr_pool_t *pool); 01157 01158 01159 /** Create a new file named @a path in @a root. The file's initial contents 01160 * are the empty string, and it has no properties. @a root must be the 01161 * root of a transaction, not a revision. 01162 * 01163 * Do any necessary temporary allocation in @a pool. 01164 */ 01165 svn_error_t *svn_fs_make_file (svn_fs_root_t *root, 01166 const char *path, 01167 apr_pool_t *pool); 01168 01169 01170 /** Apply a text delta to the file @a path in @a root. @a root must be the 01171 * root of a transaction, not a revision. 01172 * 01173 * Set @a *contents_p to a function ready to receive text delta windows 01174 * describing how to change the file's contents, relative to its 01175 * current contents. Set @a *contents_baton_p to a baton to pass to 01176 * @a *contents_p. 01177 * 01178 * If @a path does not exist in @a root, return an error. (You cannot use 01179 * this routine to create new files; use @c svn_fs_make_file to create 01180 * an empty file first.) 01181 * 01182 * @a base_checksum is the hex MD5 digest for the base text against 01183 * which the delta is to be applied; it is ignored if null, and may be 01184 * ignored even if not null. If it is not ignored, it must match the 01185 * checksum of the base text against which svndiff data is being 01186 * applied; if not, svn_fs_apply_textdelta or the @a *contents_p call 01187 * which detects the mismatch will return the error 01188 * @c SVN_ERR_CHECKSUM_MISMATCH (if there is no base text, there may 01189 * still be an error if @a base_checksum is neither null nor the 01190 * checksum of the empty string). 01191 * 01192 * @a result_checksum is the hex MD5 digest for the fulltext that 01193 * results from this delta application. It is ignored if null, but if 01194 * not null, it must match the checksum of the result; if it does not, 01195 * then the @a *contents_p call which detects the mismatch will return 01196 * the error @c SVN_ERR_CHECKSUM_MISMATCH. 01197 * 01198 * Do temporary allocation in @a pool. 01199 */ 01200 svn_error_t *svn_fs_apply_textdelta (svn_txdelta_window_handler_t *contents_p, 01201 void **contents_baton_p, 01202 svn_fs_root_t *root, 01203 const char *path, 01204 const char *base_checksum, 01205 const char *result_checksum, 01206 apr_pool_t *pool); 01207 01208 01209 /** Write data directly to the file @a path in @a root. @a root must be the 01210 * root of a transaction, not a revision. 01211 * 01212 * Set @a *contents_p to a stream ready to receive full textual data. 01213 * When the caller closes this stream, the data replaces the previous 01214 * contents of the file. 01215 * 01216 * If @a path does not exist in @a root, return an error. (You cannot use 01217 * this routine to create new files; use @c svn_fs_make_file to create 01218 * an empty file first.) 01219 * 01220 * @a result_checksum is the hex MD5 digest for the final fulltext 01221 * written to the stream. It is ignored if null, but if not null, it 01222 * must match the checksum of the result; if it does not, then the @a 01223 * *contents_p call which detects the mismatch will return the error 01224 * @c SVN_ERR_CHECKSUM_MISMATCH. 01225 * 01226 * Do any necessary temporary allocation in @a pool. 01227 * 01228 * ### This is like svn_fs_apply_textdelta, but takes the text 01229 * straight. It is currently used only by the loader, see 01230 * libsvn_repos/load.c. It should accept a checksum, of course, which 01231 * would come from an (optional) header in the dump file. See 01232 * http://subversion.tigris.org/issues/show_bug.cgi?id=1102 for more. 01233 */ 01234 svn_error_t *svn_fs_apply_text (svn_stream_t **contents_p, 01235 svn_fs_root_t *root, 01236 const char *path, 01237 const char *result_checksum, 01238 apr_pool_t *pool); 01239 01240 01241 /** Check if the contents of two root/path combos have changed. 01242 * 01243 * Set @a *changed_p to 1 if the contents at @a path1 under @a root1 differ 01244 * from those at @a path2 under @a root2, or set it to 0 if they are the 01245 * same. Both paths must exist under their respective roots, and both 01246 * roots must be in the same filesystem. 01247 */ 01248 svn_error_t *svn_fs_contents_changed (svn_boolean_t *changed_p, 01249 svn_fs_root_t *root1, 01250 const char *path1, 01251 svn_fs_root_t *root2, 01252 const char *path2, 01253 apr_pool_t *pool); 01254 01255 01256 01257 /* Filesystem revisions. */ 01258 01259 01260 /** Set @a *youngest_p to the number of the youngest revision in filesystem 01261 * @a fs. Use @a pool for all temporary allocation. 01262 * 01263 * The oldest revision in any filesystem is numbered zero. 01264 */ 01265 svn_error_t *svn_fs_youngest_rev (svn_revnum_t *youngest_p, 01266 svn_fs_t *fs, 01267 apr_pool_t *pool); 01268 01269 01270 /** Deltify predecessors of paths modified in @a revision in 01271 * filesystem @a fs. Use @a pool for all allocations. 01272 * 01273 * NOTE: This can be a time-consuming process, depending the breadth 01274 * of the changes made in @a revision, and the depth of the history of 01275 * those changed paths. 01276 */ 01277 svn_error_t *svn_fs_deltify_revision (svn_fs_t *fs, 01278 svn_revnum_t revision, 01279 apr_pool_t *pool); 01280 01281 01282 /** Set @a *value_p to the value of the property named @a propname on 01283 * revision @a rev in the filesystem @a fs. If @a rev has no property by 01284 * that name, set @a *value_p to zero. Allocate the result in @a pool. 01285 */ 01286 svn_error_t *svn_fs_revision_prop (svn_string_t **value_p, 01287 svn_fs_t *fs, 01288 svn_revnum_t rev, 01289 const char *propname, 01290 apr_pool_t *pool); 01291 01292 01293 /** Set @a *table_p to the entire property list of revision @a rev in 01294 * filesystem @a fs, as an APR hash table allocated in @a pool. The table 01295 * maps <tt>char *</tt> property names to @c svn_string_t * values; the names 01296 * and values are allocated in @a pool. 01297 */ 01298 svn_error_t *svn_fs_revision_proplist (apr_hash_t **table_p, 01299 svn_fs_t *fs, 01300 svn_revnum_t rev, 01301 apr_pool_t *pool); 01302 01303 01304 /** Change a revision's property's value, or add/delete a property. 01305 * 01306 * - @a fs is a filesystem, and @a rev is the revision in that filesystem 01307 * whose property should change. 01308 * - @a name is the name of the property to change. 01309 * - @a VALUE is the new value of the property, or zero if the property should 01310 * be removed altogether. 01311 * 01312 * Note that revision properties are non-historied --- you can change 01313 * them after the revision has been committed. They are not protected 01314 * via transactions. 01315 * 01316 * Do any necessary temporary allocation in @a pool. 01317 */ 01318 svn_error_t *svn_fs_change_rev_prop (svn_fs_t *fs, 01319 svn_revnum_t rev, 01320 const char *name, 01321 const svn_string_t *value, 01322 apr_pool_t *pool); 01323 01324 01325 01326 /* Computing deltas. */ 01327 01328 01329 /** Set @a *stream_p to a pointer to a delta stream that will turn the 01330 * contents of the file @a source into the contents of the file @a target. 01331 * If @a source_root is zero, use a file with zero length as the source. 01332 * 01333 * This function does not compare the two files' properties. 01334 * 01335 * Allocate @a *stream_p, and do any necessary temporary allocation, in 01336 * @a pool. 01337 */ 01338 svn_error_t *svn_fs_get_file_delta_stream (svn_txdelta_stream_t **stream_p, 01339 svn_fs_root_t *source_root, 01340 const char *source_path, 01341 svn_fs_root_t *target_root, 01342 const char *target_path, 01343 apr_pool_t *pool); 01344 01345 01346 01347 /* UUID manipulation. */ 01348 01349 /** Populate @a *uuid with the UUID associated with @a fs. Allocate 01350 @a *uuid in @a pool. */ 01351 svn_error_t *svn_fs_get_uuid (svn_fs_t *fs, 01352 const char **uuid, 01353 apr_pool_t *pool); 01354 01355 01356 /** Associate @a *uuid with @a fs. Use @a pool for any scratchwork. */ 01357 svn_error_t *svn_fs_set_uuid (svn_fs_t *fs, 01358 const char *uuid, 01359 apr_pool_t *pool); 01360 01361 01362 /* Non-historical properties. */ 01363 01364 /* [[Yes, do tell.]] */ 01365 01366 #ifdef __cplusplus 01367 } 01368 #endif /* __cplusplus */ 01369 01370 #endif /* SVN_FS_H */
1.3.5