Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/hotcopy.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/hotcopy.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/hotcopy.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/hotcopy.c Wed Jan 21 16:22:19 2015 @@ -125,7 +125,7 @@ hotcopy_io_copy_dir_recursively(svn_bool svn_boolean_t copy_perms, svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { svn_node_kind_t kind; apr_status_t status; @@ -135,10 +135,10 @@ hotcopy_io_copy_dir_recursively(svn_bool apr_int32_t flags = APR_FINFO_TYPE | APR_FINFO_NAME; /* Make a subpool for recursion */ - apr_pool_t *subpool = svn_pool_create(pool); + apr_pool_t *subpool = svn_pool_create(scratch_pool); /* The 'dst_path' is simply dst_parent/dst_basename */ - dst_path = svn_dirent_join(dst_parent, dst_basename, pool); + dst_path = svn_dirent_join(dst_parent, dst_basename, scratch_pool); /* Sanity checks: SRC and DST_PARENT are directories, and DST_BASENAME doesn't already exist in DST_PARENT. */ @@ -146,19 +146,20 @@ hotcopy_io_copy_dir_recursively(svn_bool if (kind != svn_node_dir) return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL, _("Source '%s' is not a directory"), - svn_dirent_local_style(src, pool)); + svn_dirent_local_style(src, scratch_pool)); SVN_ERR(svn_io_check_path(dst_parent, &kind, subpool)); if (kind != svn_node_dir) return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL, _("Destination '%s' is not a directory"), - svn_dirent_local_style(dst_parent, pool)); + svn_dirent_local_style(dst_parent, + scratch_pool)); SVN_ERR(svn_io_check_path(dst_path, &kind, subpool)); /* Create the new directory. */ /* ### TODO: copy permissions (needs apr_file_attrs_get()) */ - SVN_ERR(svn_io_make_dir_recursively(dst_path, pool)); + SVN_ERR(svn_io_make_dir_recursively(dst_path, scratch_pool)); /* Loop over the dirents in SRC. ('.' and '..' are auto-excluded) */ SVN_ERR(svn_io_dir_open(&this_dir, src, subpool)); @@ -225,12 +226,12 @@ hotcopy_io_copy_dir_recursively(svn_bool if (! (APR_STATUS_IS_ENOENT(status))) return svn_error_wrap_apr(status, _("Can't read directory '%s'"), - svn_dirent_local_style(src, pool)); + svn_dirent_local_style(src, scratch_pool)); status = apr_dir_close(this_dir); if (status) return svn_error_wrap_apr(status, _("Error closing directory '%s'"), - svn_dirent_local_style(src, pool)); + svn_dirent_local_style(src, scratch_pool)); /* Free any memory used by recursion */ svn_pool_destroy(subpool); @@ -297,7 +298,7 @@ hotcopy_copy_packed_shard(svn_boolean_t const char *src_subdir_packed_shard; svn_revnum_t revprop_rev; apr_pool_t *iterpool; - fs_x_data_t *src_ffd = src_fs->fsap_data; + svn_fs_x__data_t *src_ffd = src_fs->fsap_data; /* Copy the packed shard. */ src_subdir = svn_dirent_join(src_fs->path, PATH_REVS_DIR, scratch_pool); @@ -366,14 +367,14 @@ hotcopy_copy_packed_shard(svn_boolean_t } /* Remove file PATH, if it exists - even if it is read-only. - * Use POOL for temporary allocations. */ + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * hotcopy_remove_file(const char *path, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { /* Make the rev file writable and remove it. */ - SVN_ERR(svn_io_set_file_read_write(path, TRUE, pool)); - SVN_ERR(svn_io_remove_file2(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_read_write(path, TRUE, scratch_pool)); + SVN_ERR(svn_io_remove_file2(path, TRUE, scratch_pool)); return SVN_NO_ERROR; } @@ -474,11 +475,10 @@ hotcopy_remove_revprop_files(svn_fs_t *d * hotcopy from SRC_FS. */ static svn_error_t * hotcopy_incremental_check_preconditions(svn_fs_t *src_fs, - svn_fs_t *dst_fs, - apr_pool_t *pool) + svn_fs_t *dst_fs) { - fs_x_data_t *src_ffd = src_fs->fsap_data; - fs_x_data_t *dst_ffd = dst_fs->fsap_data; + svn_fs_x__data_t *src_ffd = src_fs->fsap_data; + svn_fs_x__data_t *dst_ffd = dst_fs->fsap_data; /* We only support incremental hotcopy between the same format. */ if (src_ffd->format != dst_ffd->format) @@ -508,16 +508,17 @@ hotcopy_incremental_check_preconditions( /* Remove folder PATH. Ignore errors due to the sub-tree not being empty. * CANCEL_FUNC and CANCEL_BATON do the usual thing. - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * remove_folder(const char *path, svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { svn_error_t *err = svn_io_remove_dir2(path, TRUE, - cancel_func, cancel_baton, pool); + cancel_func, cancel_baton, + scratch_pool); if (err && APR_STATUS_IS_ENOTEMPTY(err->apr_err)) { @@ -534,7 +535,7 @@ remove_folder(const char *path, * for every shard by updating the 'current' file if necessary. Assume * the >= SVN_FS_FS__MIN_NO_GLOBAL_IDS_FORMAT filesystem format without * global next-ID counters. Indicate progress via the optional NOTIFY_FUNC - * callback using NOTIFY_BATON. Use POOL for temporary allocations. + * callback using NOTIFY_BATON. Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * hotcopy_revisions(svn_fs_t *src_fs, @@ -550,9 +551,9 @@ hotcopy_revisions(svn_fs_t *src_fs, void* notify_baton, svn_cancel_func_t cancel_func, void* cancel_baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - fs_x_data_t *src_ffd = src_fs->fsap_data; + svn_fs_x__data_t *src_ffd = src_fs->fsap_data; int max_files_per_dir = src_ffd->max_files_per_dir; svn_revnum_t src_min_unpacked_rev; svn_revnum_t dst_min_unpacked_rev; @@ -561,9 +562,9 @@ hotcopy_revisions(svn_fs_t *src_fs, /* Copy the min unpacked rev, and read its value. */ SVN_ERR(svn_fs_x__read_min_unpacked_rev(&src_min_unpacked_rev, src_fs, - pool)); + scratch_pool)); SVN_ERR(svn_fs_x__read_min_unpacked_rev(&dst_min_unpacked_rev, dst_fs, - pool)); + scratch_pool)); /* We only support packs coming from the hotcopy source. * The destination should not be packed independently from @@ -578,7 +579,7 @@ hotcopy_revisions(svn_fs_t *src_fs, src_min_unpacked_rev - 1); SVN_ERR(svn_io_dir_file_copy(src_fs->path, dst_fs->path, - PATH_MIN_UNPACKED_REV, pool)); + PATH_MIN_UNPACKED_REV, scratch_pool)); if (cancel_func) SVN_ERR(cancel_func(cancel_baton)); @@ -587,7 +588,7 @@ hotcopy_revisions(svn_fs_t *src_fs, * Copy the necessary rev files. */ - iterpool = svn_pool_create(pool); + iterpool = svn_pool_create(scratch_pool); /* First, copy packed shards. */ for (rev = 0; rev < src_min_unpacked_rev; rev += max_files_per_dir) { @@ -709,7 +710,7 @@ hotcopy_revisions(svn_fs_t *src_fs, } /* Baton for hotcopy_body(). */ -struct hotcopy_body_baton { +typedef struct hotcopy_body_baton_t { svn_fs_t *src_fs; svn_fs_t *dst_fs; svn_boolean_t incremental; @@ -717,7 +718,7 @@ struct hotcopy_body_baton { void *notify_baton; svn_cancel_func_t cancel_func; void *cancel_baton; -}; +} hotcopy_body_baton_t; /* Perform a hotcopy, either normal or incremental. * @@ -738,9 +739,10 @@ struct hotcopy_body_baton { * write-lock is held. */ static svn_error_t * -hotcopy_body(void *baton, apr_pool_t *pool) +hotcopy_body(void *baton, + apr_pool_t *scratch_pool) { - struct hotcopy_body_baton *hbb = baton; + hotcopy_body_baton_t *hbb = baton; svn_fs_t *src_fs = hbb->src_fs; svn_fs_t *dst_fs = hbb->dst_fs; svn_boolean_t incremental = hbb->incremental; @@ -765,7 +767,7 @@ hotcopy_body(void *baton, apr_pool_t *po * ### an error from this function, and that renders the hotcopy * ### unusable anyway. */ SVN_ERR(svn_io_dir_file_copy(src_fs->path, dst_fs->path, PATH_CONFIG, - pool)); + scratch_pool)); if (cancel_func) SVN_ERR(cancel_func(cancel_baton)); @@ -775,10 +777,10 @@ hotcopy_body(void *baton, apr_pool_t *po * of revisions than the destination. * This also catches the case where users accidentally swap the * source and destination arguments. */ - SVN_ERR(svn_fs_x__read_current(&src_youngest, src_fs, pool)); + SVN_ERR(svn_fs_x__read_current(&src_youngest, src_fs, scratch_pool)); if (incremental) { - SVN_ERR(svn_fs_x__youngest_rev(&dst_youngest, dst_fs, pool)); + SVN_ERR(svn_fs_x__youngest_rev(&dst_youngest, dst_fs, scratch_pool)); if (src_youngest < dst_youngest) return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL, _("The hotcopy destination already contains more revisions " @@ -789,15 +791,17 @@ hotcopy_body(void *baton, apr_pool_t *po else dst_youngest = 0; - src_revs_dir = svn_dirent_join(src_fs->path, PATH_REVS_DIR, pool); - dst_revs_dir = svn_dirent_join(dst_fs->path, PATH_REVS_DIR, pool); - src_revprops_dir = svn_dirent_join(src_fs->path, PATH_REVPROPS_DIR, pool); - dst_revprops_dir = svn_dirent_join(dst_fs->path, PATH_REVPROPS_DIR, pool); + src_revs_dir = svn_dirent_join(src_fs->path, PATH_REVS_DIR, scratch_pool); + dst_revs_dir = svn_dirent_join(dst_fs->path, PATH_REVS_DIR, scratch_pool); + src_revprops_dir = svn_dirent_join(src_fs->path, PATH_REVPROPS_DIR, + scratch_pool); + dst_revprops_dir = svn_dirent_join(dst_fs->path, PATH_REVPROPS_DIR, + scratch_pool); /* Ensure that the required folders exist in the destination * before actually copying the revisions and revprops. */ - SVN_ERR(svn_io_make_dir_recursively(dst_revs_dir, pool)); - SVN_ERR(svn_io_make_dir_recursively(dst_revprops_dir, pool)); + SVN_ERR(svn_io_make_dir_recursively(dst_revs_dir, scratch_pool)); + SVN_ERR(svn_io_make_dir_recursively(dst_revprops_dir, scratch_pool)); if (cancel_func) SVN_ERR(cancel_func(cancel_baton)); @@ -810,30 +814,33 @@ hotcopy_body(void *baton, apr_pool_t *po incremental, src_revs_dir, dst_revs_dir, src_revprops_dir, dst_revprops_dir, notify_func, notify_baton, - cancel_func, cancel_baton, pool)); - SVN_ERR(svn_fs_x__write_current(dst_fs, src_youngest, pool)); + cancel_func, cancel_baton, scratch_pool)); + SVN_ERR(svn_fs_x__write_current(dst_fs, src_youngest, scratch_pool)); /* Replace the locks tree. * This is racy in case readers are currently trying to list locks in * the destination. However, we need to get rid of stale locks. * This is the simplest way of doing this, so we accept this small race. */ - dst_subdir = svn_dirent_join(dst_fs->path, PATH_LOCKS_DIR, pool); + dst_subdir = svn_dirent_join(dst_fs->path, PATH_LOCKS_DIR, scratch_pool); SVN_ERR(svn_io_remove_dir2(dst_subdir, TRUE, cancel_func, cancel_baton, - pool)); - src_subdir = svn_dirent_join(src_fs->path, PATH_LOCKS_DIR, pool); - SVN_ERR(svn_io_check_path(src_subdir, &kind, pool)); + scratch_pool)); + src_subdir = svn_dirent_join(src_fs->path, PATH_LOCKS_DIR, scratch_pool); + SVN_ERR(svn_io_check_path(src_subdir, &kind, scratch_pool)); if (kind == svn_node_dir) SVN_ERR(svn_io_copy_dir_recursively(src_subdir, dst_fs->path, PATH_LOCKS_DIR, TRUE, - cancel_func, cancel_baton, pool)); + cancel_func, cancel_baton, + scratch_pool)); /* Now copy the node-origins cache tree. */ - src_subdir = svn_dirent_join(src_fs->path, PATH_NODE_ORIGINS_DIR, pool); - SVN_ERR(svn_io_check_path(src_subdir, &kind, pool)); + src_subdir = svn_dirent_join(src_fs->path, PATH_NODE_ORIGINS_DIR, + scratch_pool); + SVN_ERR(svn_io_check_path(src_subdir, &kind, scratch_pool)); if (kind == svn_node_dir) SVN_ERR(hotcopy_io_copy_dir_recursively(NULL, src_subdir, dst_fs->path, PATH_NODE_ORIGINS_DIR, TRUE, - cancel_func, cancel_baton, pool)); + cancel_func, cancel_baton, + scratch_pool)); /* * NB: Data copied below is only read by writers, not readers. @@ -842,32 +849,27 @@ hotcopy_body(void *baton, apr_pool_t *po /* Copy the rep cache and then remove entries for revisions * younger than the destination's youngest revision. */ - src_subdir = svn_dirent_join(src_fs->path, REP_CACHE_DB_NAME, pool); - dst_subdir = svn_dirent_join(dst_fs->path, REP_CACHE_DB_NAME, pool); - SVN_ERR(svn_io_check_path(src_subdir, &kind, pool)); + src_subdir = svn_dirent_join(src_fs->path, REP_CACHE_DB_NAME, scratch_pool); + dst_subdir = svn_dirent_join(dst_fs->path, REP_CACHE_DB_NAME, scratch_pool); + SVN_ERR(svn_io_check_path(src_subdir, &kind, scratch_pool)); if (kind == svn_node_file) { /* Copy the rep cache and then remove entries for revisions * that did not make it into the destination. */ - src_subdir = svn_dirent_join(src_fs->path, REP_CACHE_DB_NAME, pool); - dst_subdir = svn_dirent_join(dst_fs->path, REP_CACHE_DB_NAME, pool); - SVN_ERR(svn_io_check_path(src_subdir, &kind, pool)); - if (kind == svn_node_file) - { - SVN_ERR(svn_sqlite__hotcopy(src_subdir, dst_subdir, pool)); - SVN_ERR(svn_fs_x__del_rep_reference(dst_fs, src_youngest, pool)); - } + SVN_ERR(svn_sqlite__hotcopy(src_subdir, dst_subdir, scratch_pool)); + SVN_ERR(svn_fs_x__del_rep_reference(dst_fs, src_youngest, + scratch_pool)); } /* Copy the txn-current file. */ SVN_ERR(svn_io_dir_file_copy(src_fs->path, dst_fs->path, - PATH_TXN_CURRENT, pool)); + PATH_TXN_CURRENT, scratch_pool)); /* If a revprop generation file exists in the source filesystem, * reset it to zero (since this is on a different path, it will not * overlap with data already in cache). Also, clean up stale files * used for the named atomics implementation. */ - SVN_ERR(svn_fs_x__reset_revprop_generation_file(dst_fs, pool)); + SVN_ERR(svn_fs_x__reset_revprop_generation_file(dst_fs, scratch_pool)); return SVN_NO_ERROR; } @@ -876,12 +878,13 @@ hotcopy_body(void *baton, apr_pool_t *po * locks. */ static svn_error_t * -hotcopy_locking_src_body(void *baton, apr_pool_t *pool) +hotcopy_locking_src_body(void *baton, + apr_pool_t *scratch_pool) { - struct hotcopy_body_baton *hbb = baton; + hotcopy_body_baton_t *hbb = baton; return svn_error_trace(svn_fs_x__with_pack_lock(hbb->src_fs, hotcopy_body, - baton, pool)); + baton, scratch_pool)); } /* Create an empty filesystem at DST_FS at DST_PATH with the same @@ -891,27 +894,30 @@ static svn_error_t * hotcopy_create_empty_dest(svn_fs_t *src_fs, svn_fs_t *dst_fs, const char *dst_path, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - fs_x_data_t *src_ffd = src_fs->fsap_data; + svn_fs_x__data_t *src_ffd = src_fs->fsap_data; /* Create the DST_FS repository with the same layout as SRC_FS. */ SVN_ERR(svn_fs_x__create_file_tree(dst_fs, dst_path, src_ffd->format, - src_ffd->max_files_per_dir, pool)); + src_ffd->max_files_per_dir, + scratch_pool)); /* Copy the UUID. Hotcopy destination receives a new instance ID, but * has the same filesystem UUID as the source. */ - SVN_ERR(svn_fs_x__set_uuid(dst_fs, src_fs->uuid, NULL, pool)); + SVN_ERR(svn_fs_x__set_uuid(dst_fs, src_fs->uuid, NULL, scratch_pool)); /* Remove revision 0 contents. Otherwise, it may not get overwritten * due to having a newer timestamp. */ - SVN_ERR(hotcopy_remove_file(svn_fs_x__path_rev(dst_fs, 0, pool), pool)); - SVN_ERR(hotcopy_remove_file(svn_fs_x__path_revprops(dst_fs, 0, pool), - pool)); + SVN_ERR(hotcopy_remove_file(svn_fs_x__path_rev(dst_fs, 0, scratch_pool), + scratch_pool)); + SVN_ERR(hotcopy_remove_file(svn_fs_x__path_revprops(dst_fs, 0, + scratch_pool), + scratch_pool)); /* This filesystem is ready. Stamp it with a format number. Fail if * the 'format' file should already exist. */ - SVN_ERR(svn_fs_x__write_format(dst_fs, FALSE, pool)); + SVN_ERR(svn_fs_x__write_format(dst_fs, FALSE, scratch_pool)); return SVN_NO_ERROR; } @@ -921,7 +927,7 @@ svn_fs_x__hotcopy_prepare_target(svn_fs_ svn_fs_t *dst_fs, const char *dst_path, svn_boolean_t incremental, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { if (incremental) { @@ -930,27 +936,30 @@ svn_fs_x__hotcopy_prepare_target(svn_fs_ /* Check destination format to be sure we know how to incrementally * hotcopy to the destination FS. */ - dst_format_abspath = svn_dirent_join(dst_path, PATH_FORMAT, pool); - SVN_ERR(svn_io_check_path(dst_format_abspath, &dst_format_kind, pool)); + dst_format_abspath = svn_dirent_join(dst_path, PATH_FORMAT, + scratch_pool); + SVN_ERR(svn_io_check_path(dst_format_abspath, &dst_format_kind, + scratch_pool)); if (dst_format_kind == svn_node_none) { /* Destination doesn't exist yet. Perform a normal hotcopy to a * empty destination using the same configuration as the source. */ - SVN_ERR(hotcopy_create_empty_dest(src_fs, dst_fs, dst_path, pool)); + SVN_ERR(hotcopy_create_empty_dest(src_fs, dst_fs, dst_path, + scratch_pool)); } else { /* Check the existing repository. */ - SVN_ERR(svn_fs_x__open(dst_fs, dst_path, pool)); - SVN_ERR(hotcopy_incremental_check_preconditions(src_fs, dst_fs, - pool)); + SVN_ERR(svn_fs_x__open(dst_fs, dst_path, scratch_pool)); + SVN_ERR(hotcopy_incremental_check_preconditions(src_fs, dst_fs)); } } else { /* Start out with an empty destination using the same configuration * as the source. */ - SVN_ERR(hotcopy_create_empty_dest(src_fs, dst_fs, dst_path, pool)); + SVN_ERR(hotcopy_create_empty_dest(src_fs, dst_fs, dst_path, + scratch_pool)); } return SVN_NO_ERROR; @@ -964,9 +973,9 @@ svn_fs_x__hotcopy(svn_fs_t *src_fs, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - struct hotcopy_body_baton hbb; + hotcopy_body_baton_t hbb; hbb.src_fs = src_fs; hbb.dst_fs = dst_fs; @@ -976,7 +985,7 @@ svn_fs_x__hotcopy(svn_fs_t *src_fs, hbb.cancel_func = cancel_func; hbb.cancel_baton = cancel_baton; SVN_ERR(svn_fs_x__with_all_locks(dst_fs, hotcopy_locking_src_body, &hbb, - pool)); + scratch_pool)); return SVN_NO_ERROR; }
Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/hotcopy.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/hotcopy.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/hotcopy.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/hotcopy.h Wed Jan 21 16:22:19 2015 @@ -27,25 +27,27 @@ /* Create an empty copy of the fsfs filesystem SRC_FS into a new DST_FS at * DST_PATH. If INCREMENTAL is TRUE, perform a few pre-checks only if - * a repo already exists at DST_PATH. Use POOL for temporary allocations. */ + * a repo already exists at DST_PATH. + * Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__hotcopy_prepare_target(svn_fs_t *src_fs, svn_fs_t *dst_fs, const char *dst_path, svn_boolean_t incremental, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Copy the fsfs filesystem SRC_FS into DST_FS. If INCREMENTAL is TRUE, do * not re-copy data which already exists in DST_FS. Indicate progress via - * the optional NOTIFY_FUNC callback using NOTIFY_BATON. Use POOL for - * temporary allocations. */ -svn_error_t * svn_fs_x__hotcopy(svn_fs_t *src_fs, - svn_fs_t *dst_fs, - svn_boolean_t incremental, - svn_fs_hotcopy_notify_t notify_func, - void *notify_baton, - svn_cancel_func_t cancel_func, - void *cancel_baton, - apr_pool_t *pool); + * the optional NOTIFY_FUNC callback using NOTIFY_BATON. + * Use SCRATCH_POOL for temporary allocations. */ +svn_error_t * +svn_fs_x__hotcopy(svn_fs_t *src_fs, + svn_fs_t *dst_fs, + svn_boolean_t incremental, + svn_fs_hotcopy_notify_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); #endif Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/id.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/id.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/id.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/id.c Wed Jan 21 16:22:19 2015 @@ -1,4 +1,4 @@ -/* id.c : operations on node-revision IDs +/* id.c : implements FSX-internal ID functions * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one @@ -21,32 +21,14 @@ */ #include <assert.h> -#include <string.h> -#include <stdlib.h> #include "id.h" #include "index.h" #include "util.h" -#include "../libsvn_fs/fs-loader.h" -#include "private/svn_temp_serializer.h" #include "private/svn_string_private.h" -typedef struct fs_x__id_t -{ - /* API visible part */ - svn_fs_id_t generic_id; - - /* private members */ - svn_fs_x__id_part_t node_id; - svn_fs_x__id_part_t copy_id; - svn_fs_x__id_part_t noderev_id; - - apr_pool_t *pool; /* pool that was used to allocate this struct */ -} fs_x__id_t; - - svn_boolean_t svn_fs_x__is_txn(svn_fs_x__change_set_t change_set) @@ -95,7 +77,7 @@ svn_fs_x__change_set_by_txn(apr_int64_t /* Parse the NUL-terminated ID part at DATA and write the result into *PART. * Return TRUE if no errors were detected. */ static svn_boolean_t -part_parse(svn_fs_x__id_part_t *part, +part_parse(svn_fs_x__id_t *part, const char *data) { part->number = svn__base36toui64(&data, data); @@ -119,7 +101,7 @@ part_parse(svn_fs_x__id_part_t *part, */ static char * part_unparse(char *p, - const svn_fs_x__id_part_t *part) + const svn_fs_x__id_t *part) { p += svn__ui64tobase36(p, part->number); if (part->change_set >= 0) @@ -141,151 +123,71 @@ part_unparse(char *p, /* Operations on ID parts */ svn_boolean_t -svn_fs_x__id_part_is_root(const svn_fs_x__id_part_t* part) +svn_fs_x__id_is_root(const svn_fs_x__id_t* part) { return part->change_set == 0 && part->number == 0; } svn_boolean_t -svn_fs_x__id_part_eq(const svn_fs_x__id_part_t *lhs, - const svn_fs_x__id_part_t *rhs) +svn_fs_x__id_eq(const svn_fs_x__id_t *lhs, + const svn_fs_x__id_t *rhs) { return lhs->change_set == rhs->change_set && lhs->number == rhs->number; } - - -/* Accessing ID Pieces. */ - -const svn_fs_x__id_part_t * -svn_fs_x__id_node_id(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return &id->node_id; -} - - -const svn_fs_x__id_part_t * -svn_fs_x__id_copy_id(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return &id->copy_id; -} - - -svn_fs_x__txn_id_t -svn_fs_x__id_txn_id(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return svn_fs_x__get_txn_id(id->noderev_id.change_set); -} - - -const svn_fs_x__id_part_t * -svn_fs_x__id_noderev_id(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return &id->noderev_id; -} - -svn_revnum_t -svn_fs_x__id_rev(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return svn_fs_x__get_revnum(id->noderev_id.change_set); -} - - -apr_uint64_t -svn_fs_x__id_item(const svn_fs_id_t *fs_id) +svn_error_t * +svn_fs_x__id_parse(svn_fs_x__id_t *part, + const char *data) { - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; + if (!part_parse(part, data)) + return svn_error_createf(SVN_ERR_FS_MALFORMED_NODEREV_ID, NULL, + "Malformed ID string"); - return id->noderev_id.number; + return SVN_NO_ERROR; } -svn_boolean_t -svn_fs_x__id_is_txn(const svn_fs_id_t *fs_id) +svn_string_t * +svn_fs_x__id_unparse(const svn_fs_x__id_t *id, + apr_pool_t *result_pool) { - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; + char string[2 * SVN_INT64_BUFFER_SIZE + 1]; + char *p = part_unparse(string, id); - return svn_fs_x__is_txn(id->noderev_id.change_set); + return svn_string_ncreate(string, p - string, result_pool); } -svn_string_t * -svn_fs_x__id_unparse(const svn_fs_id_t *fs_id, - apr_pool_t *pool) +void +svn_fs_x__id_reset(svn_fs_x__id_t *part) { - char string[6 * SVN_INT64_BUFFER_SIZE + 10]; - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - char *p = part_unparse(string, &id->node_id); - *(p++) = '.'; - p = part_unparse(p, &id->copy_id); - *(p++) = '.'; - p = part_unparse(p, &id->noderev_id); - - return svn_string_ncreate(string, p - string, pool); + part->change_set = SVN_FS_X__INVALID_CHANGE_SET; + part->number = 0; } - -/*** Comparing node IDs ***/ - svn_boolean_t -svn_fs_x__id_eq(const svn_fs_id_t *a, - const svn_fs_id_t *b) +svn_fs_x__id_used(const svn_fs_x__id_t *part) { - const fs_x__id_t *id_a = (const fs_x__id_t *)a; - const fs_x__id_t *id_b = (const fs_x__id_t *)b; - - if (a == b) - return TRUE; - - return svn_fs_x__id_part_eq(&id_a->node_id, &id_b->node_id) - && svn_fs_x__id_part_eq(&id_a->copy_id, &id_b->copy_id) - && svn_fs_x__id_part_eq(&id_a->noderev_id, &id_b->noderev_id); + return part->change_set != SVN_FS_X__INVALID_CHANGE_SET; } - -svn_boolean_t -svn_fs_x__id_check_related(const svn_fs_id_t *a, - const svn_fs_id_t *b) +void +svn_fs_x__init_txn_root(svn_fs_x__id_t *noderev_id, + svn_fs_x__txn_id_t txn_id) { - const fs_x__id_t *id_a = (const fs_x__id_t *)a; - const fs_x__id_t *id_b = (const fs_x__id_t *)b; - - if (a == b) - return TRUE; - - /* Items from different txns are unrelated. */ - if ( svn_fs_x__is_txn(id_a->noderev_id.change_set) - && svn_fs_x__is_txn(id_b->noderev_id.change_set) - && id_a->noderev_id.change_set != id_b->noderev_id.change_set) - return FALSE; - - /* related if they trace back to the same node creation */ - return svn_fs_x__id_part_eq(&id_a->node_id, &id_b->node_id); + noderev_id->change_set = svn_fs_x__change_set_by_txn(txn_id); + noderev_id->number = SVN_FS_X__ITEM_INDEX_ROOT_NODE; } - -svn_fs_node_relation_t -svn_fs_x__id_compare(const svn_fs_id_t *a, - const svn_fs_id_t *b) +void +svn_fs_x__init_rev_root(svn_fs_x__id_t *noderev_id, + svn_revnum_t rev) { - if (svn_fs_x__id_eq(a, b)) - return svn_fs_node_same; - return (svn_fs_x__id_check_related(a, b) ? svn_fs_node_common_ancestor - : svn_fs_node_unrelated); + noderev_id->change_set = svn_fs_x__change_set_by_rev(rev); + noderev_id->number = SVN_FS_X__ITEM_INDEX_ROOT_NODE; } int -svn_fs_x__id_part_compare(const svn_fs_x__id_part_t *a, - const svn_fs_x__id_part_t *b) +svn_fs_x__id_compare(const svn_fs_x__id_t *a, + const svn_fs_x__id_t *b) { if (a->change_set < b->change_set) return -1; @@ -294,210 +196,3 @@ svn_fs_x__id_part_compare(const svn_fs_x return a->number < b->number ? -1 : a->number == b->number ? 0 : 1; } - - - -/* Creating ID's. */ - -static id_vtable_t id_vtable = { - svn_fs_x__id_unparse, - svn_fs_x__id_compare -}; - -svn_fs_id_t * -svn_fs_x__id_txn_create_root(svn_fs_x__txn_id_t txn_id, - apr_pool_t *pool) -{ - fs_x__id_t *id = apr_pcalloc(pool, sizeof(*id)); - - /* node ID and copy ID are "0" */ - - id->noderev_id.change_set = svn_fs_x__change_set_by_txn(txn_id); - id->noderev_id.number = SVN_FS_X__ITEM_INDEX_ROOT_NODE; - - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - return (svn_fs_id_t *)id; -} - -svn_fs_id_t *svn_fs_x__id_create_root(const svn_revnum_t revision, - apr_pool_t *pool) -{ - fs_x__id_t *id = apr_pcalloc(pool, sizeof(*id)); - - /* node ID and copy ID are "0" */ - - id->noderev_id.change_set = svn_fs_x__change_set_by_rev(revision); - id->noderev_id.number = SVN_FS_X__ITEM_INDEX_ROOT_NODE; - - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - return (svn_fs_id_t *)id; -} - -svn_fs_id_t * -svn_fs_x__id_txn_create(const svn_fs_x__id_part_t *node_id, - const svn_fs_x__id_part_t *copy_id, - svn_fs_x__txn_id_t txn_id, - apr_uint64_t item, - apr_pool_t *pool) -{ - fs_x__id_t *id = apr_pcalloc(pool, sizeof(*id)); - - id->node_id = *node_id; - id->copy_id = *copy_id; - - id->noderev_id.change_set = svn_fs_x__change_set_by_txn(txn_id); - id->noderev_id.number = item; - - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - return (svn_fs_id_t *)id; -} - - -svn_fs_id_t * -svn_fs_x__id_create(const svn_fs_x__id_part_t *node_id, - const svn_fs_x__id_part_t *copy_id, - const svn_fs_x__id_part_t *noderev_id, - apr_pool_t *pool) -{ - fs_x__id_t *id = apr_pcalloc(pool, sizeof(*id)); - - id->node_id = *node_id; - id->copy_id = *copy_id; - id->noderev_id = *noderev_id; - - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - return (svn_fs_id_t *)id; -} - - -svn_fs_id_t * -svn_fs_x__id_copy(const svn_fs_id_t *source, apr_pool_t *pool) -{ - const fs_x__id_t *id = (const fs_x__id_t *)source; - fs_x__id_t *new_id = apr_pmemdup(pool, id, sizeof(*new_id)); - - new_id->generic_id.fsap_data = new_id; - new_id->pool = pool; - - return (svn_fs_id_t *)new_id; -} - -/* Return an ID resulting from parsing the string DATA, or NULL if DATA is - an invalid ID string. *DATA will be modified / invalidated by this call. */ -static svn_fs_id_t * -id_parse(char *data, - apr_pool_t *pool) -{ - fs_x__id_t *id; - char *str; - - /* Alloc a new svn_fs_id_t structure. */ - id = apr_pcalloc(pool, sizeof(*id)); - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - /* Now, we basically just need to "split" this data on `.' - characters. We will use svn_cstring_tokenize, which will put - terminators where each of the '.'s used to be. Then our new - id field will reference string locations inside our duplicate - string.*/ - - /* Node Id */ - str = svn_cstring_tokenize(".", &data); - if (str == NULL) - return NULL; - if (! part_parse(&id->node_id, str)) - return NULL; - - /* Copy Id */ - str = svn_cstring_tokenize(".", &data); - if (str == NULL) - return NULL; - if (! part_parse(&id->copy_id, str)) - return NULL; - - /* NodeRev Id */ - str = svn_cstring_tokenize(".", &data); - if (str == NULL) - return NULL; - - if (! part_parse(&id->noderev_id, str)) - return NULL; - - return (svn_fs_id_t *)id; -} - -svn_error_t * -svn_fs_x__id_parse(const svn_fs_id_t **id_p, - char *data, - apr_pool_t *pool) -{ - svn_fs_id_t *id = id_parse(data, pool); - if (id == NULL) - return svn_error_createf(SVN_ERR_FS_MALFORMED_NODEREV_ID, NULL, - "Malformed node revision ID string"); - - *id_p = id; - - return SVN_NO_ERROR; -} - -/* (de-)serialization support */ - -/* Serialize an ID within the serialization CONTEXT. - */ -void -svn_fs_x__id_serialize(svn_temp_serializer__context_t *context, - const svn_fs_id_t * const *in) -{ - const fs_x__id_t *id = (const fs_x__id_t *)*in; - - /* nothing to do for NULL ids */ - if (id == NULL) - return; - - /* serialize the id data struct itself */ - svn_temp_serializer__add_leaf(context, - (const void * const *)in, - sizeof(fs_x__id_t)); -} - -/* Deserialize an ID inside the BUFFER. - */ -void -svn_fs_x__id_deserialize(void *buffer, - svn_fs_id_t **in_out, - apr_pool_t *pool) -{ - fs_x__id_t *id; - - /* The id maybe all what is in the whole buffer. - * Don't try to fixup the pointer in that case*/ - if (*in_out != buffer) - svn_temp_deserializer__resolve(buffer, (void**)in_out); - - id = (fs_x__id_t *)*in_out; - - /* no id, no sub-structure fixup necessary */ - if (id == NULL) - return; - - /* the stored vtable is bogus at best -> set the right one */ - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; -} - Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/id.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/id.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/id.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/id.h Wed Jan 21 16:22:19 2015 @@ -1,4 +1,4 @@ -/* id.h : interface to node ID functions, private to libsvn_fs_x +/* id.h : interface to FSX-internal ID functions * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one @@ -45,149 +45,88 @@ typedef apr_int64_t svn_fs_x__change_set /* Return TRUE iff the CHANGE_SET refers to a revision (will return FALSE for SVN_INVALID_REVNUM). */ -svn_boolean_t svn_fs_x__is_revision(svn_fs_x__change_set_t change_set); +svn_boolean_t +svn_fs_x__is_revision(svn_fs_x__change_set_t change_set); /* Return TRUE iff the CHANGE_SET refers to a transaction (will return FALSE for SVN_FS_X__INVALID_TXN_ID). */ -svn_boolean_t svn_fs_x__is_txn(svn_fs_x__change_set_t change_set); +svn_boolean_t +svn_fs_x__is_txn(svn_fs_x__change_set_t change_set); /* Return the revision number that corresponds to CHANGE_SET. Will SVN_INVALID_REVNUM for transactions. */ -svn_revnum_t svn_fs_x__get_revnum(svn_fs_x__change_set_t change_set); +svn_revnum_t +svn_fs_x__get_revnum(svn_fs_x__change_set_t change_set); /* Return the transaction ID that corresponds to CHANGE_SET. Will SVN_FS_X__INVALID_TXN_ID for revisions. */ -apr_int64_t svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set); +svn_fs_x__txn_id_t +svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set); /* Convert REVNUM into a change set number */ -svn_fs_x__change_set_t svn_fs_x__change_set_by_rev(svn_revnum_t revnum); +svn_fs_x__change_set_t +svn_fs_x__change_set_by_rev(svn_revnum_t revnum); /* Convert TXN_ID into a change set number */ -svn_fs_x__change_set_t svn_fs_x__change_set_by_txn(apr_int64_t txn_id); +svn_fs_x__change_set_t +svn_fs_x__change_set_by_txn(svn_fs_x__txn_id_t txn_id); -/* A rev node ID in FSX consists of a 3 of sub-IDs ("parts") that consist - * of a creation CHANGE_SET number and some revision-local counter value - * (NUMBER). +/* An ID in FSX consists of a creation CHANGE_SET number and some changeset- + * local counter value (NUMBER). */ -typedef struct svn_fs_x__id_part_t +typedef struct svn_fs_x__id_t { svn_fs_x__change_set_t change_set; apr_uint64_t number; -} svn_fs_x__id_part_t; +} svn_fs_x__id_t; /*** Operations on ID parts. ***/ /* Return TRUE, if both elements of the PART is 0, i.e. this is the default * value if e.g. no copies were made of this node. */ -svn_boolean_t svn_fs_x__id_part_is_root(const svn_fs_x__id_part_t *part); +svn_boolean_t +svn_fs_x__id_is_root(const svn_fs_x__id_t *part); /* Return TRUE, if all element values of *LHS and *RHS match. */ -svn_boolean_t svn_fs_x__id_part_eq(const svn_fs_x__id_part_t *lhs, - const svn_fs_x__id_part_t *rhs); +svn_boolean_t +svn_fs_x__id_eq(const svn_fs_x__id_t *lhs, + const svn_fs_x__id_t *rhs); - -/*** ID accessor functions. ***/ - -/* Get the "node id" portion of ID. */ -const svn_fs_x__id_part_t *svn_fs_x__id_node_id(const svn_fs_id_t *id); - -/* Get the "copy id" portion of ID. */ -const svn_fs_x__id_part_t *svn_fs_x__id_copy_id(const svn_fs_id_t *id); - -/* Get the "txn id" portion of ID, - * or SVN_FS_X__INVALID_TXN_ID if it is a permanent ID. */ -svn_fs_x__txn_id_t svn_fs_x__id_txn_id(const svn_fs_id_t *id); - -/* Get the "noderev id" portion of ID. */ -const svn_fs_x__id_part_t *svn_fs_x__id_noderev_id(const svn_fs_id_t *id); - -/* Get the "rev" portion of ID, or SVN_INVALID_REVNUM if it is a - transaction ID. */ -svn_revnum_t svn_fs_x__id_rev(const svn_fs_id_t *id); - -/* Access the "item" portion of the ID, or 0 if it is a transaction - ID. */ -apr_uint64_t svn_fs_x__id_item(const svn_fs_id_t *id); - -/* Return TRUE, if this is a transaction ID. */ -svn_boolean_t svn_fs_x__id_is_txn(const svn_fs_id_t *id); - -/* Convert ID into string form, allocated in POOL. */ -svn_string_t *svn_fs_x__id_unparse(const svn_fs_id_t *id, - apr_pool_t *pool); +/* Parse the NUL-terminated ID part at DATA and write the result into *PART. + */ +svn_error_t * +svn_fs_x__id_parse(svn_fs_x__id_t *part, + const char *data); -/* Return true if A and B are equal. */ -svn_boolean_t svn_fs_x__id_eq(const svn_fs_id_t *a, - const svn_fs_id_t *b); +/* Convert ID into string form, allocated in RESULT_POOL. */ +svn_string_t * +svn_fs_x__id_unparse(const svn_fs_x__id_t*id, + apr_pool_t *result_pool); -/* Return true if A and B are related. */ -svn_boolean_t svn_fs_x__id_check_related(const svn_fs_id_t *a, - const svn_fs_id_t *b); +/* Set *PART to "unused". */ +void +svn_fs_x__id_reset(svn_fs_x__id_t *part); -/* Return the noderev relationship between A and B. */ -svn_fs_node_relation_t svn_fs_x__id_compare(const svn_fs_id_t *a, - const svn_fs_id_t *b); +/* Return TRUE if *PART is belongs to either a revision or transaction. */ +svn_boolean_t +svn_fs_x__id_used(const svn_fs_x__id_t *part); /* Return 0 if A and B are equal, 1 if A is "greater than" B, -1 otherwise. */ -int svn_fs_x__id_part_compare(const svn_fs_x__id_part_t *a, - const svn_fs_x__id_part_t *b); - -/* Create the txn root ID for transaction TXN_ID. Allocate it in POOL. */ -svn_fs_id_t *svn_fs_x__id_txn_create_root(svn_fs_x__txn_id_t txnnum, - apr_pool_t *pool); - -/* Create the root ID for REVISION. Allocate it in POOL. */ -svn_fs_id_t *svn_fs_x__id_create_root(const svn_revnum_t revision, - apr_pool_t *pool); - -/* Create an ID within a transaction based on NODE_ID, COPY_ID, TXN_ID - and ITEM number, allocated in POOL. */ -svn_fs_id_t *svn_fs_x__id_txn_create(const svn_fs_x__id_part_t *node_id, - const svn_fs_x__id_part_t *copy_id, - svn_fs_x__txn_id_t txn_id, - apr_uint64_t item, - apr_pool_t *pool); - -/* Create a permanent ID based on NODE_ID, COPY_ID and NODEREV_ID, - allocated in POOL. */ -svn_fs_id_t *svn_fs_x__id_create(const svn_fs_x__id_part_t *node_id, - const svn_fs_x__id_part_t *copy_id, - const svn_fs_x__id_part_t *noderev_id, - apr_pool_t *pool); - -/* Return a copy of ID, allocated from POOL. */ -svn_fs_id_t *svn_fs_x__id_copy(const svn_fs_id_t *id, - apr_pool_t *pool); - -/* Return an ID in *ID_P resulting from parsing the string DATA, or an error - if DATA is an invalid ID string. *DATA will be modified / invalidated by - this call. */ -svn_error_t * -svn_fs_x__id_parse(const svn_fs_id_t **id_p, - char *data, - apr_pool_t *pool); - +int +svn_fs_x__id_compare(const svn_fs_x__id_t *a, + const svn_fs_x__id_t *b); -/* (de-)serialization support*/ - -struct svn_temp_serializer__context_t; - -/** - * Serialize an @a id within the serialization @a context. - */ +/* Set *NODEREV_ID to the root node ID of transaction TXN_ID. */ void -svn_fs_x__id_serialize(struct svn_temp_serializer__context_t *context, - const svn_fs_id_t * const *id); +svn_fs_x__init_txn_root(svn_fs_x__id_t *noderev_id, + svn_fs_x__txn_id_t txn_id); -/** - * Deserialize an @a id within the @a buffer and associate it with @a pool. - */ +/* Set *NODEREV_ID to the root node ID of revision REV. */ void -svn_fs_x__id_deserialize(void *buffer, - svn_fs_id_t **id, - apr_pool_t *pool); +svn_fs_x__init_rev_root(svn_fs_x__id_t *noderev_id, + svn_revnum_t rev); #ifdef __cplusplus } Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/index.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/index.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/index.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/index.c Wed Jan 21 16:22:19 2015 @@ -234,10 +234,10 @@ stream_error_create(svn_fs_x__packed_num const char *message) { const char *file_name; - apr_off_t offset = 0; + apr_off_t offset; SVN_ERR(svn_io_file_name_get(&file_name, stream->file, stream->pool)); - SVN_ERR(svn_io_file_seek(stream->file, APR_CUR, &offset, stream->pool)); + SVN_ERR(svn_fs_x__get_file_offset(&offset, stream->file, stream->pool)); return svn_error_createf(err, NULL, message, file_name, apr_psprintf(stream->pool, @@ -905,7 +905,7 @@ svn_fs_x__l2p_index_append(svn_checksum_ apr_pool_t * result_pool, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; apr_file_t *proto_index = NULL; svn_stream_t *stream; int i; @@ -1076,7 +1076,7 @@ svn_fs_x__l2p_index_append(svn_checksum_ static svn_revnum_t base_revision(svn_fs_t *fs, svn_revnum_t revision) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; return svn_fs_x__is_packed_rev(fs, revision) ? revision - (revision % ffd->max_files_per_dir) : revision; @@ -1241,7 +1241,7 @@ auto_open_l2p_index(svn_fs_x__revision_f { if (rev_file->l2p_stream == NULL) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; SVN_ERR(svn_fs_x__auto_read_footer(rev_file)); SVN_ERR(packed_stream_open(&rev_file->l2p_stream, @@ -1269,7 +1269,7 @@ get_l2p_header_body(l2p_header_t **heade apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; apr_uint64_t value; apr_size_t i; apr_size_t page, page_count; @@ -1280,7 +1280,7 @@ get_l2p_header_body(l2p_header_t **heade apr_array_header_t *expanded_values = apr_array_make(scratch_pool, 16, sizeof(apr_uint64_t)); - pair_cache_key_t key; + svn_fs_x__pair_cache_key_t key; key.revision = rev_file->start_revision; key.second = rev_file->is_packed; @@ -1397,13 +1397,13 @@ get_l2p_page_info(l2p_page_info_baton_t svn_fs_t *fs, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; l2p_header_t *result; svn_boolean_t is_cached = FALSE; void *dummy = NULL; /* try to find the info in the cache */ - pair_cache_key_t key; + svn_fs_x__pair_cache_key_t key; key.revision = base_revision(fs, baton->revision); key.second = svn_fs_x__is_packed_rev(fs, baton->revision); SVN_ERR(svn_cache__get_partial((void**)&dummy, &is_cached, @@ -1435,11 +1435,11 @@ get_l2p_header(l2p_header_t **header, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_boolean_t is_cached = FALSE; /* first, try cache lookop */ - pair_cache_key_t key; + svn_fs_x__pair_cache_key_t key; key.revision = rev_file->start_revision; key.second = rev_file->is_packed; SVN_ERR(svn_cache__get((void**)header, &is_cached, ffd->l2p_header_cache, @@ -1556,20 +1556,21 @@ typedef struct l2p_page_baton_t /* Return the rev / pack file offset of the item at BATON->PAGE_OFFSET in * OFFSETS of PAGE and write it to *OFFSET. + * Allocate temporaries in SCRATCH_POOL. */ static svn_error_t * l2p_page_get_offset(l2p_page_baton_t *baton, const l2p_page_t *page, const apr_off_t *offsets, const apr_uint32_t *sub_items, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { /* overflow check */ if (page->entry_count <= baton->page_offset) return svn_error_createf(SVN_ERR_FS_INDEX_OVERFLOW , NULL, _("Item index %s too large in" " revision %ld"), - apr_psprintf(pool, "%" APR_UINT64_T_FMT, + apr_psprintf(scratch_pool, "%" APR_UINT64_T_FMT, baton->item_index), baton->revision); @@ -1667,11 +1668,11 @@ get_l2p_page_table(apr_array_header_t *p svn_revnum_t revision, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_boolean_t is_cached = FALSE; l2p_page_table_baton_t baton; - pair_cache_key_t key; + svn_fs_x__pair_cache_key_t key; key.revision = base_revision(fs, revision); key.second = svn_fs_x__is_packed_rev(fs, revision); @@ -1707,7 +1708,7 @@ prefetch_l2p_pages(svn_boolean_t *end, apr_off_t max_offset, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; int i; apr_pool_t *iterpool; svn_fs_x__page_cache_key_t key = { 0 }; @@ -1794,7 +1795,7 @@ l2p_index_lookup(apr_off_t *offset, apr_uint64_t item_index, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; l2p_page_info_baton_t info_baton; l2p_page_baton_t page_baton; l2p_page_t *page = NULL; @@ -2000,13 +2001,12 @@ svn_fs_x__l2p_get_max_ids(apr_array_head */ svn_fs_x__p2l_entry_t * svn_fs_x__p2l_entry_dup(const svn_fs_x__p2l_entry_t *entry, - apr_pool_t *pool) + apr_pool_t *result_pool) { - svn_fs_x__p2l_entry_t *new_entry = apr_palloc(pool, sizeof(*new_entry)); - *new_entry = *entry; - + svn_fs_x__p2l_entry_t *new_entry = apr_pmemdup(result_pool, entry, + sizeof(*new_entry)); if (new_entry->item_count) - new_entry->items = apr_pmemdup(pool, + new_entry->items = apr_pmemdup(result_pool, entry->items, entry->item_count * sizeof(*entry->items)); @@ -2063,7 +2063,7 @@ svn_fs_x__p2l_proto_index_add_entry(apr_ /* Add sub-items. */ for (i = 0; i < entry->item_count; ++i) { - const svn_fs_x__id_part_t *sub_item = &entry->items[i]; + const svn_fs_x__id_t *sub_item = &entry->items[i]; /* Make sure all signed elements of ENTRY have non-negative values. * @@ -2128,7 +2128,7 @@ read_p2l_sub_items_from_proto_index(apr_ for (i = 0; i < entry->item_count; ++i) { apr_uint64_t revision; - svn_fs_x__id_part_t *sub_item = &entry->items[i]; + svn_fs_x__id_t *sub_item = &entry->items[i]; SVN_ERR(read_uint64_from_proto_index(proto_index, &revision, eof, scratch_pool)); @@ -2204,7 +2204,7 @@ svn_fs_x__p2l_index_append(svn_checksum_ apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; apr_uint64_t page_size = ffd->p2l_page_size; apr_file_t *proto_index = NULL; svn_stream_t *stream; @@ -2392,7 +2392,7 @@ auto_open_p2l_index(svn_fs_x__revision_f { if (rev_file->p2l_stream == NULL) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; SVN_ERR(svn_fs_x__auto_read_footer(rev_file)); SVN_ERR(packed_stream_open(&rev_file->p2l_stream, @@ -2509,7 +2509,7 @@ get_p2l_header(p2l_header_t **header, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; apr_uint64_t value; apr_size_t i; apr_off_t offset; @@ -2517,7 +2517,7 @@ get_p2l_header(p2l_header_t **header, svn_boolean_t is_cached = FALSE; /* look for the header data in our cache */ - pair_cache_key_t key; + svn_fs_x__pair_cache_key_t key; key.revision = rev_file->start_revision; key.second = rev_file->is_packed; @@ -2595,13 +2595,13 @@ get_p2l_page_info(p2l_page_info_baton_t svn_fs_t *fs, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; p2l_header_t *header; svn_boolean_t is_cached = FALSE; void *dummy = NULL; /* look for the header data in our cache */ - pair_cache_key_t key; + svn_fs_x__pair_cache_key_t key; key.revision = base_revision(fs, baton->revision); key.second = svn_fs_x__is_packed_rev(fs, baton->revision); @@ -2803,7 +2803,7 @@ prefetch_p2l_page(svn_boolean_t *end, apr_off_t min_offset, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_boolean_t already_cached; apr_array_header_t *page; svn_fs_x__page_cache_key_t key = { 0 }; @@ -2954,7 +2954,7 @@ append_p2l_entries(apr_array_header_t *e /* Copy the items of that entries. */ if (entry->item_count) { - const svn_fs_x__id_part_t *items + const svn_fs_x__id_t *items = resolve_ptr ? svn_temp_deserializer__ptr(page_entries->elts, (const void * const *)&entry->items) @@ -3014,7 +3014,7 @@ p2l_index_lookup(apr_array_header_t *ent apr_off_t block_end, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_fs_x__page_cache_key_t key; svn_boolean_t is_cached = FALSE; p2l_page_info_baton_t page_info; @@ -3241,7 +3241,7 @@ get_p2l_entry_from_cached_page(const voi svn_fs_x__p2l_entry_t *result = apr_pmemdup(result_pool, entry, sizeof(*result)); result->items - = (svn_fs_x__id_part_t *)svn_temp_deserializer__ptr(entries->elts, + = (svn_fs_x__id_t *)svn_temp_deserializer__ptr(entries->elts, (const void *const *)&entry->items); return result; } @@ -3280,7 +3280,7 @@ p2l_entry_lookup(svn_fs_x__p2l_entry_t * apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_fs_x__page_cache_key_t key = { 0 }; svn_boolean_t is_cached = FALSE; p2l_page_info_baton_t page_info; @@ -3338,7 +3338,7 @@ typedef struct p2l_item_lookup_baton_t } p2l_item_lookup_baton_t; /* Implements svn_cache__partial_getter_func_t for P2L index pages, copying - * the svn_fs_x__id_part_t for the item described 2l_item_lookup_baton_t + * the svn_fs_x__id_t for the item described 2l_item_lookup_baton_t * *BATON. *OUT will be NULL if there is no matching index entry or the * sub-item is out of range. */ @@ -3366,7 +3366,7 @@ p2l_item_lookup_func(void **out, } svn_error_t * -svn_fs_x__p2l_item_lookup(svn_fs_x__id_part_t **item, +svn_fs_x__p2l_item_lookup(svn_fs_x__id_t **item, svn_fs_t *fs, svn_fs_x__revision_file_t *rev_file, svn_revnum_t revision, @@ -3375,7 +3375,7 @@ svn_fs_x__p2l_item_lookup(svn_fs_x__id_p apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_fs_x__page_cache_key_t key = { 0 }; svn_boolean_t is_cached = FALSE; p2l_page_info_baton_t page_info; @@ -3432,13 +3432,13 @@ svn_fs_x__p2l_get_max_offset(apr_off_t * svn_revnum_t revision, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; p2l_header_t *header; svn_boolean_t is_cached = FALSE; apr_off_t *offset_p; /* look for the header data in our cache */ - pair_cache_key_t key; + svn_fs_x__pair_cache_key_t key; key.revision = base_revision(fs, revision); key.second = svn_fs_x__is_packed_rev(fs, revision); @@ -3464,7 +3464,7 @@ svn_fs_x__item_offset(apr_off_t *absolut apr_uint32_t *sub_item, svn_fs_t *fs, svn_fs_x__revision_file_t *rev_file, - const svn_fs_x__id_part_t *item_id, + const svn_fs_x__id_t *item_id, apr_pool_t *scratch_pool) { if (svn_fs_x__is_txn(item_id->change_set)) @@ -3583,15 +3583,15 @@ typedef struct sub_item_ordered_t /* Array of pointers into ENTRY->ITEMS, sorted by their revision member * _descending_ order. May be NULL if ENTRY->ITEM_COUNT < 2. */ - svn_fs_x__id_part_t **order; + svn_fs_x__id_t **order; } sub_item_ordered_t; /* implements compare_fn_t. Place LHS before RHS, if the latter is younger. * Used to sort sub_item_ordered_t::order */ static int -compare_sub_items(const svn_fs_x__id_part_t * const * lhs, - const svn_fs_x__id_part_t * const * rhs) +compare_sub_items(const svn_fs_x__id_t * const * lhs, + const svn_fs_x__id_t * const * rhs) { return (*lhs)->change_set < (*rhs)->change_set ? 1 @@ -3605,8 +3605,8 @@ static int compare_p2l_info_rev(const sub_item_ordered_t * lhs, const sub_item_ordered_t * rhs) { - svn_fs_x__id_part_t *lhs_part; - svn_fs_x__id_part_t *rhs_part; + svn_fs_x__id_t *lhs_part; + svn_fs_x__id_t *rhs_part; assert(lhs != rhs); if (lhs->entry->item_count == 0) @@ -3697,7 +3697,7 @@ svn_fs_x__l2p_index_from_p2l_entries(con /* write index entries */ for (i = 0; i < count; ++i) { - svn_fs_x__id_part_t *sub_item; + svn_fs_x__id_t *sub_item; sub_item_ordered_t *ordered = svn_priority_queue__peek(queue); if (ordered->entry->item_count > 0) Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/index.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/index.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/index.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/index.h Wed Jan 21 16:22:19 2015 @@ -77,14 +77,14 @@ typedef struct svn_fs_x__p2l_entry_t apr_uint32_t item_count; /* List of items in that block / container */ - svn_fs_x__id_part_t *items; + svn_fs_x__id_t *items; } svn_fs_x__p2l_entry_t; -/* Return a (deep) copy of ENTRY, allocated in POOL. +/* Return a (deep) copy of ENTRY, allocated in RESULT_POOL. */ svn_fs_x__p2l_entry_t * svn_fs_x__p2l_entry_dup(const svn_fs_x__p2l_entry_t *entry, - apr_pool_t *pool); + apr_pool_t *result_pool); /* Open / create a log-to-phys index file with the full file path name * FILE_NAME. Return the open file in *PROTO_INDEX allocated in @@ -220,7 +220,7 @@ svn_fs_x__p2l_entry_lookup(svn_fs_x__p2l apr_pool_t *result_pool, apr_pool_t *scratch_pool); -/* Use the phys-to-log mapping files in FS to return the svn_fs_x__id_part_t +/* Use the phys-to-log mapping files in FS to return the svn_fs_x__id_t * for the SUB_ITEM of the container starting at global OFFSET in the rep / * pack file containing REVISION in *ITEM, allocated in RESULT_POOL. Sets * *ITEM to NULL if no element starts at exactly that offset or if it @@ -229,7 +229,7 @@ svn_fs_x__p2l_entry_lookup(svn_fs_x__p2l * Use SCRATCH_POOL for temporary allocations. */ svn_error_t * -svn_fs_x__p2l_item_lookup(svn_fs_x__id_part_t **item, +svn_fs_x__p2l_item_lookup(svn_fs_x__id_t **item, svn_fs_t *fs, svn_fs_x__revision_file_t *rev_file, svn_revnum_t revision, @@ -254,7 +254,7 @@ svn_fs_x__item_offset(apr_off_t *absolut apr_uint32_t *sub_item, svn_fs_t *fs, svn_fs_x__revision_file_t *rev_file, - const svn_fs_x__id_part_t *item_id, + const svn_fs_x__id_t *item_id, apr_pool_t *scratch_pool); /* Use the log-to-phys indexes in FS to determine the maximum item indexes Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/lock.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/lock.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/lock.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/lock.c Wed Jan 21 16:22:19 2015 @@ -37,6 +37,7 @@ #include "tree.h" #include "fs_x.h" #include "transaction.h" +#include "util.h" #include "../libsvn_fs/fs-loader.h" #include "private/svn_fs_util.h" @@ -103,8 +104,7 @@ hash_store(apr_hash_t *hash, of that value (if it exists). */ static const char * hash_fetch(apr_hash_t *hash, - const char *key, - apr_pool_t *pool) + const char *key) { svn_string_t *str = svn_hash_gets(hash, key); return str ? str->data : NULL; @@ -161,7 +161,7 @@ digest_path_from_path(const char **diges empty, if the versioned path in FS represented by DIGEST_PATH has no children) and LOCK (which may be NULL if that versioned path is lock itself locked). Set the permissions of DIGEST_PATH to those of - PERMS_REFERENCE. Use POOL for all allocations. + PERMS_REFERENCE. Use POOL for temporary allocations. */ static svn_error_t * write_digest_file(apr_hash_t *children, @@ -169,45 +169,53 @@ write_digest_file(apr_hash_t *children, const char *fs_path, const char *digest_path, const char *perms_reference, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { svn_error_t *err = SVN_NO_ERROR; svn_stream_t *stream; apr_hash_index_t *hi; - apr_hash_t *hash = apr_hash_make(pool); + apr_hash_t *hash = apr_hash_make(scratch_pool); const char *tmp_path; SVN_ERR(svn_fs_x__ensure_dir_exists(svn_dirent_join(fs_path, PATH_LOCKS_DIR, - pool), fs_path, pool)); - SVN_ERR(svn_fs_x__ensure_dir_exists(svn_dirent_dirname(digest_path, pool), - fs_path, pool)); + scratch_pool), + fs_path, scratch_pool)); + SVN_ERR(svn_fs_x__ensure_dir_exists(svn_dirent_dirname(digest_path, + scratch_pool), + fs_path, scratch_pool)); if (lock) { const char *creation_date = NULL, *expiration_date = NULL; if (lock->creation_date) - creation_date = svn_time_to_cstring(lock->creation_date, pool); + creation_date = svn_time_to_cstring(lock->creation_date, + scratch_pool); if (lock->expiration_date) - expiration_date = svn_time_to_cstring(lock->expiration_date, pool); + expiration_date = svn_time_to_cstring(lock->expiration_date, + scratch_pool); + hash_store(hash, PATH_KEY, sizeof(PATH_KEY)-1, - lock->path, APR_HASH_KEY_STRING, pool); + lock->path, APR_HASH_KEY_STRING, scratch_pool); hash_store(hash, TOKEN_KEY, sizeof(TOKEN_KEY)-1, - lock->token, APR_HASH_KEY_STRING, pool); + lock->token, APR_HASH_KEY_STRING, scratch_pool); hash_store(hash, OWNER_KEY, sizeof(OWNER_KEY)-1, - lock->owner, APR_HASH_KEY_STRING, pool); + lock->owner, APR_HASH_KEY_STRING, scratch_pool); hash_store(hash, COMMENT_KEY, sizeof(COMMENT_KEY)-1, - lock->comment, APR_HASH_KEY_STRING, pool); + lock->comment, APR_HASH_KEY_STRING, scratch_pool); hash_store(hash, IS_DAV_COMMENT_KEY, sizeof(IS_DAV_COMMENT_KEY)-1, - lock->is_dav_comment ? "1" : "0", 1, pool); + lock->is_dav_comment ? "1" : "0", 1, scratch_pool); hash_store(hash, CREATION_DATE_KEY, sizeof(CREATION_DATE_KEY)-1, - creation_date, APR_HASH_KEY_STRING, pool); + creation_date, APR_HASH_KEY_STRING, scratch_pool); hash_store(hash, EXPIRATION_DATE_KEY, sizeof(EXPIRATION_DATE_KEY)-1, - expiration_date, APR_HASH_KEY_STRING, pool); + expiration_date, APR_HASH_KEY_STRING, scratch_pool); } if (apr_hash_count(children)) { - svn_stringbuf_t *children_list = svn_stringbuf_create_empty(pool); - for (hi = apr_hash_first(pool, children); hi; hi = apr_hash_next(hi)) + svn_stringbuf_t *children_list + = svn_stringbuf_create_empty(scratch_pool); + for (hi = apr_hash_first(scratch_pool, children); + hi; + hi = apr_hash_next(hi)) { svn_stringbuf_appendbytes(children_list, apr_hash_this_key(hi), @@ -215,24 +223,28 @@ write_digest_file(apr_hash_t *children, svn_stringbuf_appendbyte(children_list, '\n'); } hash_store(hash, CHILDREN_KEY, sizeof(CHILDREN_KEY)-1, - children_list->data, children_list->len, pool); + children_list->data, children_list->len, scratch_pool); } SVN_ERR(svn_stream_open_unique(&stream, &tmp_path, - svn_dirent_dirname(digest_path, pool), - svn_io_file_del_none, pool, pool)); - if ((err = svn_hash_write2(hash, stream, SVN_HASH_TERMINATOR, pool))) + svn_dirent_dirname(digest_path, + scratch_pool), + svn_io_file_del_none, scratch_pool, + scratch_pool)); + if ((err = svn_hash_write2(hash, stream, SVN_HASH_TERMINATOR, + scratch_pool))) { svn_error_clear(svn_stream_close(stream)); return svn_error_createf(err->apr_err, err, _("Cannot write lock/entries hashfile '%s'"), - svn_dirent_local_style(tmp_path, pool)); + svn_dirent_local_style(tmp_path, + scratch_pool)); } SVN_ERR(svn_stream_close(stream)); - SVN_ERR(svn_io_file_rename(tmp_path, digest_path, pool)); - SVN_ERR(svn_io_copy_perms(perms_reference, digest_path, pool)); + SVN_ERR(svn_io_file_rename(tmp_path, digest_path, scratch_pool)); + SVN_ERR(svn_io_copy_perms(perms_reference, digest_path, scratch_pool)); return SVN_NO_ERROR; } @@ -284,7 +296,7 @@ read_digest_file(apr_hash_t **children_p /* If our caller cares, see if we have a lock path in our hash. If so, we'll assume we have a lock here. */ - val = hash_fetch(hash, PATH_KEY, pool); + val = hash_fetch(hash, PATH_KEY); if (val && lock_p) { const char *path = val; @@ -293,30 +305,30 @@ read_digest_file(apr_hash_t **children_p lock = svn_lock_create(pool); lock->path = path; - if (! ((lock->token = hash_fetch(hash, TOKEN_KEY, pool)))) + if (! ((lock->token = hash_fetch(hash, TOKEN_KEY)))) return svn_error_trace(err_corrupt_lockfile(fs_path, path)); - if (! ((lock->owner = hash_fetch(hash, OWNER_KEY, pool)))) + if (! ((lock->owner = hash_fetch(hash, OWNER_KEY)))) return svn_error_trace(err_corrupt_lockfile(fs_path, path)); - if (! ((val = hash_fetch(hash, IS_DAV_COMMENT_KEY, pool)))) + if (! ((val = hash_fetch(hash, IS_DAV_COMMENT_KEY)))) return svn_error_trace(err_corrupt_lockfile(fs_path, path)); lock->is_dav_comment = (val[0] == '1'); - if (! ((val = hash_fetch(hash, CREATION_DATE_KEY, pool)))) + if (! ((val = hash_fetch(hash, CREATION_DATE_KEY)))) return svn_error_trace(err_corrupt_lockfile(fs_path, path)); SVN_ERR(svn_time_from_cstring(&(lock->creation_date), val, pool)); - if ((val = hash_fetch(hash, EXPIRATION_DATE_KEY, pool))) + if ((val = hash_fetch(hash, EXPIRATION_DATE_KEY))) SVN_ERR(svn_time_from_cstring(&(lock->expiration_date), val, pool)); - lock->comment = hash_fetch(hash, COMMENT_KEY, pool); + lock->comment = hash_fetch(hash, COMMENT_KEY); *lock_p = lock; } /* If our caller cares, see if we have any children for this path. */ - val = hash_fetch(hash, CHILDREN_KEY, pool); + val = hash_fetch(hash, CHILDREN_KEY); if (val && children_p) { apr_array_header_t *kiddos = svn_cstring_split(val, "\n", FALSE, pool); @@ -345,19 +357,21 @@ static svn_error_t * set_lock(const char *fs_path, svn_lock_t *lock, const char *perms_reference, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { const char *digest_path; apr_hash_t *children; - SVN_ERR(digest_path_from_path(&digest_path, fs_path, lock->path, pool)); + SVN_ERR(digest_path_from_path(&digest_path, fs_path, lock->path, + scratch_pool)); /* We could get away without reading the file as children should always come back empty. */ - SVN_ERR(read_digest_file(&children, NULL, fs_path, digest_path, pool)); + SVN_ERR(read_digest_file(&children, NULL, fs_path, digest_path, + scratch_pool)); SVN_ERR(write_digest_file(children, lock, fs_path, digest_path, - perms_reference, pool)); + perms_reference, scratch_pool)); return SVN_NO_ERROR; } @@ -365,13 +379,13 @@ set_lock(const char *fs_path, static svn_error_t * delete_lock(const char *fs_path, const char *path, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { const char *digest_path; - SVN_ERR(digest_path_from_path(&digest_path, fs_path, path, pool)); + SVN_ERR(digest_path_from_path(&digest_path, fs_path, path, scratch_pool)); - SVN_ERR(svn_io_remove_file2(digest_path, TRUE, pool)); + SVN_ERR(svn_io_remove_file2(digest_path, TRUE, scratch_pool)); return SVN_NO_ERROR; } @@ -381,7 +395,7 @@ add_to_digest(const char *fs_path, apr_array_header_t *paths, const char *index_path, const char *perms_reference, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { const char *index_digest_path; apr_hash_t *children; @@ -389,9 +403,10 @@ add_to_digest(const char *fs_path, int i; unsigned int original_count; - SVN_ERR(digest_path_from_path(&index_digest_path, fs_path, index_path, pool)); - - SVN_ERR(read_digest_file(&children, &lock, fs_path, index_digest_path, pool)); + SVN_ERR(digest_path_from_path(&index_digest_path, fs_path, index_path, + scratch_pool)); + SVN_ERR(read_digest_file(&children, &lock, fs_path, index_digest_path, + scratch_pool)); original_count = apr_hash_count(children); @@ -400,14 +415,15 @@ add_to_digest(const char *fs_path, const char *path = APR_ARRAY_IDX(paths, i, const char *); const char *digest_path, *digest_file; - SVN_ERR(digest_path_from_path(&digest_path, fs_path, path, pool)); + SVN_ERR(digest_path_from_path(&digest_path, fs_path, path, + scratch_pool)); digest_file = svn_dirent_basename(digest_path, NULL); svn_hash_sets(children, digest_file, (void *)1); } if (apr_hash_count(children) != original_count) SVN_ERR(write_digest_file(children, lock, fs_path, index_digest_path, - perms_reference, pool)); + perms_reference, scratch_pool)); return SVN_NO_ERROR; } @@ -417,32 +433,34 @@ delete_from_digest(const char *fs_path, apr_array_header_t *paths, const char *index_path, const char *perms_reference, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { const char *index_digest_path; apr_hash_t *children; svn_lock_t *lock; int i; - SVN_ERR(digest_path_from_path(&index_digest_path, fs_path, index_path, pool)); - - SVN_ERR(read_digest_file(&children, &lock, fs_path, index_digest_path, pool)); + SVN_ERR(digest_path_from_path(&index_digest_path, fs_path, index_path, + scratch_pool)); + SVN_ERR(read_digest_file(&children, &lock, fs_path, index_digest_path, + scratch_pool)); for (i = 0; i < paths->nelts; ++i) { const char *path = APR_ARRAY_IDX(paths, i, const char *); const char *digest_path, *digest_file; - SVN_ERR(digest_path_from_path(&digest_path, fs_path, path, pool)); + SVN_ERR(digest_path_from_path(&digest_path, fs_path, path, + scratch_pool)); digest_file = svn_dirent_basename(digest_path, NULL); svn_hash_sets(children, digest_file, NULL); } if (apr_hash_count(children) || lock) SVN_ERR(write_digest_file(children, lock, fs_path, index_digest_path, - perms_reference, pool)); + perms_reference, scratch_pool)); else - SVN_ERR(svn_io_remove_file2(index_digest_path, TRUE, pool)); + SVN_ERR(svn_io_remove_file2(index_digest_path, TRUE, scratch_pool)); return SVN_NO_ERROR; } @@ -529,11 +547,12 @@ get_lock_helper(svn_fs_t *fs, /* Baton for locks_walker(). */ -struct walk_locks_baton { +typedef struct walk_locks_baton_t +{ svn_fs_get_locks_callback_t get_locks_func; void *get_locks_baton; svn_fs_t *fs; -}; +} walk_locks_baton_t; /* Implements walk_digests_callback_t. */ static svn_error_t * @@ -545,7 +564,7 @@ locks_walker(void *baton, svn_boolean_t have_write_lock, apr_pool_t *pool) { - struct walk_locks_baton *wlb = baton; + walk_locks_baton_t *wlb = baton; if (lock) { @@ -632,7 +651,7 @@ walk_locks(svn_fs_t *fs, svn_boolean_t have_write_lock, apr_pool_t *pool) { - struct walk_locks_baton wlb; + walk_locks_baton_t wlb; wlb.get_locks_func = get_locks_func; wlb.get_locks_baton = get_locks_baton; @@ -652,8 +671,7 @@ walk_locks(svn_fs_t *fs, */ static svn_error_t * verify_lock(svn_fs_t *fs, - svn_lock_t *lock, - apr_pool_t *pool) + svn_lock_t *lock) { if ((! fs->access_ctx) || (! fs->access_ctx->username)) return svn_error_createf @@ -684,7 +702,7 @@ get_locks_callback(void *baton, svn_lock_t *lock, apr_pool_t *pool) { - return verify_lock(baton, lock, pool); + return verify_lock(baton, lock); } @@ -694,30 +712,32 @@ svn_fs_x__allow_locked_operation(const c svn_fs_t *fs, svn_boolean_t recurse, svn_boolean_t have_write_lock, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - path = svn_fs__canonicalize_abspath(path, pool); + path = svn_fs__canonicalize_abspath(path, scratch_pool); if (recurse) { /* Discover all locks at or below the path. */ const char *digest_path; - SVN_ERR(digest_path_from_path(&digest_path, fs->path, path, pool)); + SVN_ERR(digest_path_from_path(&digest_path, fs->path, path, + scratch_pool)); SVN_ERR(walk_locks(fs, digest_path, get_locks_callback, - fs, have_write_lock, pool)); + fs, have_write_lock, scratch_pool)); } else { /* Discover and verify any lock attached to the path. */ svn_lock_t *lock; - SVN_ERR(get_lock_helper(fs, &lock, path, have_write_lock, pool)); + SVN_ERR(get_lock_helper(fs, &lock, path, have_write_lock, + scratch_pool)); if (lock) - SVN_ERR(verify_lock(fs, lock, pool)); + SVN_ERR(verify_lock(fs, lock)); } return SVN_NO_ERROR; } /* The effective arguments for lock_body() below. */ -struct lock_baton { +typedef struct lock_baton_t { svn_fs_t *fs; apr_array_header_t *targets; apr_array_header_t *infos; @@ -726,13 +746,13 @@ struct lock_baton { apr_time_t expiration_date; svn_boolean_t steal_lock; apr_pool_t *result_pool; -}; +} lock_baton_t; static svn_error_t * check_lock(svn_error_t **fs_err, const char *path, const svn_fs_lock_target_t *target, - struct lock_baton *lb, + lock_baton_t *lb, svn_fs_root_t *root, apr_pool_t *pool) { @@ -826,16 +846,16 @@ check_lock(svn_error_t **fs_err, return SVN_NO_ERROR; } -struct lock_info_t { +typedef struct lock_info_t { const char *path; const char *component; svn_lock_t *lock; svn_error_t *fs_err; -}; +} lock_info_t; /* The body of svn_fs_x__lock(), which see. - BATON is a 'struct lock_baton *' holding the effective arguments. + BATON is a 'lock_baton_t *' holding the effective arguments. BATON->targets is an array of 'svn_sort__item_t' targets, sorted by path, mapping canonical path to 'svn_fs_lock_target_t'. Set BATON->infos to an array of 'lock_info_t' holding the results. For @@ -847,7 +867,7 @@ struct lock_info_t { static svn_error_t * lock_body(void *baton, apr_pool_t *pool) { - struct lock_baton *lb = baton; + lock_baton_t *lb = baton; svn_fs_root_t *root; svn_revnum_t youngest; const char *rev_0_path; @@ -855,7 +875,7 @@ lock_body(void *baton, apr_pool_t *pool) apr_pool_t *iterpool = svn_pool_create(pool); lb->infos = apr_array_make(lb->result_pool, lb->targets->nelts, - sizeof(struct lock_info_t)); + sizeof(lock_info_t)); /* Until we implement directory locks someday, we only allow locks on files or non-existent paths. */ @@ -869,7 +889,7 @@ lock_body(void *baton, apr_pool_t *pool) const svn_sort__item_t *item = &APR_ARRAY_IDX(lb->targets, i, svn_sort__item_t); const svn_fs_lock_target_t *target = item->value; - struct lock_info_t info; + lock_info_t info; svn_pool_clear(iterpool); @@ -877,7 +897,7 @@ lock_body(void *baton, apr_pool_t *pool) SVN_ERR(check_lock(&info.fs_err, info.path, target, lb, root, iterpool)); info.lock = NULL; info.component = NULL; - APR_ARRAY_PUSH(lb->infos, struct lock_info_t) = info; + APR_ARRAY_PUSH(lb->infos, lock_info_t) = info; if (!info.fs_err) ++outstanding; } @@ -915,8 +935,7 @@ lock_body(void *baton, apr_pool_t *pool) for (i = 0; i < lb->infos->nelts; ++i) { - struct lock_info_t *info = &APR_ARRAY_IDX(lb->infos, i, - struct lock_info_t); + lock_info_t *info = &APR_ARRAY_IDX(lb->infos, i, lock_info_t); const svn_sort__item_t *item = &APR_ARRAY_IDX(lb->targets, i, svn_sort__item_t); const svn_fs_lock_target_t *target = item->value; @@ -994,7 +1013,7 @@ lock_body(void *baton, apr_pool_t *pool) } /* The effective arguments for unlock_body() below. */ -struct unlock_baton { +typedef struct unlock_baton_t { svn_fs_t *fs; apr_array_header_t *targets; apr_array_header_t *infos; @@ -1002,13 +1021,13 @@ struct unlock_baton { svn_boolean_t skip_check; svn_boolean_t break_lock; apr_pool_t *result_pool; -}; +} unlock_baton_t; static svn_error_t * check_unlock(svn_error_t **fs_err, const char *path, const char *token, - struct unlock_baton *ub, + unlock_baton_t *ub, svn_fs_root_t *root, apr_pool_t *pool) { @@ -1028,17 +1047,17 @@ check_unlock(svn_error_t **fs_err, return SVN_NO_ERROR; } -struct unlock_info_t { +typedef struct unlock_info_t { const char *path; const char *component; svn_error_t *fs_err; svn_boolean_t done; int components; -}; +} unlock_info_t; /* The body of svn_fs_x__unlock(), which see. - BATON is a 'struct unlock_baton *' holding the effective arguments. + BATON is a 'unlock_baton_t *' holding the effective arguments. BATON->targets is an array of 'svn_sort__item_t' targets, sorted by path, mapping canonical path to (const char *) token. Set BATON->infos to an array of 'unlock_info_t' results. For the other @@ -1050,7 +1069,7 @@ struct unlock_info_t { static svn_error_t * unlock_body(void *baton, apr_pool_t *pool) { - struct unlock_baton *ub = baton; + unlock_baton_t *ub = baton; svn_fs_root_t *root; svn_revnum_t youngest; const char *rev_0_path; @@ -1058,7 +1077,7 @@ unlock_body(void *baton, apr_pool_t *poo apr_pool_t *iterpool = svn_pool_create(pool); ub->infos = apr_array_make(ub->result_pool, ub->targets->nelts, - sizeof(struct unlock_info_t)); + sizeof( unlock_info_t)); SVN_ERR(ub->fs->vtable->youngest_rev(&youngest, ub->fs, pool)); SVN_ERR(ub->fs->vtable->revision_root(&root, ub->fs, youngest, pool)); @@ -1068,7 +1087,7 @@ unlock_body(void *baton, apr_pool_t *poo const svn_sort__item_t *item = &APR_ARRAY_IDX(ub->targets, i, svn_sort__item_t); const char *token = item->value; - struct unlock_info_t info = { 0 }; + unlock_info_t info = { 0 }; svn_pool_clear(iterpool); @@ -1093,7 +1112,7 @@ unlock_body(void *baton, apr_pool_t *poo ++outstanding; } - APR_ARRAY_PUSH(ub->infos, struct unlock_info_t) = info; + APR_ARRAY_PUSH(ub->infos, unlock_info_t) = info; } rev_0_path = svn_fs_x__path_rev_absolute(ub->fs, 0, pool); @@ -1109,8 +1128,7 @@ unlock_body(void *baton, apr_pool_t *poo for (j = 0; j < ub->infos->nelts; ++j) { - struct unlock_info_t *info = &APR_ARRAY_IDX(ub->infos, j, - struct unlock_info_t); + unlock_info_t *info = &APR_ARRAY_IDX(ub->infos, j, unlock_info_t); if (!info->fs_err && info->path) { @@ -1168,11 +1186,11 @@ unlock_body(void *baton, apr_pool_t *poo static svn_error_t * unlock_single(svn_fs_t *fs, svn_lock_t *lock, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - struct unlock_baton ub; + unlock_baton_t ub; svn_sort__item_t item; - apr_array_header_t *targets = apr_array_make(pool, 1, + apr_array_header_t *targets = apr_array_make(scratch_pool, 1, sizeof(svn_sort__item_t)); item.key = lock->path; item.klen = strlen(item.key); @@ -1182,10 +1200,10 @@ unlock_single(svn_fs_t *fs, ub.fs = fs; ub.targets = targets; ub.skip_check = TRUE; - ub.result_pool = pool; + ub.result_pool = scratch_pool; /* No ub.infos[].fs_err error because skip_check is TRUE. */ - SVN_ERR(unlock_body(&ub, pool)); + SVN_ERR(unlock_body(&ub, scratch_pool)); return SVN_NO_ERROR; } @@ -1205,7 +1223,7 @@ svn_fs_x__lock(svn_fs_t *fs, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - struct lock_baton lb; + lock_baton_t lb; apr_array_header_t *sorted_targets; apr_hash_t *canonical_targets = apr_hash_make(scratch_pool); apr_hash_index_t *hi; @@ -1299,7 +1317,7 @@ svn_fs_x__unlock(svn_fs_t *fs, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - struct unlock_baton ub; + unlock_baton_t ub; apr_array_header_t *sorted_targets; apr_hash_t *canonical_targets = apr_hash_make(scratch_pool); apr_hash_index_t *hi; @@ -1338,8 +1356,7 @@ svn_fs_x__unlock(svn_fs_t *fs, err = svn_fs_x__with_write_lock(fs, unlock_body, &ub, scratch_pool); for (i = 0; i < ub.infos->nelts; ++i) { - struct unlock_info_t *info = &APR_ARRAY_IDX(ub.infos, i, - struct unlock_info_t); + unlock_info_t *info = &APR_ARRAY_IDX(ub.infos, i, unlock_info_t); if (!cb_err && lock_callback) { if (!info->done && !info->fs_err) @@ -1434,13 +1451,13 @@ svn_fs_x__get_locks(svn_fs_t *fs, svn_depth_t depth, svn_fs_get_locks_callback_t get_locks_func, void *get_locks_baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { const char *digest_path; get_locks_filter_baton_t glfb; SVN_ERR(svn_fs__check_fs(fs, TRUE)); - path = svn_fs__canonicalize_abspath(path, pool); + path = svn_fs__canonicalize_abspath(path, scratch_pool); glfb.path = path; glfb.requested_depth = depth; @@ -1448,8 +1465,8 @@ svn_fs_x__get_locks(svn_fs_t *fs, glfb.get_locks_baton = get_locks_baton; /* Get the top digest path in our tree of interest, and then walk it. */ - SVN_ERR(digest_path_from_path(&digest_path, fs->path, path, pool)); + SVN_ERR(digest_path_from_path(&digest_path, fs->path, path, scratch_pool)); SVN_ERR(walk_locks(fs, digest_path, get_locks_filter_func, &glfb, - FALSE, pool)); + FALSE, scratch_pool)); return SVN_NO_ERROR; }
