static svn_error_t * file_add(const char *path, void *parent_baton, const char *copyfrom_path, svn_revnum_t copyfrom_revision, apr_pool_t *result_pool, void **file_baton) { struct dir_baton_t *pb = parent_baton; struct edit_baton_t *eb = pb->eb; apr_pool_t *file_pool = svn_pool_create(pb->pool); struct file_baton_t *fb = apr_pcalloc(file_pool, sizeof(*fb)); svn_boolean_t under_root; pb->users++; fb->pool = file_pool; fb->eb = eb; fb->pb = pb; SVN_ERR(svn_dirent_is_under_root(&under_root, &fb->local_abspath, eb->anchor_abspath, path, fb->pool)); if (! under_root) { return svn_error_createf( SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL, _("Path '%s' is not in the working copy"), svn_dirent_local_style(path, fb->pool)); } *file_baton = fb; return SVN_NO_ERROR; }
static svn_error_t * get_path(const char **local_abspath_p, const char *anchor_abspath, const char *path, apr_pool_t *result_pool) { svn_boolean_t under_root; SVN_ERR(svn_dirent_is_under_root(&under_root, local_abspath_p, anchor_abspath, path, result_pool)); if (! under_root) { return svn_error_createf( SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL, _("Path '%s' is not in the working copy"), svn_dirent_local_style(path, result_pool)); } return SVN_NO_ERROR; }
static svn_error_t * dir_add(const char *path, void *parent_baton, const char *copyfrom_path, svn_revnum_t copyfrom_revision, apr_pool_t *result_pool, void **child_baton) { struct dir_baton_t *pb = parent_baton; struct edit_baton_t *eb = pb->eb; apr_pool_t *dir_pool = svn_pool_create(pb->pool); struct dir_baton_t *db = apr_pcalloc(dir_pool, sizeof(*db)); svn_boolean_t under_root; pb->users++; db->pb = pb; db->eb = pb->eb; db->pool = dir_pool; db->users = 1; SVN_ERR(svn_dirent_is_under_root(&under_root, &db->local_abspath, eb->anchor_abspath, path, db->pool)); if (! under_root) { return svn_error_createf( SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL, _("Path '%s' is not in the working copy"), svn_dirent_local_style(path, db->pool)); } SVN_ERR(svn_io_make_dir_recursively(db->local_abspath, db->pool)); *child_baton = db; return SVN_NO_ERROR; }
static svn_error_t * handle_externals_change(svn_client_ctx_t *ctx, const char *repos_root_url, svn_boolean_t *timestamp_sleep, const char *local_abspath, const char *new_desc_text, apr_hash_t *old_externals, svn_depth_t ambient_depth, svn_depth_t requested_depth, apr_pool_t *scratch_pool) { apr_array_header_t *new_desc; int i; apr_pool_t *iterpool; const char *url; iterpool = svn_pool_create(scratch_pool); SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); /* Bag out if the depth here is too shallow for externals action. */ if ((requested_depth < svn_depth_infinity && requested_depth != svn_depth_unknown) || (ambient_depth < svn_depth_infinity && requested_depth < svn_depth_infinity)) return SVN_NO_ERROR; if (new_desc_text) SVN_ERR(svn_wc_parse_externals_description3(&new_desc, local_abspath, new_desc_text, FALSE, scratch_pool)); else new_desc = NULL; SVN_ERR(svn_wc__node_get_url(&url, ctx->wc_ctx, local_abspath, scratch_pool, iterpool)); SVN_ERR_ASSERT(url); for (i = 0; new_desc && (i < new_desc->nelts); i++) { const char *old_defining_abspath; svn_wc_external_item2_t *new_item; const char *target_abspath; svn_boolean_t under_root; new_item = APR_ARRAY_IDX(new_desc, i, svn_wc_external_item2_t *); svn_pool_clear(iterpool); if (ctx->cancel_func) SVN_ERR(ctx->cancel_func(ctx->cancel_baton)); SVN_ERR(svn_dirent_is_under_root(&under_root, &target_abspath, local_abspath, new_item->target_dir, iterpool)); if (! under_root) { return svn_error_createf( SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL, _("Path '%s' is not in the working copy"), svn_dirent_local_style( svn_dirent_join(local_abspath, new_item->target_dir, iterpool), iterpool)); } old_defining_abspath = svn_hash_gets(old_externals, target_abspath); SVN_ERR(wrap_external_error( ctx, target_abspath, handle_external_item_change(ctx, repos_root_url, local_abspath, url, target_abspath, old_defining_abspath, new_item, timestamp_sleep, iterpool), iterpool)); /* And remove already processed items from the to-remove hash */ if (old_defining_abspath) svn_hash_sets(old_externals, target_abspath, NULL); } svn_pool_destroy(iterpool); return SVN_NO_ERROR; }
svn_error_t * svn_client__export_externals(apr_hash_t *externals, const char *from_url, const char *to_abspath, const char *repos_root_url, svn_depth_t requested_depth, const char *native_eol, svn_boolean_t ignore_keywords, svn_client_ctx_t *ctx, apr_pool_t *scratch_pool) { apr_pool_t *iterpool = svn_pool_create(scratch_pool); apr_pool_t *sub_iterpool = svn_pool_create(scratch_pool); apr_hash_index_t *hi; SVN_ERR_ASSERT(svn_dirent_is_absolute(to_abspath)); for (hi = apr_hash_first(scratch_pool, externals); hi; hi = apr_hash_next(hi)) { const char *local_abspath = svn__apr_hash_index_key(hi); const char *desc_text = svn__apr_hash_index_val(hi); const char *local_relpath; const char *dir_url; apr_array_header_t *items; int i; svn_pool_clear(iterpool); SVN_ERR(svn_wc_parse_externals_description3(&items, local_abspath, desc_text, FALSE, iterpool)); if (! items->nelts) continue; local_relpath = svn_dirent_skip_ancestor(to_abspath, local_abspath); dir_url = svn_path_url_add_component2(from_url, local_relpath, scratch_pool); for (i = 0; i < items->nelts; i++) { const char *item_abspath; const char *new_url; svn_boolean_t under_root; svn_wc_external_item2_t *item = APR_ARRAY_IDX(items, i, svn_wc_external_item2_t *); svn_pool_clear(sub_iterpool); SVN_ERR(svn_dirent_is_under_root(&under_root, &item_abspath, local_abspath, item->target_dir, sub_iterpool)); if (! under_root) { return svn_error_createf( SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL, _("Path '%s' is not in the working copy"), svn_dirent_local_style( svn_dirent_join(local_abspath, item->target_dir, sub_iterpool), sub_iterpool)); } SVN_ERR(svn_wc__resolve_relative_external_url(&new_url, item, repos_root_url, dir_url, sub_iterpool, sub_iterpool)); /* The target dir might have multiple components. Guarantee the path leading down to the last component. */ SVN_ERR(svn_io_make_dir_recursively(svn_dirent_dirname(item_abspath, sub_iterpool), sub_iterpool)); SVN_ERR(wrap_external_error( ctx, item_abspath, svn_client_export5(NULL, new_url, item_abspath, &item->peg_revision, &item->revision, TRUE, FALSE, ignore_keywords, svn_depth_infinity, native_eol, ctx, sub_iterpool), sub_iterpool)); } } svn_pool_destroy(sub_iterpool); svn_pool_destroy(iterpool); return SVN_NO_ERROR; }