static svn_error_t * remove_external(svn_boolean_t *removed, svn_wc_context_t *wc_ctx, const char *wri_abspath, const char *local_abspath, svn_node_kind_t external_kind, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool) { *removed = FALSE; switch (external_kind) { case svn_node_dir: SVN_WC__CALL_WITH_WRITE_LOCK( remove_external2(removed, wc_ctx, wri_abspath, local_abspath, external_kind, cancel_func, cancel_baton, scratch_pool), wc_ctx, local_abspath, FALSE, scratch_pool); break; case svn_node_file: default: SVN_ERR(remove_external2(removed, wc_ctx, wri_abspath, local_abspath, external_kind, cancel_func, cancel_baton, scratch_pool)); break; } return SVN_NO_ERROR; }
svn_error_t * svn_client_add4(const char *path, svn_depth_t depth, svn_boolean_t force, svn_boolean_t no_ignore, svn_boolean_t add_parents, svn_client_ctx_t *ctx, apr_pool_t *pool) { const char *parent_abspath; const char *local_abspath; const char *existing_parent_abspath; if (svn_path_is_url(path)) return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL, _("'%s' is not a local path"), path); SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool)); /* ### this is a hack. ### before we switched to absolute paths, if a user tried to do ### 'svn add .', PATH would be "" and PARENT_PATH would also be "", ### thus emulating the behavior below. Now that we are using ### absolute paths, svn_dirent_dirname() doesn't behave the same way ### w.r.t. '.', so we need to include the following hack. This ### behavior is tested in schedule_tests-11. */ if (path[0] == 0) parent_abspath = local_abspath; else parent_abspath = svn_dirent_dirname(local_abspath, pool); existing_parent_abspath = NULL; if (add_parents) { apr_pool_t *subpool; const char *existing_parent_abspath2; subpool = svn_pool_create(pool); SVN_ERR(find_existing_parent(&existing_parent_abspath2, ctx, parent_abspath, pool, subpool)); if (strcmp(existing_parent_abspath2, parent_abspath) != 0) existing_parent_abspath = existing_parent_abspath2; svn_pool_destroy(subpool); } SVN_WC__CALL_WITH_WRITE_LOCK( add(local_abspath, depth, force, no_ignore, existing_parent_abspath, ctx, pool), ctx->wc_ctx, existing_parent_abspath ? existing_parent_abspath : parent_abspath, FALSE /* lock_anchor */, pool); return SVN_NO_ERROR; }
svn_error_t * svn_client__wc_copy_mods(const char *src_wc_abspath, const char *dst_wc_abspath, svn_client_ctx_t *ctx, apr_pool_t *scratch_pool) { svn_client__pathrev_t *base; const char *dst_wc_url; svn_ra_session_t *ra_session; const svn_delta_editor_t *editor; void *edit_baton; apr_array_header_t *src_targets = apr_array_make(scratch_pool, 1, sizeof(char *)); /* We'll need an RA session to obtain the base of any copies */ SVN_ERR(svn_client__wc_node_get_base(&base, src_wc_abspath, ctx->wc_ctx, scratch_pool, scratch_pool)); dst_wc_url = base->url; SVN_ERR(svn_client_open_ra_session2(&ra_session, dst_wc_url, dst_wc_abspath, ctx, scratch_pool, scratch_pool)); SVN_ERR(svn_client__wc_editor(&editor, &edit_baton, dst_wc_abspath, NULL, NULL, ra_session, ctx, scratch_pool)); APR_ARRAY_PUSH(src_targets, const char *) = src_wc_abspath; SVN_WC__CALL_WITH_WRITE_LOCK( svn_client__wc_replay(src_wc_abspath, src_targets, svn_depth_infinity, NULL, editor, edit_baton, ctx, scratch_pool), ctx->wc_ctx, dst_wc_abspath, FALSE, scratch_pool); return SVN_NO_ERROR; }
svn_error_t * svn_client__copy_foreign(const char *url, const char *dst_abspath, svn_opt_revision_t *peg_revision, svn_opt_revision_t *revision, svn_depth_t depth, svn_boolean_t make_parents, svn_boolean_t already_locked, svn_client_ctx_t *ctx, apr_pool_t *scratch_pool) { svn_ra_session_t *ra_session; svn_client__pathrev_t *loc; svn_node_kind_t kind; svn_node_kind_t wc_kind; const char *dir_abspath; SVN_ERR_ASSERT(svn_path_is_url(url)); SVN_ERR_ASSERT(svn_dirent_is_absolute(dst_abspath)); /* Do we need to validate/update revisions? */ SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &loc, url, NULL, peg_revision, revision, ctx, scratch_pool)); SVN_ERR(svn_ra_check_path(ra_session, "", loc->rev, &kind, scratch_pool)); if (kind != svn_node_file && kind != svn_node_dir) return svn_error_createf( SVN_ERR_ILLEGAL_TARGET, NULL, _("'%s' is not a valid location inside a repository"), url); SVN_ERR(svn_wc_read_kind2(&wc_kind, ctx->wc_ctx, dst_abspath, FALSE, TRUE, scratch_pool)); if (wc_kind != svn_node_none) { return svn_error_createf( SVN_ERR_ENTRY_EXISTS, NULL, _("'%s' is already under version control"), svn_dirent_local_style(dst_abspath, scratch_pool)); } dir_abspath = svn_dirent_dirname(dst_abspath, scratch_pool); SVN_ERR(svn_wc_read_kind2(&wc_kind, ctx->wc_ctx, dir_abspath, FALSE, FALSE, scratch_pool)); if (wc_kind == svn_node_none) { if (make_parents) SVN_ERR(svn_client__make_local_parents(dir_abspath, make_parents, ctx, scratch_pool)); SVN_ERR(svn_wc_read_kind2(&wc_kind, ctx->wc_ctx, dir_abspath, FALSE, FALSE, scratch_pool)); } if (wc_kind != svn_node_dir) return svn_error_createf( SVN_ERR_ENTRY_NOT_FOUND, NULL, _("Can't add '%s', because no parent directory is found"), svn_dirent_local_style(dst_abspath, scratch_pool)); if (kind == svn_node_file) { svn_stream_t *target; apr_hash_t *props; apr_hash_index_t *hi; SVN_ERR(svn_stream_open_writable(&target, dst_abspath, scratch_pool, scratch_pool)); SVN_ERR(svn_ra_get_file(ra_session, "", loc->rev, target, NULL, &props, scratch_pool)); if (props != NULL) for (hi = apr_hash_first(scratch_pool, props); hi; hi = apr_hash_next(hi)) { const char *name = apr_hash_this_key(hi); if (svn_property_kind2(name) != svn_prop_regular_kind || ! strcmp(name, SVN_PROP_MERGEINFO)) { /* We can't handle DAV, ENTRY and merge specific props here */ svn_hash_sets(props, name, NULL); } } if (!already_locked) SVN_WC__CALL_WITH_WRITE_LOCK( svn_wc_add_from_disk3(ctx->wc_ctx, dst_abspath, props, TRUE /* skip checks */, ctx->notify_func2, ctx->notify_baton2, scratch_pool), ctx->wc_ctx, dir_abspath, FALSE, scratch_pool); else SVN_ERR(svn_wc_add_from_disk3(ctx->wc_ctx, dst_abspath, props, TRUE /* skip checks */, ctx->notify_func2, ctx->notify_baton2, scratch_pool)); } else { if (!already_locked) SVN_WC__CALL_WITH_WRITE_LOCK( copy_foreign_dir(ra_session, loc, ctx->wc_ctx, dst_abspath, depth, ctx->notify_func2, ctx->notify_baton2, ctx->cancel_func, ctx->cancel_baton, scratch_pool), ctx->wc_ctx, dir_abspath, FALSE, scratch_pool); else SVN_ERR(copy_foreign_dir(ra_session, loc, ctx->wc_ctx, dst_abspath, depth, ctx->notify_func2, ctx->notify_baton2, ctx->cancel_func, ctx->cancel_baton, scratch_pool)); } return SVN_NO_ERROR; }