Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_repos/repos.c view on Meta::CPAN
sub_path = &path[ctx->src_len+1];
/* Check if we are inside db directory and if so skip it */
if (svn_path_compare_paths
(svn_dirent_get_longest_ancestor(SVN_REPOS__DB_DIR, sub_path, pool),
SVN_REPOS__DB_DIR) == 0)
return SVN_NO_ERROR;
if (svn_path_compare_paths
(svn_dirent_get_longest_ancestor(SVN_REPOS__LOCK_DIR, sub_path,
pool),
SVN_REPOS__LOCK_DIR) == 0)
return SVN_NO_ERROR;
if (svn_path_compare_paths
(svn_dirent_get_longest_ancestor(SVN_REPOS__FORMAT, sub_path, pool),
SVN_REPOS__FORMAT) == 0)
return SVN_NO_ERROR;
}
target = svn_dirent_join(ctx->dest, sub_path, pool);
if (finfo->filetype == APR_DIR)
{
svn_error_t *err;
err = create_repos_dir(target, pool);
if (ctx->incremental && err && err->apr_err == SVN_ERR_DIR_NOT_EMPTY)
{
svn_error_clear(err);
err = SVN_NO_ERROR;
}
return svn_error_trace(err);
}
else if (finfo->filetype == APR_REG)
return svn_io_copy_file(path, target, TRUE, pool);
else if (finfo->filetype == APR_LNK)
return svn_io_copy_link(path, target, pool);
else
return SVN_NO_ERROR;
}
/** Obtain a lock on db logs lock file. Create one if it does not exist.
*/
static svn_error_t *
lock_db_logs_file(svn_repos_t *repos,
svn_boolean_t exclusive,
apr_pool_t *pool)
{
const char * lock_file = svn_repos_db_logs_lockfile(repos, pool);
/* Try to create a lock file, in case if it is missing. As in case of the
repositories created before hotcopy functionality. */
svn_error_clear(create_db_logs_lock(repos, pool));
return svn_io_file_lock2(lock_file, exclusive, FALSE, pool);
}
/* Make a copy of a repository with hot backup of fs. */
svn_error_t *
svn_repos_hotcopy2(const char *src_path,
const char *dst_path,
svn_boolean_t clean_logs,
svn_boolean_t incremental,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *pool)
{
svn_repos_t *src_repos;
svn_repos_t *dst_repos;
struct hotcopy_ctx_t hotcopy_context;
svn_error_t *err;
const char *src_abspath;
const char *dst_abspath;
SVN_ERR(svn_dirent_get_absolute(&src_abspath, src_path, pool));
SVN_ERR(svn_dirent_get_absolute(&dst_abspath, dst_path, pool));
if (strcmp(src_abspath, dst_abspath) == 0)
return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
_("Hotcopy source and destination are equal"));
/* Try to open original repository */
SVN_ERR(get_repos(&src_repos, src_abspath,
FALSE, FALSE,
FALSE, /* don't try to open the db yet. */
NULL,
pool));
/* If we are going to clean logs, then get an exclusive lock on
db-logs.lock, to ensure that no one else will work with logs.
If we are just copying, then get a shared lock to ensure that
no one else will clean logs while we copying them */
SVN_ERR(lock_db_logs_file(src_repos, clean_logs, pool));
/* Copy the repository to a new path, with exception of
specially handled directories */
hotcopy_context.dest = dst_abspath;
hotcopy_context.src_len = strlen(src_abspath);
hotcopy_context.incremental = incremental;
hotcopy_context.cancel_func = cancel_func;
hotcopy_context.cancel_baton = cancel_baton;
SVN_ERR(svn_io_dir_walk2(src_abspath,
0,
hotcopy_structure,
&hotcopy_context,
pool));
/* Prepare dst_repos object so that we may create locks,
so that we may open repository */
dst_repos = create_svn_repos_t(dst_abspath, pool);
dst_repos->fs_type = src_repos->fs_type;
dst_repos->format = src_repos->format;
err = create_locks(dst_repos, pool);
if (err)
( run in 1.019 second using v1.01-cache-2.11-cpan-97f6503c9c8 )