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)); }
svn_error_t * svn_cl__conflict_stats_get_paths(apr_array_header_t **conflicted_paths, svn_cl__conflict_stats_t *conflict_stats, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { int n_text = apr_hash_count(conflict_stats->text_conflicts); int n_prop = apr_hash_count(conflict_stats->prop_conflicts); int n_tree = apr_hash_count(conflict_stats->tree_conflicts); apr_hash_t *all_conflicts; *conflicted_paths = NULL; if (n_text == 0 && n_prop == 0 && n_tree == 0) return SVN_NO_ERROR; /* Use a hash table to ensure paths with multiple conflicts are * returned just once. */ all_conflicts = apr_hash_make(result_pool); if (n_text > 0) { apr_array_header_t *k_text; int i; SVN_ERR(svn_hash_keys(&k_text, conflict_stats->text_conflicts, scratch_pool)); for (i = 0; i < k_text->nelts; i++) { const char *path = APR_ARRAY_IDX(k_text, i, const char *); svn_hash_sets(all_conflicts, path, ""); } }
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
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