svn_error_t * svn_cl__changelist_paths(apr_array_header_t **paths, const apr_array_header_t *changelists, const apr_array_header_t *targets, svn_depth_t depth, svn_client_ctx_t *ctx, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { apr_array_header_t *found; apr_hash_t *paths_hash; apr_pool_t *iterpool; int i; if (! (changelists && changelists->nelts)) { *paths = (apr_array_header_t *)targets; return SVN_NO_ERROR; } found = apr_array_make(scratch_pool, 8, sizeof(const char *)); iterpool = svn_pool_create(scratch_pool); for (i = 0; i < targets->nelts; i++) { const char *target = APR_ARRAY_IDX(targets, i, const char *); svn_pool_clear(iterpool); SVN_ERR(svn_client_get_changelists(target, changelists, depth, changelist_receiver, found, ctx, iterpool)); } svn_pool_destroy(iterpool); SVN_ERR(svn_hash_from_cstring_keys(&paths_hash, found, result_pool)); return svn_error_trace(svn_hash_keys(paths, paths_hash, result_pool)); }
/* Public Interface */ svn_error_t * svn_wc_diff6(svn_wc_context_t *wc_ctx, const char *local_abspath, const svn_wc_diff_callbacks4_t *callbacks, void *callback_baton, svn_depth_t depth, svn_boolean_t ignore_ancestry, svn_boolean_t show_copies_as_adds, svn_boolean_t use_git_diff_format, const apr_array_header_t *changelist_filter, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool) { struct diff_baton eb = { 0 }; svn_kind_t kind; svn_boolean_t get_all; SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath, FALSE, scratch_pool)); if (kind == svn_kind_dir) eb.anchor_abspath = local_abspath; else eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool); eb.db = wc_ctx->db; eb.callbacks = callbacks; eb.callback_baton = callback_baton; eb.ignore_ancestry = ignore_ancestry; eb.show_copies_as_adds = show_copies_as_adds; eb.use_git_diff_format = use_git_diff_format; eb.empty_file = NULL; eb.pool = scratch_pool; if (changelist_filter && changelist_filter->nelts) SVN_ERR(svn_hash_from_cstring_keys(&eb.changelist_hash, changelist_filter, scratch_pool)); if (show_copies_as_adds || use_git_diff_format) get_all = TRUE; /* We need unmodified descendants of copies */ else get_all = FALSE; /* Walk status handles files and directories */ SVN_ERR(svn_wc__internal_walk_status(wc_ctx->db, local_abspath, depth, get_all, TRUE /* no_ignore */, FALSE /* ignore_text_mods */, NULL /* ignore_patterns */, diff_status_callback, &eb, cancel_func, cancel_baton, scratch_pool)); return SVN_NO_ERROR; }
static svn_error_t * mkdir_urls(const apr_array_header_t *urls, svn_boolean_t make_parents, const apr_hash_t *revprop_table, svn_commit_callback2_t commit_callback, void *commit_baton, svn_client_ctx_t *ctx, apr_pool_t *pool) { svn_ra_session_t *ra_session = NULL; const svn_delta_editor_t *editor; void *edit_baton; const char *log_msg; apr_array_header_t *targets; apr_hash_t *targets_hash; apr_hash_t *commit_revprops; svn_error_t *err; const char *common; int i; /* Find any non-existent parent directories */ if (make_parents) { apr_array_header_t *all_urls = apr_array_make(pool, urls->nelts, sizeof(const char *)); const char *first_url = APR_ARRAY_IDX(urls, 0, const char *); apr_pool_t *iterpool = svn_pool_create(pool); SVN_ERR(svn_client__open_ra_session_internal(&ra_session, NULL, first_url, NULL, NULL, FALSE, TRUE, ctx, pool)); for (i = 0; i < urls->nelts; i++) { const char *url = APR_ARRAY_IDX(urls, i, const char *); svn_pool_clear(iterpool); SVN_ERR(add_url_parents(ra_session, url, all_urls, iterpool, pool)); } svn_pool_destroy(iterpool); urls = all_urls; } /* Condense our list of mkdir targets. */ SVN_ERR(svn_uri_condense_targets(&common, &targets, urls, FALSE, pool, pool)); /*Remove duplicate targets introduced by make_parents with more targets. */ SVN_ERR(svn_hash_from_cstring_keys(&targets_hash, targets, pool)); SVN_ERR(svn_hash_keys(&targets, targets_hash, pool)); if (! targets->nelts) { const char *bname; svn_uri_split(&common, &bname, common, pool); APR_ARRAY_PUSH(targets, const char *) = bname; if (*bname == '\0') return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL, _("There is no valid uri above '%s'"), common); } else { svn_boolean_t resplit = FALSE; /* We can't "mkdir" the root of an editor drive, so if one of our targets is the empty string, we need to back everything up by a path component. */ for (i = 0; i < targets->nelts; i++) { const char *path = APR_ARRAY_IDX(targets, i, const char *); if (! *path) { resplit = TRUE; break; } } if (resplit) { const char *bname; svn_uri_split(&common, &bname, common, pool); if (*bname == '\0') return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL, _("There is no valid uri above '%s'"), common); for (i = 0; i < targets->nelts; i++) { const char *path = APR_ARRAY_IDX(targets, i, const char *); path = svn_relpath_join(bname, path, pool); APR_ARRAY_IDX(targets, i, const char *) = path; } } } qsort(targets->elts, targets->nelts, targets->elt_size, svn_sort_compare_paths); /* ### This reparent may be problematic in limited-authz-to-common-parent ### scenarios (compare issue #3242). See also issue #3649. */ if (ra_session) SVN_ERR(svn_ra_reparent(ra_session, common, pool)); /* Create new commit items and add them to the array. */ if (SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx)) { svn_client_commit_item3_t *item; const char *tmp_file; apr_array_header_t *commit_items = apr_array_make(pool, targets->nelts, sizeof(item)); for (i = 0; i < targets->nelts; i++) { const char *path = APR_ARRAY_IDX(targets, i, const char *); item = svn_client_commit_item3_create(pool); item->url = svn_path_url_add_component2(common, path, pool); item->state_flags = SVN_CLIENT_COMMIT_ITEM_ADD; APR_ARRAY_PUSH(commit_items, svn_client_commit_item3_t *) = item; } SVN_ERR(svn_client__get_log_msg(&log_msg, &tmp_file, commit_items, ctx, pool)); if (! log_msg) return SVN_NO_ERROR; } else
/* Public Interface */ svn_error_t * svn_wc_diff6(svn_wc_context_t *wc_ctx, const char *local_abspath, const svn_wc_diff_callbacks4_t *callbacks, void *callback_baton, svn_depth_t depth, svn_boolean_t ignore_ancestry, svn_boolean_t show_copies_as_adds, svn_boolean_t use_git_diff_format, const apr_array_header_t *changelist_filter, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *scratch_pool) { struct diff_baton eb = { 0 }; svn_node_kind_t kind; svn_boolean_t get_all; const svn_diff_tree_processor_t *processor; SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath, FALSE /* allow_missing */, TRUE /* show_deleted */, FALSE /* show_hidden */, scratch_pool)); if (kind == svn_node_dir) eb.anchor_abspath = local_abspath; else eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool); SVN_ERR(svn_wc__wrap_diff_callbacks(&processor, callbacks, callback_baton, TRUE, scratch_pool, scratch_pool)); if (use_git_diff_format) show_copies_as_adds = TRUE; if (show_copies_as_adds) ignore_ancestry = FALSE; /* if (reverse_order) processor = svn_diff__tree_processor_reverse_create(processor, NULL, pool); */ if (! show_copies_as_adds && !use_git_diff_format) processor = svn_diff__tree_processor_copy_as_changed_create(processor, scratch_pool); eb.db = wc_ctx->db; eb.processor = processor; eb.ignore_ancestry = ignore_ancestry; eb.show_copies_as_adds = show_copies_as_adds; eb.pool = scratch_pool; if (changelist_filter && changelist_filter->nelts) SVN_ERR(svn_hash_from_cstring_keys(&eb.changelist_hash, changelist_filter, scratch_pool)); if (show_copies_as_adds || use_git_diff_format || !ignore_ancestry) get_all = TRUE; /* We need unmodified descendants of copies */ else get_all = FALSE; /* Walk status handles files and directories */ SVN_ERR(svn_wc__internal_walk_status(wc_ctx->db, local_abspath, depth, get_all, TRUE /* no_ignore */, FALSE /* ignore_text_mods */, NULL /* ignore_patterns */, diff_status_callback, &eb, cancel_func, cancel_baton, scratch_pool)); /* Close the remaining open directories */ while (eb.cur) { struct node_state_t *ns = eb.cur; if (!ns->skip) { if (ns->propchanges) SVN_ERR(processor->dir_changed(ns->relpath, ns->left_src, ns->right_src, ns->left_props, ns->right_props, ns->propchanges, ns->baton, processor, ns->pool)); else SVN_ERR(processor->dir_closed(ns->relpath, ns->left_src, ns->right_src, ns->baton, processor, ns->pool)); } eb.cur = ns->parent; svn_pool_clear(ns->pool); } return SVN_NO_ERROR; }
svn_error_t * svn_client_proplist3(const char *path_or_url, const svn_opt_revision_t *peg_revision, const svn_opt_revision_t *revision, svn_depth_t depth, const apr_array_header_t *changelists, svn_proplist_receiver_t receiver, void *receiver_baton, svn_client_ctx_t *ctx, apr_pool_t *pool) { const char *url; peg_revision = svn_cl__rev_default_to_head_or_working(peg_revision, path_or_url); revision = svn_cl__rev_default_to_peg(revision, peg_revision); if (depth == svn_depth_unknown) depth = svn_depth_empty; if (! svn_path_is_url(path_or_url) && SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(peg_revision->kind) && SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(revision->kind)) { svn_boolean_t pristine; svn_node_kind_t kind; apr_hash_t *changelist_hash = NULL; const char *local_abspath; SVN_ERR(svn_dirent_get_absolute(&local_abspath, path_or_url, pool)); pristine = ((revision->kind == svn_opt_revision_committed) || (revision->kind == svn_opt_revision_base)); SVN_ERR(svn_wc_read_kind(&kind, ctx->wc_ctx, local_abspath, FALSE, pool)); if (kind == svn_node_unknown || kind == svn_node_none) { /* svn uses SVN_ERR_UNVERSIONED_RESOURCE as warning only for this function. */ return svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL, _("'%s' is not under version control"), svn_dirent_local_style(local_abspath, pool)); } if (changelists && changelists->nelts) SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelists, pool)); /* Fetch, recursively or not. */ if (kind == svn_node_dir) { struct recursive_proplist_receiver_baton rb; rb.wc_ctx = ctx->wc_ctx; rb.wrapped_receiver = receiver; rb.wrapped_receiver_baton = receiver_baton; if (strcmp(path_or_url, local_abspath) != 0) { rb.anchor = path_or_url; rb.anchor_abspath = local_abspath; } else { rb.anchor = NULL; rb.anchor_abspath = NULL; } SVN_ERR(svn_wc__prop_list_recursive(ctx->wc_ctx, local_abspath, NULL, depth, FALSE, pristine, changelists, recursive_proplist_receiver, &rb, ctx->cancel_func, ctx->cancel_baton, pool)); } else if (svn_wc__changelist_match(ctx->wc_ctx, local_abspath, changelist_hash, pool)) { apr_hash_t *hash; SVN_ERR(pristine_or_working_props(&hash, ctx->wc_ctx, local_abspath, pristine, pool, pool)); SVN_ERR(call_receiver(path_or_url, hash, receiver, receiver_baton, pool)); } } else /* remote target */ { svn_ra_session_t *ra_session; svn_node_kind_t kind; apr_pool_t *subpool = svn_pool_create(pool); svn_revnum_t revnum; /* Get an RA session for this URL. */ SVN_ERR(svn_client__ra_session_from_path(&ra_session, &revnum, &url, path_or_url, NULL, peg_revision, revision, ctx, pool)); SVN_ERR(svn_ra_check_path(ra_session, "", revnum, &kind, pool)); SVN_ERR(remote_proplist(url, "", kind, revnum, ra_session, depth, receiver, receiver_baton, pool, subpool)); svn_pool_destroy(subpool); } return SVN_NO_ERROR; }
svn_error_t * svn_client_status6(svn_revnum_t *result_rev, svn_client_ctx_t *ctx, const char *path, const svn_opt_revision_t *revision, svn_depth_t depth, svn_boolean_t get_all, svn_boolean_t check_out_of_date, svn_boolean_t check_working_copy, svn_boolean_t no_ignore, svn_boolean_t ignore_externals, svn_boolean_t depth_as_sticky, const apr_array_header_t *changelists, svn_client_status_func_t status_func, void *status_baton, apr_pool_t *pool) /* ### aka scratch_pool */ { struct status_baton sb; const char *dir, *dir_abspath; const char *target_abspath; const char *target_basename; apr_array_header_t *ignores; svn_error_t *err; apr_hash_t *changelist_hash = NULL; /* Override invalid combinations of the check_out_of_date and check_working_copy flags. */ if (!check_out_of_date) check_working_copy = TRUE; if (svn_path_is_url(path)) return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL, _("'%s' is not a local path"), path); if (changelists && changelists->nelts) SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelists, pool)); if (result_rev) *result_rev = SVN_INVALID_REVNUM; sb.real_status_func = status_func; sb.real_status_baton = status_baton; sb.deleted_in_repos = FALSE; sb.changelist_hash = changelist_hash; sb.wc_ctx = ctx->wc_ctx; SVN_ERR(svn_dirent_get_absolute(&target_abspath, path, pool)); if (check_out_of_date) { /* The status editor only works on directories, so get the ancestor if necessary */ svn_node_kind_t kind; SVN_ERR(svn_wc_read_kind2(&kind, ctx->wc_ctx, target_abspath, TRUE, FALSE, pool)); /* Dir must be a working copy directory or the status editor fails */ if (kind == svn_node_dir) { dir_abspath = target_abspath; target_basename = ""; dir = path; } else { dir_abspath = svn_dirent_dirname(target_abspath, pool); target_basename = svn_dirent_basename(target_abspath, NULL); dir = svn_dirent_dirname(path, pool); if (kind == svn_node_file) { if (depth == svn_depth_empty) depth = svn_depth_files; } else { err = svn_wc_read_kind2(&kind, ctx->wc_ctx, dir_abspath, FALSE, FALSE, pool); svn_error_clear(err); if (err || kind != svn_node_dir) { return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL, _("'%s' is not a working copy"), svn_dirent_local_style(path, pool)); } } } } else { dir = path; dir_abspath = target_abspath; } if (svn_dirent_is_absolute(dir)) { sb.anchor_abspath = NULL; sb.anchor_relpath = NULL; } else { sb.anchor_abspath = dir_abspath; sb.anchor_relpath = dir; } /* Get the status edit, and use our wrapping status function/baton as the callback pair. */ SVN_ERR(svn_wc_get_default_ignores(&ignores, ctx->config, pool)); /* If we want to know about out-of-dateness, we crawl the working copy and let the RA layer drive the editor for real. Otherwise, we just close the edit. :-) */ if (check_out_of_date) { svn_ra_session_t *ra_session; const char *URL; svn_node_kind_t kind; svn_boolean_t server_supports_depth; const svn_delta_editor_t *editor; void *edit_baton, *set_locks_baton; svn_revnum_t edit_revision = SVN_INVALID_REVNUM; /* Get full URL from the ANCHOR. */ SVN_ERR(svn_client_url_from_path2(&URL, dir_abspath, ctx, pool, pool)); if (!URL) return svn_error_createf (SVN_ERR_ENTRY_MISSING_URL, NULL, _("Entry '%s' has no URL"), svn_dirent_local_style(dir, pool)); /* Open a repository session to the URL. */ SVN_ERR(svn_client__open_ra_session_internal(&ra_session, NULL, URL, dir_abspath, NULL, FALSE, TRUE, ctx, pool, pool)); SVN_ERR(svn_ra_has_capability(ra_session, &server_supports_depth, SVN_RA_CAPABILITY_DEPTH, pool)); SVN_ERR(svn_wc__get_status_editor(&editor, &edit_baton, &set_locks_baton, &edit_revision, ctx->wc_ctx, dir_abspath, target_basename, depth, get_all, check_working_copy, no_ignore, depth_as_sticky, server_supports_depth, ignores, tweak_status, &sb, ctx->cancel_func, ctx->cancel_baton, pool, pool)); /* Verify that URL exists in HEAD. If it doesn't, this can save us a whole lot of hassle; if it does, the cost of this request should be minimal compared to the size of getting back the average amount of "out-of-date" information. */ SVN_ERR(svn_ra_check_path(ra_session, "", SVN_INVALID_REVNUM, &kind, pool)); if (kind == svn_node_none) { svn_boolean_t added; /* Our status target does not exist in HEAD. If we've got it locally added, that's okay. But if it was previously versioned, then it must have since been deleted from the repository. (Note that "locally replaced" doesn't count as "added" in this case.) */ SVN_ERR(svn_wc__node_is_added(&added, ctx->wc_ctx, dir_abspath, pool)); if (! added) sb.deleted_in_repos = TRUE; /* And now close the edit. */ SVN_ERR(editor->close_edit(edit_baton, pool)); } else { svn_revnum_t revnum; report_baton_t rb; svn_depth_t status_depth; if (revision->kind == svn_opt_revision_head) { /* Cause the revision number to be omitted from the request, which implies HEAD. */ revnum = SVN_INVALID_REVNUM; } else { /* Get a revision number for our status operation. */ SVN_ERR(svn_client__get_revision_number(&revnum, NULL, ctx->wc_ctx, target_abspath, ra_session, revision, pool)); } if (depth_as_sticky || !server_supports_depth) status_depth = depth; else status_depth = svn_depth_unknown; /* Use depth from WC */ /* Do the deed. Let the RA layer drive the status editor. */ SVN_ERR(svn_ra_do_status2(ra_session, &rb.wrapped_reporter, &rb.wrapped_report_baton, target_basename, revnum, status_depth, editor, edit_baton, pool)); /* Init the report baton. */ rb.ancestor = apr_pstrdup(pool, URL); /* Edited later */ rb.set_locks_baton = set_locks_baton; rb.ctx = ctx; rb.pool = pool; if (depth == svn_depth_unknown) rb.depth = svn_depth_infinity; else rb.depth = depth; /* Drive the reporter structure, describing the revisions within PATH. When we call reporter->finish_report, EDITOR will be driven to describe differences between our working copy and HEAD. */ SVN_ERR(svn_wc_crawl_revisions5(ctx->wc_ctx, target_abspath, &lock_fetch_reporter, &rb, FALSE /* restore_files */, depth, (! depth_as_sticky), (! server_supports_depth), FALSE /* use_commit_times */, ctx->cancel_func, ctx->cancel_baton, NULL, NULL, pool)); } if (ctx->notify_func2) { svn_wc_notify_t *notify = svn_wc_create_notify(target_abspath, svn_wc_notify_status_completed, pool); notify->revision = edit_revision; ctx->notify_func2(ctx->notify_baton2, notify, pool); } /* If the caller wants the result revision, give it to them. */ if (result_rev) *result_rev = edit_revision; } else { err = svn_wc_walk_status(ctx->wc_ctx, target_abspath, depth, get_all, no_ignore, FALSE, ignores, tweak_status, &sb, ctx->cancel_func, ctx->cancel_baton, pool); if (err && err->apr_err == SVN_ERR_WC_MISSING) { /* This error code is checked for in svn to continue after this error */ svn_error_clear(err); return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL, _("'%s' is not a working copy"), svn_dirent_local_style(path, pool)); } SVN_ERR(err); } /* We only descend into an external if depth is svn_depth_infinity or svn_depth_unknown. However, there are conceivable behaviors that would involve descending under other circumstances; thus, we pass depth anyway, so the code will DTRT if we change the conditional in the future. */ if (SVN_DEPTH_IS_RECURSIVE(depth) && (! ignore_externals)) { apr_hash_t *external_map; SVN_ERR(svn_wc__externals_defined_below(&external_map, ctx->wc_ctx, target_abspath, pool, pool)); SVN_ERR(do_external_status(ctx, external_map, depth, get_all, check_out_of_date, check_working_copy, no_ignore, changelists, sb.anchor_abspath, sb.anchor_relpath, status_func, status_baton, pool)); } return SVN_NO_ERROR; }
svn_error_t * svn_client_info2(const char *path_or_url, const svn_opt_revision_t *peg_revision, const svn_opt_revision_t *revision, svn_info_receiver_t receiver, void *receiver_baton, svn_depth_t depth, const apr_array_header_t *changelists, svn_client_ctx_t *ctx, apr_pool_t *pool) { svn_ra_session_t *ra_session, *parent_ra_session; svn_revnum_t rev; const char *url; svn_node_kind_t url_kind; const char *repos_root_URL, *repos_UUID; svn_lock_t *lock; svn_boolean_t related; apr_hash_t *parent_ents; const char *parent_url, *base_name; svn_dirent_t *the_ent; svn_info_t *info; svn_error_t *err; if ((revision == NULL || revision->kind == svn_opt_revision_unspecified) && (peg_revision == NULL || peg_revision->kind == svn_opt_revision_unspecified)) { /* Do all digging in the working copy. */ apr_hash_t *changelist_hash = NULL; if (changelists && changelists->nelts) SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelists, pool)); return crawl_entries(path_or_url, receiver, receiver_baton, depth, changelist_hash, ctx, pool); } /* Go repository digging instead. */ /* Trace rename history (starting at path_or_url@peg_revision) and return RA session to the possibly-renamed URL as it exists in REVISION. The ra_session returned will be anchored on this "final" URL. */ SVN_ERR(svn_client__ra_session_from_path(&ra_session, &rev, &url, path_or_url, NULL, peg_revision, revision, ctx, pool)); SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root_URL, pool)); SVN_ERR(svn_ra_get_uuid2(ra_session, &repos_UUID, pool)); svn_path_split(url, &parent_url, &base_name, pool); base_name = svn_path_uri_decode(base_name, pool); /* Get the dirent for the URL itself. */ err = svn_ra_stat(ra_session, "", rev, &the_ent, pool); /* svn_ra_stat() will work against old versions of mod_dav_svn, but not old versions of svnserve. In the case of a pre-1.2 svnserve, catch the specific error it throws:*/ if (err && err->apr_err == SVN_ERR_RA_NOT_IMPLEMENTED) { /* Fall back to pre-1.2 strategy for fetching dirent's URL. */ svn_error_clear(err); if (strcmp(url, repos_root_URL) == 0) { /* In this universe, there's simply no way to fetch information about the repository's root directory! If we're recursing, degrade gracefully: rather than throw an error, return no information about the repos root. */ if (depth > svn_depth_empty) goto pre_1_2_recurse; /* Otherwise, we really are stuck. Better tell the user what's going on. */ return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL, _("Server does not support retrieving " "information about the repository root")); } SVN_ERR(svn_ra_check_path(ra_session, "", rev, &url_kind, pool)); if (url_kind == svn_node_none) return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL, _("URL '%s' non-existent in revision %ld"), url, rev); /* Open a new RA session to the item's parent. */ SVN_ERR(svn_client__open_ra_session_internal(&parent_ra_session, parent_url, NULL, NULL, NULL, FALSE, TRUE, ctx, pool)); /* Get all parent's entries, and find the item's dirent in the hash. */ SVN_ERR(svn_ra_get_dir2(parent_ra_session, &parent_ents, NULL, NULL, "", rev, DIRENT_FIELDS, pool)); the_ent = apr_hash_get(parent_ents, base_name, APR_HASH_KEY_STRING); if (the_ent == NULL) return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL, _("URL '%s' non-existent in revision %ld"), url, rev); } else if (err) { return err; } if (! the_ent) return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL, _("URL '%s' non-existent in revision %ld"), url, rev); /* Check if the URL exists in HEAD and refers to the same resource. In this case, we check the repository for a lock on this URL. ### There is a possible race here, since HEAD might have changed since ### we checked it. A solution to this problem could be to do the below ### check in a loop which only terminates if the HEAD revision is the same ### before and after this check. That could, however, lead to a ### starvation situation instead. */ SVN_ERR(same_resource_in_head(&related, url, rev, ra_session, ctx, pool)); if (related) { err = svn_ra_get_lock(ra_session, &lock, "", pool); /* An old mod_dav_svn will always work; there's nothing wrong with doing a PROPFIND for a property named "DAV:supportedlock". But an old svnserve will error. */ if (err && err->apr_err == SVN_ERR_RA_NOT_IMPLEMENTED) { svn_error_clear(err); lock = NULL; } else if (err) return err; } else lock = NULL; /* Push the URL's dirent (and lock) at the callback.*/ SVN_ERR(build_info_from_dirent(&info, the_ent, lock, url, rev, repos_UUID, repos_root_URL, pool)); SVN_ERR(receiver(receiver_baton, base_name, info, pool)); /* Possibly recurse, using the original RA session. */ if (depth > svn_depth_empty && (the_ent->kind == svn_node_dir)) { apr_hash_t *locks; pre_1_2_recurse: if (peg_revision->kind == svn_opt_revision_head) { err = svn_ra_get_locks(ra_session, &locks, "", pool); /* Catch specific errors thrown by old mod_dav_svn or svnserve. */ if (err && (err->apr_err == SVN_ERR_RA_NOT_IMPLEMENTED || err->apr_err == SVN_ERR_UNSUPPORTED_FEATURE)) { svn_error_clear(err); locks = apr_hash_make(pool); /* use an empty hash */ } else if (err) return err; } else locks = apr_hash_make(pool); /* use an empty hash */ SVN_ERR(push_dir_info(ra_session, url, "", rev, repos_UUID, repos_root_URL, receiver, receiver_baton, depth, ctx, locks, pool)); } return SVN_NO_ERROR; }
static svn_error_t * mkdir_urls(svn_commit_info_t **commit_info_p, const apr_array_header_t *urls, svn_boolean_t make_parents, const apr_hash_t *revprop_table, svn_client_ctx_t *ctx, apr_pool_t *pool) { svn_ra_session_t *ra_session = NULL; const svn_delta_editor_t *editor; void *edit_baton; void *commit_baton; const char *log_msg; apr_array_header_t *targets; apr_hash_t *targets_hash; apr_hash_t *commit_revprops; svn_error_t *err; const char *common; int i; /* Find any non-existent parent directories */ if (make_parents) { apr_array_header_t *all_urls = apr_array_make(pool, urls->nelts, sizeof(const char *)); const char *first_url = APR_ARRAY_IDX(urls, 0, const char *); apr_pool_t *iterpool = svn_pool_create(pool); SVN_ERR(svn_client__open_ra_session_internal(&ra_session, first_url, NULL, NULL, NULL, FALSE, TRUE, ctx, pool)); for (i = 0; i < urls->nelts; i++) { const char *url = APR_ARRAY_IDX(urls, i, const char *); svn_pool_clear(iterpool); SVN_ERR(add_url_parents(ra_session, url, all_urls, iterpool, pool)); } svn_pool_destroy(iterpool); urls = all_urls; } /* Condense our list of mkdir targets. */ SVN_ERR(svn_path_condense_targets(&common, &targets, urls, FALSE, pool)); SVN_ERR(svn_hash_from_cstring_keys(&targets_hash, targets, pool)); SVN_ERR(svn_hash_keys(&targets, targets_hash, pool)); if (! targets->nelts) { const char *bname; svn_path_split(common, &common, &bname, pool); APR_ARRAY_PUSH(targets, const char *) = bname; } else { svn_boolean_t resplit = FALSE; /* We can't "mkdir" the root of an editor drive, so if one of our targets is the empty string, we need to back everything up by a path component. */ for (i = 0; i < targets->nelts; i++) { const char *path = APR_ARRAY_IDX(targets, i, const char *); if (! *path) { resplit = TRUE; break; } } if (resplit) { const char *bname; svn_path_split(common, &common, &bname, pool); for (i = 0; i < targets->nelts; i++) { const char *path = APR_ARRAY_IDX(targets, i, const char *); path = svn_path_join(bname, path, pool); APR_ARRAY_IDX(targets, i, const char *) = path; } } } qsort(targets->elts, targets->nelts, targets->elt_size, svn_sort_compare_paths); /* Create new commit items and add them to the array. */ if (SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx)) { svn_client_commit_item3_t *item; const char *tmp_file; apr_array_header_t *commit_items = apr_array_make(pool, targets->nelts, sizeof(item)); for (i = 0; i < targets->nelts; i++) { const char *path = APR_ARRAY_IDX(targets, i, const char *); SVN_ERR(svn_client_commit_item_create ((const svn_client_commit_item3_t **) &item, pool)); item->url = svn_path_join(common, path, pool); item->state_flags = SVN_CLIENT_COMMIT_ITEM_ADD; APR_ARRAY_PUSH(commit_items, svn_client_commit_item3_t *) = item; } SVN_ERR(svn_client__get_log_msg(&log_msg, &tmp_file, commit_items, ctx, pool)); if (! log_msg) return SVN_NO_ERROR; } else
svn_error_t * svn_client_status4(svn_revnum_t *result_rev, const char *path, const svn_opt_revision_t *revision, svn_wc_status_func3_t status_func, void *status_baton, svn_depth_t depth, svn_boolean_t get_all, svn_boolean_t update, svn_boolean_t no_ignore, svn_boolean_t ignore_externals, const apr_array_header_t *changelists, svn_client_ctx_t *ctx, apr_pool_t *pool) { svn_wc_adm_access_t *anchor_access, *target_access; svn_wc_traversal_info_t *traversal_info = svn_wc_init_traversal_info(pool); const char *anchor, *target; const svn_delta_editor_t *editor; void *edit_baton, *set_locks_baton; const svn_wc_entry_t *entry = NULL; struct status_baton sb; apr_array_header_t *ignores; svn_error_t *err; apr_hash_t *changelist_hash = NULL; svn_revnum_t edit_revision = SVN_INVALID_REVNUM; if (changelists && changelists->nelts) SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelists, pool)); sb.real_status_func = status_func; sb.real_status_baton = status_baton; sb.deleted_in_repos = FALSE; sb.changelist_hash = changelist_hash; /* Try to open the target directory. If the target is a file or an unversioned directory, open the parent directory instead */ err = svn_wc_adm_open3(&anchor_access, NULL, path, FALSE, SVN_DEPTH_IS_RECURSIVE(depth) ? -1 : 1, ctx->cancel_func, ctx->cancel_baton, pool); if (err && err->apr_err == SVN_ERR_WC_NOT_DIRECTORY) { svn_error_clear(err); SVN_ERR(svn_wc_adm_open_anchor(&anchor_access, &target_access, &target, path, FALSE, SVN_DEPTH_IS_RECURSIVE(depth) ? -1 : 1, ctx->cancel_func, ctx->cancel_baton, pool)); } else if (!err) { target = ""; target_access = anchor_access; } else return err; anchor = svn_wc_adm_access_path(anchor_access); /* Get the status edit, and use our wrapping status function/baton as the callback pair. */ SVN_ERR(svn_wc_get_default_ignores(&ignores, ctx->config, pool)); SVN_ERR(svn_wc_get_status_editor4(&editor, &edit_baton, &set_locks_baton, &edit_revision, anchor_access, target, depth, get_all, no_ignore, ignores, tweak_status, &sb, ctx->cancel_func, ctx->cancel_baton, traversal_info, pool)); /* If we want to know about out-of-dateness, we crawl the working copy and let the RA layer drive the editor for real. Otherwise, we just close the edit. :-) */ if (update) { svn_ra_session_t *ra_session; const char *URL; svn_node_kind_t kind; svn_boolean_t server_supports_depth; /* Get full URL from the ANCHOR. */ if (! entry) SVN_ERR(svn_wc__entry_versioned(&entry, anchor, anchor_access, FALSE, pool)); if (! entry->url) return svn_error_createf (SVN_ERR_ENTRY_MISSING_URL, NULL, _("Entry '%s' has no URL"), svn_path_local_style(anchor, pool)); URL = apr_pstrdup(pool, entry->url); /* Open a repository session to the URL. */ SVN_ERR(svn_client__open_ra_session_internal(&ra_session, URL, anchor, anchor_access, NULL, FALSE, TRUE, ctx, pool)); /* Verify that URL exists in HEAD. If it doesn't, this can save us a whole lot of hassle; if it does, the cost of this request should be minimal compared to the size of getting back the average amount of "out-of-date" information. */ SVN_ERR(svn_ra_check_path(ra_session, "", SVN_INVALID_REVNUM, &kind, pool)); if (kind == svn_node_none) { /* Our status target does not exist in HEAD of the repository. If we're just adding this thing, that's fine. But if it was previously versioned, then it must have been deleted from the repository. */ if (entry->schedule != svn_wc_schedule_add) sb.deleted_in_repos = TRUE; /* And now close the edit. */ SVN_ERR(editor->close_edit(edit_baton, pool)); } else { svn_revnum_t revnum; report_baton_t rb; if (revision->kind == svn_opt_revision_head) { /* Cause the revision number to be omitted from the request, which implies HEAD. */ revnum = SVN_INVALID_REVNUM; } else { /* Get a revision number for our status operation. */ SVN_ERR(svn_client__get_revision_number (&revnum, NULL, ra_session, revision, target, pool)); } /* Do the deed. Let the RA layer drive the status editor. */ SVN_ERR(svn_ra_do_status2(ra_session, &rb.wrapped_reporter, &rb.wrapped_report_baton, target, revnum, depth, editor, edit_baton, pool)); /* Init the report baton. */ rb.ancestor = apr_pstrdup(pool, URL); rb.set_locks_baton = set_locks_baton; rb.ctx = ctx; rb.pool = pool; SVN_ERR(svn_ra_has_capability(ra_session, &server_supports_depth, SVN_RA_CAPABILITY_DEPTH, pool)); /* Drive the reporter structure, describing the revisions within PATH. When we call reporter->finish_report, EDITOR will be driven to describe differences between our working copy and HEAD. */ SVN_ERR(svn_wc_crawl_revisions4(path, target_access, &lock_fetch_reporter, &rb, FALSE, depth, TRUE, (! server_supports_depth), FALSE, NULL, NULL, NULL, pool)); } } else { SVN_ERR(editor->close_edit(edit_baton, pool)); } if (ctx->notify_func2 && update) { svn_wc_notify_t *notify = svn_wc_create_notify(path, svn_wc_notify_status_completed, pool); notify->revision = edit_revision; (ctx->notify_func2)(ctx->notify_baton2, notify, pool); } /* If the caller wants the result revision, give it to them. */ if (result_rev) *result_rev = edit_revision; /* Close the access baton here, as svn_client__do_external_status() calls back into this function and thus will be re-opening the working copy. */ SVN_ERR(svn_wc_adm_close2(anchor_access, pool)); /* If there are svn:externals set, we don't want those to show up as unversioned or unrecognized, so patch up the hash. If caller wants all the statuses, we will change unversioned status items that are interesting to an svn:externals property to svn_wc_status_unversioned, otherwise we'll just remove the status item altogether. We only descend into an external if depth is svn_depth_infinity or svn_depth_unknown. However, there are conceivable behaviors that would involve descending under other circumstances; thus, we pass depth anyway, so the code will DTRT if we change the conditional in the future. */ if (SVN_DEPTH_IS_RECURSIVE(depth) && (! ignore_externals)) SVN_ERR(svn_client__do_external_status(traversal_info, status_func, status_baton, depth, get_all, update, no_ignore, ctx, pool)); return SVN_NO_ERROR; }