int a_svn_sparse_checkout (char *repository_path, char *temp_working_dir, apr_pool_t *apr_pool, apr_pool_t *svn_pool) /* * * SVN sparse checkout - check out an _empty_ subversion dir * */ { svn_error_t* err; int int_err; apr_array_header_t *device_arr; svn_error_t *svn_err; struct stat checked_file_info; char temp_svn_path[MAXPATH]; svn_client_ctx_t* context; a_debug_info2(DEBUGLVL5,"a_svn_sparse_checkout: args: [%s], [%s]",repository_path,temp_working_dir); /* if we have gotten this far - we are free to remove temporary */ /* svn directory for this device (if it exists for some reason). */ a_remove_directory(temp_working_dir); strncpy(temp_svn_path,temp_working_dir,MAXPATH); svn_err = svn_client_create_context( &context, svn_pool ); if(svn_err){a_logmsg("a_svn_sparse_checkout: svn error: %s",svn_err->message); a_debug_info2(DEBUGLVL5,"a_svn_sparse_checkout: svn error: %s",svn_err->message); return -2;} svn_opt_revision_t pegrevision; pegrevision.kind = svn_opt_revision_unspecified; svn_opt_revision_t revision; revision.kind = svn_opt_revision_head; svn_err = svn_client_checkout3(NULL, repository_path, temp_svn_path, &pegrevision, &revision, svn_depth_empty, FALSE, FALSE, context, svn_pool ); if(svn_err){a_logmsg("a_svn_sparse_checkout: svn error: %s",svn_err->message); a_debug_info2(DEBUGLVL5,"a_svn_sparse_checkout: svn error: %s",svn_err->message); a_debug_info2(DEBUGLVL5,"a_svn_sparse_checkout: svn error code: %d",svn_err->apr_err); return -2;} return 1; }
/* Create an empty repository and WC for the test TEST_NAME. Set *REPOS_URL * to the URL of the new repository and *WC_ABSPATH to the root path of the * new WC. * * Create the repository and WC in subdirectories called * REPOSITORIES_WORK_DIR/TEST_NAME and WCS_WORK_DIR/TEST_NAME respectively, * within the current working directory. * * Register the repo and WC to be cleaned up when the test suite exits. */ static svn_error_t * create_repos_and_wc(const char **repos_url, const char **wc_abspath, const char *test_name, const svn_test_opts_t *opts, apr_pool_t *pool) { const char *repos_path = svn_relpath_join(REPOSITORIES_WORK_DIR, test_name, pool); const char *wc_path = svn_relpath_join(WCS_WORK_DIR, test_name, pool); /* Remove the repo and WC dirs if they already exist, to ensure the test * will run even if a previous failed attempt was not cleaned up. */ SVN_ERR(svn_io_remove_dir2(repos_path, TRUE, NULL, NULL, pool)); SVN_ERR(svn_io_remove_dir2(wc_path, TRUE, NULL, NULL, pool)); /* Create the parent dirs of the repo and WC if necessary. */ SVN_ERR(svn_io_make_dir_recursively(REPOSITORIES_WORK_DIR, pool)); SVN_ERR(svn_io_make_dir_recursively(WCS_WORK_DIR, pool)); /* Create a repos. Register it for clean-up. Set *REPOS_URL to its path. */ { svn_repos_t *repos; /* Use a subpool to create the repository and then destroy the subpool so the repository's underlying filesystem is closed. If opts->fs_type is BDB this prevents any attempt to open a second environment handle within the same process when we checkout the WC below. BDB 4.4+ allows only a single environment handle to be open per process. */ apr_pool_t *subpool = svn_pool_create(pool); SVN_ERR(svn_test__create_repos(&repos, repos_path, opts, subpool)); SVN_ERR(svn_uri_get_file_url_from_dirent(repos_url, repos_path, pool)); svn_pool_destroy(subpool); } /* Create a WC. Set *WC_ABSPATH to its path. */ { apr_pool_t *subpool = svn_pool_create(pool); /* To cleanup CTX */ svn_client_ctx_t *ctx; svn_opt_revision_t head_rev = { svn_opt_revision_head, {0} }; SVN_ERR(svn_client_create_context(&ctx, subpool)); SVN_ERR(svn_dirent_get_absolute(wc_abspath, wc_path, pool)); SVN_ERR(svn_client_checkout3(NULL, *repos_url, *wc_abspath, &head_rev, &head_rev, svn_depth_infinity, FALSE /* ignore_externals */, FALSE /* allow_unver_obstructions */, ctx, subpool)); svn_pool_destroy(subpool); } /* Register this WC for cleanup. */ svn_test_add_dir_cleanup(*wc_abspath); return SVN_NO_ERROR; }
int a_svn_checkout (char *device_name, char *repository_path, char *temp_working_dir, apr_pool_t *apr_pool, apr_pool_t *svn_pool) /* * * SVN checkout - check out single file from subversion * */ { svn_error_t* err; int int_err; apr_array_header_t *device_arr; svn_error_t *svn_err; struct stat checked_file_info; char temp_svn_path[MAXPATH]; svn_client_ctx_t* context1; svn_client_ctx_t* context2; a_debug_info2(DEBUGLVL5,"a_svn_checkout: args: [%s], [%s], [%s]", device_name,repository_path,temp_working_dir); /* if we have gotten this far - we are free to remove temporary */ /* svn directory for this device (if it exists for some reason). */ a_remove_directory(temp_working_dir); strcpy(temp_svn_path,temp_working_dir); svn_err = svn_client_create_context(&context1, svn_pool); if(svn_err){a_logmsg("%s: svn error: %s",device_name,svn_err->message); a_debug_info2(DEBUGLVL5,"a_svn_checkout: svn error: %s",svn_err->message); return -2;} svn_err = svn_client_create_context(&context2, svn_pool); if(svn_err){ a_logmsg("%s: svn error: %s",device_name,svn_err->message); a_debug_info2(DEBUGLVL5,"a_svn_checkout: svn error: %s",svn_err->message); return -2; } svn_opt_revision_t pegrevision; pegrevision.kind = svn_opt_revision_unspecified; svn_opt_revision_t revision; revision.kind = svn_opt_revision_head; svn_err = svn_client_checkout3(NULL, repository_path, temp_svn_path, &pegrevision, &revision, svn_depth_empty, FALSE, FALSE, context1, svn_pool ); if(svn_err) { a_logmsg("%s: svn error: %s",device_name,svn_err->message); a_debug_info2(DEBUGLVL5,"a_svn_checkout: svn error: %s",svn_err->message); a_debug_info2(DEBUGLVL5,"a_svn_checkout: svn error code: %d",svn_err->apr_err); /* checked out dir doesn't exist - special action needed: */ if(strstr(svn_err->message,"doesn't exist")) return -3; else return -2; } device_arr = apr_array_make(apr_pool, 1, sizeof(const char*)); strcat(temp_svn_path,"/"); strcat(temp_svn_path,device_name); *(const char**)apr_array_push(device_arr) = temp_svn_path; svn_err = svn_client_update3(NULL, device_arr, &revision, svn_depth_empty, FALSE, FALSE, FALSE, context2, svn_pool ); if(svn_err){a_logmsg("%s: svn error: %s",device_name,svn_err->message); a_debug_info2(DEBUGLVL5,"a_svn_checkout: svn error: %s",svn_err->message); return -2;} if(stat(temp_svn_path,&checked_file_info) != -1) return (int)checked_file_info.st_size; else return -1; }