Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/copy.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/copy.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/copy.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/copy.c Sun Jun 14 20:58:10 2015 @@ -177,12 +177,513 @@ get_copy_pair_ancestors(const apr_array_ return SVN_NO_ERROR; } +/* Quote a string if it would be handled as multiple or different tokens + during externals parsing */ +static const char * +maybe_quote(const char *value, + apr_pool_t *result_pool) +{ + apr_status_t status; + char **argv; + + status = apr_tokenize_to_argv(value, &argv, result_pool); + + if (!status && argv[0] && !argv[1] && strcmp(argv[0], value) == 0) + return apr_pstrdup(result_pool, value); + + { + svn_stringbuf_t *sb = svn_stringbuf_create_empty(result_pool); + const char *c; + + svn_stringbuf_appendbyte(sb, '\"'); + + for (c = value; *c; c++) + { + if (*c == '\\' || *c == '\"' || *c == '\'') + svn_stringbuf_appendbyte(sb, '\\'); + + svn_stringbuf_appendbyte(sb, *c); + } + + svn_stringbuf_appendbyte(sb, '\"'); + +#ifdef SVN_DEBUG + status = apr_tokenize_to_argv(sb->data, &argv, result_pool); + + SVN_ERR_ASSERT_NO_RETURN(!status && argv[0] && !argv[1] + && !strcmp(argv[0], value)); +#endif + + return sb->data; + } +} + +/* In *NEW_EXTERNALS_DESCRIPTION, return a new external description for + * use as a line in an svn:externals property, based on the external item + * ITEM and the additional parser information in INFO. Pin the external + * to EXTERNAL_PEGREV. Use POOL for all allocations. */ +static svn_error_t * +make_external_description(const char **new_external_description, + const char *local_abspath_or_url, + svn_wc_external_item2_t *item, + svn_wc__externals_parser_info_t *info, + svn_opt_revision_t external_pegrev, + apr_pool_t *pool) +{ + const char *rev_str; + const char *peg_rev_str; + + switch (info->format) + { + case svn_wc__external_description_format_1: + if (external_pegrev.kind == svn_opt_revision_unspecified) + { + /* If info->rev_str is NULL, this yields an empty string. */ + rev_str = apr_pstrcat(pool, info->rev_str, " ", SVN_VA_NULL); + } + else if (info->rev_str && item->revision.kind != svn_opt_revision_head) + rev_str = apr_psprintf(pool, "%s ", info->rev_str); + else + { + /* ### can't handle svn_opt_revision_date without info->rev_str */ + SVN_ERR_ASSERT(external_pegrev.kind == svn_opt_revision_number); + rev_str = apr_psprintf(pool, "-r%ld ", + external_pegrev.value.number); + } + + *new_external_description = + apr_psprintf(pool, "%s %s%s\n", maybe_quote(item->target_dir, pool), + rev_str, + maybe_quote(item->url, pool)); + break; + + case svn_wc__external_description_format_2: + if (external_pegrev.kind == svn_opt_revision_unspecified) + { + /* If info->rev_str is NULL, this yields an empty string. */ + rev_str = apr_pstrcat(pool, info->rev_str, " ", SVN_VA_NULL); + } + else if (info->rev_str && item->revision.kind != svn_opt_revision_head) + rev_str = apr_psprintf(pool, "%s ", info->rev_str); + else + rev_str = ""; + + if (external_pegrev.kind == svn_opt_revision_unspecified) + peg_rev_str = info->peg_rev_str ? info->peg_rev_str : ""; + else if (info->peg_rev_str && + item->peg_revision.kind != svn_opt_revision_head) + peg_rev_str = info->peg_rev_str; + else + { + /* ### can't handle svn_opt_revision_date without info->rev_str */ + SVN_ERR_ASSERT(external_pegrev.kind == svn_opt_revision_number); + peg_rev_str = apr_psprintf(pool, "@%ld", + external_pegrev.value.number); + } + + *new_external_description = + apr_psprintf(pool, "%s%s %s\n", rev_str, + maybe_quote(apr_psprintf(pool, "%s%s", item->url, + peg_rev_str), + pool), + maybe_quote(item->target_dir, pool)); + break; + + default: + return svn_error_createf( + SVN_ERR_CLIENT_INVALID_EXTERNALS_DESCRIPTION, NULL, + _("%s property defined at '%s' is using an unsupported " + "syntax"), SVN_PROP_EXTERNALS, + svn_dirent_local_style(local_abspath_or_url, pool)); + } + + return SVN_NO_ERROR; +} + +/* Pin all externals listed in EXTERNALS_PROP_VAL to their + * last-changed revision. Set *PINNED_EXTERNALS to a new property + * value allocated in RESULT_POOL, or to NULL if none of the externals + * in EXTERNALS_PROP_VAL were changed. LOCAL_ABSPATH_OR_URL is the + * path or URL defining the svn:externals property. Use SCRATCH_POOL + * for temporary allocations. + */ +static svn_error_t * +pin_externals_prop(svn_string_t **pinned_externals, + svn_string_t *externals_prop_val, + const apr_hash_t *externals_to_pin, + const char *repos_root_url, + const char *local_abspath_or_url, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) +{ + svn_stringbuf_t *buf; + apr_array_header_t *external_items; + apr_array_header_t *parser_infos; + apr_array_header_t *items_to_pin; + int pinned_items; + int i; + apr_pool_t *iterpool; + + SVN_ERR(svn_wc__parse_externals_description(&external_items, + &parser_infos, + local_abspath_or_url, + externals_prop_val->data, + FALSE /* canonicalize_url */, + scratch_pool)); + + if (externals_to_pin) + { + items_to_pin = svn_hash_gets((apr_hash_t *)externals_to_pin, + local_abspath_or_url); + if (!items_to_pin) + { + /* No pinning at all for this path. */ + *pinned_externals = NULL; + return SVN_NO_ERROR; + } + } + else + items_to_pin = NULL; + + buf = svn_stringbuf_create_empty(scratch_pool); + iterpool = svn_pool_create(scratch_pool); + pinned_items = 0; + for (i = 0; i < external_items->nelts; i++) + { + svn_wc_external_item2_t *item; + svn_wc__externals_parser_info_t *info; + svn_opt_revision_t external_pegrev; + const char *pinned_desc; + + svn_pool_clear(iterpool); + + item = APR_ARRAY_IDX(external_items, i, svn_wc_external_item2_t *); + info = APR_ARRAY_IDX(parser_infos, i, svn_wc__externals_parser_info_t *); + + if (items_to_pin) + { + int j; + svn_wc_external_item2_t *item_to_pin = NULL; + + for (j = 0; j < items_to_pin->nelts; j++) + { + svn_wc_external_item2_t *const current = + APR_ARRAY_IDX(items_to_pin, j, svn_wc_external_item2_t *); + + + if (current + && 0 == strcmp(item->url, current->url) + && 0 == strcmp(item->target_dir, current->target_dir)) + { + item_to_pin = current; + break; + } + } + + /* If this item is not in our list of external items to pin then + * simply keep the external at its original value. */ + if (!item_to_pin) + { + const char *desc; + + external_pegrev.kind = svn_opt_revision_unspecified; + SVN_ERR(make_external_description(&desc, local_abspath_or_url, + item, info, external_pegrev, + iterpool)); + svn_stringbuf_appendcstr(buf, desc); + continue; + } + } + + if (item->peg_revision.kind == svn_opt_revision_date) + { + /* Already pinned ... copy the peg date. */ + external_pegrev.kind = svn_opt_revision_date; + external_pegrev.value.date = item->peg_revision.value.date; + } + else if (item->peg_revision.kind == svn_opt_revision_number) + { + /* Already pinned ... copy the peg revision number. */ + external_pegrev.kind = svn_opt_revision_number; + external_pegrev.value.number = item->peg_revision.value.number; + } + else + { + SVN_ERR_ASSERT( + item->peg_revision.kind == svn_opt_revision_head || + item->peg_revision.kind == svn_opt_revision_unspecified); + + /* We're actually going to change the peg revision. */ + ++pinned_items; + + if (svn_path_is_url(local_abspath_or_url)) + { + const char *resolved_url; + svn_ra_session_t *external_ra_session; + svn_revnum_t latest_revnum; + + SVN_ERR(svn_wc__resolve_relative_external_url( + &resolved_url, item, repos_root_url, + local_abspath_or_url, iterpool, iterpool)); + SVN_ERR(svn_client__open_ra_session_internal(&external_ra_session, + NULL, resolved_url, + NULL, NULL, FALSE, + FALSE, ctx, + iterpool, + iterpool)); + SVN_ERR(svn_ra_get_latest_revnum(external_ra_session, + &latest_revnum, + iterpool)); + + external_pegrev.kind = svn_opt_revision_number; + external_pegrev.value.number = latest_revnum; + } + else + { + const char *external_abspath; + svn_node_kind_t external_kind; + svn_revnum_t external_checked_out_rev; + + external_abspath = svn_dirent_join(local_abspath_or_url, + item->target_dir, + iterpool); + SVN_ERR(svn_wc__read_external_info(&external_kind, NULL, NULL, + NULL, NULL, ctx->wc_ctx, + local_abspath_or_url, + external_abspath, TRUE, + iterpool, + iterpool)); + if (external_kind == svn_node_none) + return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, + NULL, + _("Cannot pin external '%s' defined " + "in %s at '%s' because it is not " + "checked out in the working copy " + "at '%s'"), + item->url, SVN_PROP_EXTERNALS, + svn_dirent_local_style( + local_abspath_or_url, iterpool), + svn_dirent_local_style( + external_abspath, iterpool)); + else if (external_kind == svn_node_dir) + { + svn_boolean_t is_switched; + svn_boolean_t is_modified; + svn_revnum_t min_rev; + svn_revnum_t max_rev; + + /* Perform some sanity checks on the checked-out external. */ + + SVN_ERR(svn_wc__has_switched_subtrees(&is_switched, + ctx->wc_ctx, + external_abspath, NULL, + iterpool)); + if (is_switched) + return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, + NULL, + _("Cannot pin external '%s' defined " + "in %s at '%s' because '%s' has " + "switched subtrees (switches " + "cannot be represented in %s)"), + item->url, SVN_PROP_EXTERNALS, + svn_dirent_local_style( + local_abspath_or_url, iterpool), + svn_dirent_local_style( + external_abspath, iterpool), + SVN_PROP_EXTERNALS); + + SVN_ERR(svn_wc__has_local_mods(&is_modified, ctx->wc_ctx, + external_abspath, TRUE, + ctx->cancel_func, + ctx->cancel_baton, + iterpool)); + if (is_modified) + return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, + NULL, + _("Cannot pin external '%s' defined " + "in %s at '%s' because '%s' has " + "local modifications (local " + "modifications cannot be " + "represented in %s)"), + item->url, SVN_PROP_EXTERNALS, + svn_dirent_local_style( + local_abspath_or_url, iterpool), + svn_dirent_local_style( + external_abspath, iterpool), + SVN_PROP_EXTERNALS); + + SVN_ERR(svn_wc__min_max_revisions(&min_rev, &max_rev, ctx->wc_ctx, + external_abspath, FALSE, + iterpool)); + if (min_rev != max_rev) + return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, + NULL, + _("Cannot pin external '%s' defined " + "in %s at '%s' because '%s' is a " + "mixed-revision working copy " + "(mixed-revisions cannot be " + "represented in %s)"), + item->url, SVN_PROP_EXTERNALS, + svn_dirent_local_style( + local_abspath_or_url, iterpool), + svn_dirent_local_style( + external_abspath, iterpool), + SVN_PROP_EXTERNALS); + external_checked_out_rev = min_rev; + } + else + { + SVN_ERR_ASSERT(external_kind == svn_node_file); + SVN_ERR(svn_wc__node_get_repos_info(&external_checked_out_rev, + NULL, NULL, NULL, + ctx->wc_ctx, external_abspath, + iterpool, iterpool)); + } + + external_pegrev.kind = svn_opt_revision_number; + external_pegrev.value.number = external_checked_out_rev; + } + } + + SVN_ERR_ASSERT(external_pegrev.kind == svn_opt_revision_date || + external_pegrev.kind == svn_opt_revision_number); + + SVN_ERR(make_external_description(&pinned_desc, local_abspath_or_url, + item, info, external_pegrev, iterpool)); + + svn_stringbuf_appendcstr(buf, pinned_desc); + } + svn_pool_destroy(iterpool); + + if (pinned_items > 0) + *pinned_externals = svn_string_create_from_buf(buf, result_pool); + else + *pinned_externals = NULL; + + return SVN_NO_ERROR; +} + +/* Return, in *PINNED_EXTERNALS, a new hash mapping URLs or local abspaths + * to svn:externals property values (as const char *), where some or all + * external references have been pinned. + * If EXTERNALS_TO_PIN is NULL, pin all externals, else pin the externals + * mentioned in EXTERNALS_TO_PIN. + * The pinning operation takes place as part of the copy operation for + * the source/destination pair PAIR. Use RA_SESSION and REPOS_ROOT_URL + * to contact the repository containing the externals definition, if neccesary. + * Use CX to fopen additional RA sessions to external repositories, if + * neccessary. Allocate *NEW_EXTERNALS in RESULT_POOL. + * Use SCRATCH_POOL for temporary allocations. */ +static svn_error_t * +resolve_pinned_externals(apr_hash_t **pinned_externals, + const apr_hash_t *externals_to_pin, + svn_client__copy_pair_t *pair, + svn_ra_session_t *ra_session, + const char *repos_root_url, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) +{ + const char *old_url = NULL; + apr_hash_t *externals_props; + apr_hash_index_t *hi; + apr_pool_t *iterpool; + + *pinned_externals = apr_hash_make(result_pool); + + if (svn_path_is_url(pair->src_abspath_or_url)) + { + SVN_ERR(svn_client__ensure_ra_session_url(&old_url, ra_session, + pair->src_abspath_or_url, + scratch_pool)); + externals_props = apr_hash_make(scratch_pool); + SVN_ERR(svn_client__remote_propget(externals_props, NULL, + SVN_PROP_EXTERNALS, + pair->src_abspath_or_url, "", + svn_node_dir, + pair->src_revnum, + ra_session, + svn_depth_infinity, + scratch_pool, + scratch_pool)); + } + else + { + SVN_ERR(svn_wc__externals_gather_definitions(&externals_props, NULL, + ctx->wc_ctx, + pair->src_abspath_or_url, + svn_depth_infinity, + scratch_pool, scratch_pool)); + + /* ### gather_definitions returns propvals as const char * */ + for (hi = apr_hash_first(scratch_pool, externals_props); + hi; + hi = apr_hash_next(hi)) + { + const char *local_abspath_or_url = apr_hash_this_key(hi); + const char *propval = apr_hash_this_val(hi); + svn_string_t *new_propval = svn_string_create(propval, scratch_pool); + + svn_hash_sets(externals_props, local_abspath_or_url, new_propval); + } + } + + if (apr_hash_count(externals_props) == 0) + { + if (old_url) + SVN_ERR(svn_ra_reparent(ra_session, old_url, scratch_pool)); + return SVN_NO_ERROR; + } + + iterpool = svn_pool_create(scratch_pool); + for (hi = apr_hash_first(scratch_pool, externals_props); + hi; + hi = apr_hash_next(hi)) + { + const char *local_abspath_or_url = apr_hash_this_key(hi); + svn_string_t *externals_propval = apr_hash_this_val(hi); + const char *relpath; + svn_string_t *new_propval; + + svn_pool_clear(iterpool); + + SVN_ERR(pin_externals_prop(&new_propval, externals_propval, + externals_to_pin, + repos_root_url, local_abspath_or_url, ctx, + result_pool, iterpool)); + if (new_propval) + { + if (svn_path_is_url(pair->src_abspath_or_url)) + relpath = svn_uri_skip_ancestor(pair->src_abspath_or_url, + local_abspath_or_url, + result_pool); + else + relpath = svn_dirent_skip_ancestor(pair->src_abspath_or_url, + local_abspath_or_url); + SVN_ERR_ASSERT(relpath); + + svn_hash_sets(*pinned_externals, relpath, new_propval); + } + } + svn_pool_destroy(iterpool); + + if (old_url) + SVN_ERR(svn_ra_reparent(ra_session, old_url, scratch_pool)); + + return SVN_NO_ERROR; +} + + /* The guts of do_wc_to_wc_copies */ static svn_error_t * do_wc_to_wc_copies_with_write_lock(svn_boolean_t *timestamp_sleep, const apr_array_header_t *copy_pairs, const char *dst_parent, + svn_boolean_t metadata_only, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, svn_client_ctx_t *ctx, apr_pool_t *scratch_pool) { @@ -195,22 +696,63 @@ do_wc_to_wc_copies_with_write_lock(svn_b const char *dst_abspath; svn_client__copy_pair_t *pair = APR_ARRAY_IDX(copy_pairs, i, svn_client__copy_pair_t *); + apr_hash_t *pinned_externals = NULL; + svn_pool_clear(iterpool); /* Check for cancellation */ if (ctx->cancel_func) SVN_ERR(ctx->cancel_func(ctx->cancel_baton)); + if (pin_externals) + { + const char *repos_root_url; + + SVN_ERR(svn_wc__node_get_origin(NULL, NULL, NULL, &repos_root_url, + NULL, NULL, NULL, ctx->wc_ctx, + pair->src_abspath_or_url, FALSE, + scratch_pool, iterpool)); + SVN_ERR(resolve_pinned_externals(&pinned_externals, + externals_to_pin, pair, NULL, + repos_root_url, ctx, + iterpool, iterpool)); + } + /* Perform the copy */ dst_abspath = svn_dirent_join(pair->dst_parent_abspath, pair->base_name, iterpool); *timestamp_sleep = TRUE; err = svn_wc_copy3(ctx->wc_ctx, pair->src_abspath_or_url, dst_abspath, - FALSE /* metadata_only */, + metadata_only, ctx->cancel_func, ctx->cancel_baton, ctx->notify_func2, ctx->notify_baton2, iterpool); if (err) break; + + if (pinned_externals) + { + apr_hash_index_t *hi; + + for (hi = apr_hash_first(iterpool, pinned_externals); + hi; + hi = apr_hash_next(hi)) + { + const char *dst_relpath = apr_hash_this_key(hi); + svn_string_t *externals_propval = apr_hash_this_val(hi); + const char *local_abspath; + + local_abspath = svn_dirent_join(pair->dst_abspath_or_url, + dst_relpath, iterpool); + /* ### use a work queue? */ + SVN_ERR(svn_wc_prop_set4(ctx->wc_ctx, local_abspath, + SVN_PROP_EXTERNALS, externals_propval, + svn_depth_empty, TRUE /* skip_checks */, + NULL /* changelist_filter */, + ctx->cancel_func, ctx->cancel_baton, + NULL, NULL, /* no extra notification */ + iterpool)); + } + } } svn_pool_destroy(iterpool); @@ -223,6 +765,9 @@ do_wc_to_wc_copies_with_write_lock(svn_b static svn_error_t * do_wc_to_wc_copies(svn_boolean_t *timestamp_sleep, const apr_array_header_t *copy_pairs, + svn_boolean_t metadata_only, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, svn_client_ctx_t *ctx, apr_pool_t *pool) { @@ -236,7 +781,8 @@ do_wc_to_wc_copies(svn_boolean_t *timest SVN_WC__CALL_WITH_WRITE_LOCK( do_wc_to_wc_copies_with_write_lock(timestamp_sleep, copy_pairs, dst_parent, - ctx, pool), + metadata_only, pin_externals, + externals_to_pin, ctx, pool), ctx->wc_ctx, dst_parent_abspath, FALSE, pool); return SVN_NO_ERROR; @@ -594,6 +1140,8 @@ typedef struct path_driver_info_t svn_boolean_t resurrection; svn_boolean_t dir_add; svn_string_t *mergeinfo; /* the new mergeinfo for the target */ + svn_string_t *externals; /* new externals definitions for the target */ + svn_boolean_t only_pin_externals; } path_driver_info_t; @@ -631,7 +1179,7 @@ path_driver_cb_func(void **dir_baton, with such, the code is just plain wrong. */ SVN_ERR_ASSERT(! svn_path_is_empty(path)); - /* Check to see if we need to add the path as a directory. */ + /* Check to see if we need to add the path as a parent directory. */ if (path_info->dir_add) { return cb_baton->editor->add_directory(path, parent_baton, NULL, @@ -662,7 +1210,7 @@ path_driver_cb_func(void **dir_baton, /* Not a move? This must just be the copy addition. */ else { - do_add = TRUE; + do_add = !path_info->only_pin_externals; } } @@ -702,6 +1250,18 @@ path_driver_cb_func(void **dir_baton, pool)); } } + + if (path_info->externals) + { + if (*dir_baton == NULL) + SVN_ERR(cb_baton->editor->open_directory(path, parent_baton, + SVN_INVALID_REVNUM, + pool, dir_baton)); + + SVN_ERR(cb_baton->editor->change_dir_prop(*dir_baton, SVN_PROP_EXTERNALS, + path_info->externals, pool)); + } + return SVN_NO_ERROR; } @@ -786,6 +1346,79 @@ find_absent_parents2(svn_ra_session_t *r return SVN_NO_ERROR; } +/* Queue property changes for pinning svn:externals properties set on + * descendants of the path corresponding to PARENT_INFO. PINNED_EXTERNALS + * is keyed by the relative path of each descendant which should have some + * or all of its externals pinned, with the corresponding pinned svn:externals + * properties as values. Property changes are queued in a new list of path + * infos *NEW_PATH_INFOS, or in an existing item of the PATH_INFOS list if an + * existing item is found for the descendant. Allocate results in RESULT_POOL. + * Use SCRATCH_POOL for temporary allocations. */ +static svn_error_t * +queue_externals_change_path_infos(apr_array_header_t *new_path_infos, + apr_array_header_t *path_infos, + apr_hash_t *pinned_externals, + path_driver_info_t *parent_info, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) +{ + apr_pool_t *iterpool = svn_pool_create(scratch_pool); + apr_hash_index_t *hi; + + for (hi = apr_hash_first(scratch_pool, pinned_externals); + hi; + hi = apr_hash_next(hi)) + { + const char *dst_relpath = apr_hash_this_key(hi); + svn_string_t *externals_prop = apr_hash_this_val(hi); + const char *src_url; + path_driver_info_t *info; + int i; + + svn_pool_clear(iterpool); + + src_url = svn_path_url_add_component2(parent_info->src_url, + dst_relpath, iterpool); + + /* Try to find a path info the external change can be applied to. */ + info = NULL; + for (i = 0; i < path_infos->nelts; i++) + { + path_driver_info_t *existing_info; + + existing_info = APR_ARRAY_IDX(path_infos, i, path_driver_info_t *); + if (strcmp(src_url, existing_info->src_url) == 0) + { + info = existing_info; + break; + } + } + + if (info == NULL) + { + /* A copied-along child needs its externals pinned. + Create a new path info for this property change. */ + info = apr_pcalloc(result_pool, sizeof(*info)); + info->src_url = svn_path_url_add_component2( + parent_info->src_url, dst_relpath, + result_pool); + info->src_path = NULL; /* Only needed on copied dirs */ + info->dst_path = svn_relpath_join(parent_info->dst_path, + dst_relpath, + result_pool); + info->src_kind = svn_node_dir; + info->only_pin_externals = TRUE; + APR_ARRAY_PUSH(new_path_infos, path_driver_info_t *) = info; + } + + info->externals = externals_prop; + } + + svn_pool_destroy(iterpool); + + return SVN_NO_ERROR; +} + static svn_error_t * repos_to_repos_copy(const apr_array_header_t *copy_pairs, svn_boolean_t make_parents, @@ -794,6 +1427,8 @@ repos_to_repos_copy(const apr_array_head void *commit_baton, svn_client_ctx_t *ctx, svn_boolean_t is_move, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, apr_pool_t *pool) { svn_error_t *err; @@ -809,6 +1444,7 @@ repos_to_repos_copy(const apr_array_head struct path_driver_cb_baton cb_baton; apr_array_header_t *new_dirs = NULL; apr_hash_t *commit_revprops; + apr_array_header_t *pin_externals_only_infos = NULL; int i; svn_client__copy_pair_t *first_pair = APR_ARRAY_IDX(copy_pairs, 0, svn_client__copy_pair_t *); @@ -1006,7 +1642,10 @@ repos_to_repos_copy(const apr_array_head && (relpath != NULL && *relpath != '\0')) { info->resurrection = TRUE; - top_url = svn_uri_dirname(top_url, pool); + top_url = svn_uri_get_longest_ancestor( + top_url, + svn_uri_dirname(pair->dst_abspath_or_url, pool), + pool); SVN_ERR(svn_ra_reparent(ra_session, top_url, pool)); } } @@ -1058,21 +1697,36 @@ repos_to_repos_copy(const apr_array_head SVN_ERR(svn_ra_check_path(ra_session, dst_rel, SVN_INVALID_REVNUM, &dst_kind, pool)); if (dst_kind != svn_node_none) - { - const char *path = svn_uri_skip_ancestor(repos_root, - pair->dst_abspath_or_url, - pool); - return svn_error_createf(SVN_ERR_FS_ALREADY_EXISTS, NULL, - _("Path '/%s' already exists"), path); - } + return svn_error_createf(SVN_ERR_FS_ALREADY_EXISTS, NULL, + _("Path '%s' already exists"), + pair->dst_abspath_or_url); /* More info for our INFO structure. */ - info->src_path = src_rel; + info->src_path = src_rel; /* May be NULL, if outside RA session scope */ info->dst_path = dst_rel; svn_hash_sets(action_hash, info->dst_path, info); if (is_move && (! info->resurrection)) svn_hash_sets(action_hash, info->src_path, info); + + if (pin_externals) + { + apr_hash_t *pinned_externals; + + SVN_ERR(resolve_pinned_externals(&pinned_externals, + externals_to_pin, pair, + ra_session, repos_root, + ctx, pool, pool)); + if (pin_externals_only_infos == NULL) + { + pin_externals_only_infos = + apr_array_make(pool, 0, sizeof(path_driver_info_t *)); + } + SVN_ERR(queue_externals_change_path_infos(pin_externals_only_infos, + path_infos, + pinned_externals, + info, pool, pool)); + } } if (SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx)) @@ -1161,6 +1815,19 @@ repos_to_repos_copy(const apr_array_head APR_ARRAY_PUSH(paths, const char *) = info->src_path; } + /* Add any items which only need their externals pinned. */ + if (pin_externals_only_infos) + { + for (i = 0; i < pin_externals_only_infos->nelts; i++) + { + path_driver_info_t *info; + + info = APR_ARRAY_IDX(pin_externals_only_infos, i, path_driver_info_t *); + APR_ARRAY_PUSH(paths, const char *) = info->dst_path; + svn_hash_sets(action_hash, info->dst_path, info); + } + } + SVN_ERR(svn_client__ensure_revprop_table(&commit_revprops, revprop_table, message, ctx, pool)); @@ -1239,6 +1906,65 @@ check_url_kind(void *baton, return SVN_NO_ERROR; } +/* Queue a property change on a copy of LOCAL_ABSPATH to COMMIT_URL + * in the COMMIT_ITEMS list. + * If the list does not already have a commit item for COMMIT_URL + * add a new commit item for the property change. + * Allocate results in RESULT_POOL. + * Use SCRATCH_POOL for temporary allocations. */ +static svn_error_t * +queue_prop_change_commit_items(const char *local_abspath, + const char *commit_url, + apr_array_header_t *commit_items, + const char *propname, + svn_string_t *propval, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) +{ + svn_client_commit_item3_t *item = NULL; + svn_prop_t *prop; + int i; + + for (i = 0; i < commit_items->nelts; i++) + { + svn_client_commit_item3_t *existing_item; + + existing_item = APR_ARRAY_IDX(commit_items, i, + svn_client_commit_item3_t *); + if (strcmp(existing_item->url, commit_url) == 0) + { + item = existing_item; + break; + } + } + + if (item == NULL) + { + item = svn_client_commit_item3_create(result_pool); + item->path = local_abspath; + item->url = commit_url; + item->kind = svn_node_dir; + item->state_flags = SVN_CLIENT_COMMIT_ITEM_PROP_MODS; + + item->incoming_prop_changes = apr_array_make(result_pool, 1, + sizeof(svn_prop_t *)); + APR_ARRAY_PUSH(commit_items, svn_client_commit_item3_t *) = item; + } + else + item->state_flags |= SVN_CLIENT_COMMIT_ITEM_PROP_MODS; + + if (item->outgoing_prop_changes == NULL) + item->outgoing_prop_changes = apr_array_make(result_pool, 1, + sizeof(svn_prop_t *)); + + prop = apr_palloc(result_pool, sizeof(*prop)); + prop->name = propname; + prop->value = propval; + APR_ARRAY_PUSH(item->outgoing_prop_changes, svn_prop_t *) = prop; + + return SVN_NO_ERROR; +} + /* ### Copy ... * COMMIT_INFO_P is ... * COPY_PAIRS is ... such that each 'src_abspath_or_url' is a local abspath @@ -1252,6 +1978,8 @@ wc_to_repos_copy(const apr_array_header_ const apr_hash_t *revprop_table, svn_commit_callback2_t commit_callback, void *commit_baton, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, svn_client_ctx_t *ctx, apr_pool_t *scratch_pool) { @@ -1448,6 +2176,43 @@ wc_to_repos_copy(const apr_array_header_ APR_ARRAY_PUSH(item->outgoing_prop_changes, svn_prop_t *) = mergeinfo_prop; } + + if (pin_externals) + { + apr_hash_t *pinned_externals; + apr_hash_index_t *hi; + + SVN_ERR(resolve_pinned_externals(&pinned_externals, + externals_to_pin, pair, + ra_session, cukb.repos_root_url, + ctx, scratch_pool, iterpool)); + for (hi = apr_hash_first(scratch_pool, pinned_externals); + hi; + hi = apr_hash_next(hi)) + { + const char *dst_relpath = apr_hash_this_key(hi); + svn_string_t *externals_propval = apr_hash_this_val(hi); + const char *dst_url; + const char *commit_url; + const char *src_abspath; + + if (svn_path_is_url(pair->dst_abspath_or_url)) + dst_url = pair->dst_abspath_or_url; + else + SVN_ERR(svn_wc__node_get_url(&dst_url, ctx->wc_ctx, + pair->dst_abspath_or_url, + scratch_pool, iterpool)); + commit_url = svn_path_url_add_component2(dst_url, dst_relpath, + scratch_pool); + src_abspath = svn_dirent_join(pair->src_abspath_or_url, + dst_relpath, iterpool); + SVN_ERR(queue_prop_change_commit_items(src_abspath, + commit_url, commit_items, + SVN_PROP_EXTERNALS, + externals_propval, + scratch_pool, iterpool)); + } + } } if (SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx)) @@ -1567,6 +2332,8 @@ repos_to_wc_copy_single(svn_boolean_t *t svn_client__copy_pair_t *pair, svn_boolean_t same_repositories, svn_boolean_t ignore_externals, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, svn_ra_session_t *ra_session, svn_client_ctx_t *ctx, apr_pool_t *pool) @@ -1623,6 +2390,14 @@ repos_to_wc_copy_single(svn_boolean_t *t ctx->notify_func2 = notification_adjust_func; ctx->notify_baton2 = &nb; + /* Avoid a chicken-and-egg problem: + * If pinning externals we'll need to adjust externals + * properties before checking out any externals. + * But copy needs to happen before pinning because else there + * are no svn:externals properties to pin. */ + if (pin_externals) + ignore_externals = TRUE; + err = svn_client__checkout_internal(&pair->src_revnum, timestamp_sleep, pair->src_original, tmp_abspath, @@ -1675,6 +2450,61 @@ repos_to_wc_copy_single(svn_boolean_t *t return SVN_NO_ERROR; } + + if (pin_externals) + { + apr_hash_t *pinned_externals; + apr_hash_index_t *hi; + apr_pool_t *iterpool; + const char *repos_root_url; + apr_hash_t *new_externals; + apr_hash_t *new_depths; + + SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root_url, pool)); + SVN_ERR(resolve_pinned_externals(&pinned_externals, + externals_to_pin, pair, + ra_session, repos_root_url, + ctx, pool, pool)); + + iterpool = svn_pool_create(pool); + for (hi = apr_hash_first(pool, pinned_externals); + hi; + hi = apr_hash_next(hi)) + { + const char *dst_relpath = apr_hash_this_key(hi); + svn_string_t *externals_propval = apr_hash_this_val(hi); + const char *local_abspath; + + svn_pool_clear(iterpool); + + local_abspath = svn_dirent_join(pair->dst_abspath_or_url, + dst_relpath, iterpool); + /* ### use a work queue? */ + SVN_ERR(svn_wc_prop_set4(ctx->wc_ctx, local_abspath, + SVN_PROP_EXTERNALS, externals_propval, + svn_depth_empty, TRUE /* skip_checks */, + NULL /* changelist_filter */, + ctx->cancel_func, ctx->cancel_baton, + NULL, NULL, /* no extra notification */ + iterpool)); + } + + /* Now update all externals in the newly created copy. */ + SVN_ERR(svn_wc__externals_gather_definitions(&new_externals, + &new_depths, + ctx->wc_ctx, + dst_abspath, + svn_depth_infinity, + iterpool, iterpool)); + SVN_ERR(svn_client__handle_externals(new_externals, + new_depths, + repos_root_url, dst_abspath, + svn_depth_infinity, + timestamp_sleep, + ra_session, + ctx, iterpool)); + svn_pool_destroy(iterpool); + } } /* end directory case */ else if (pair->src_kind == svn_node_file) @@ -1734,6 +2564,8 @@ repos_to_wc_copy_locked(svn_boolean_t *t const apr_array_header_t *copy_pairs, const char *top_dst_path, svn_boolean_t ignore_externals, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, svn_ra_session_t *ra_session, svn_client_ctx_t *ctx, apr_pool_t *scratch_pool) @@ -1799,6 +2631,7 @@ repos_to_wc_copy_locked(svn_boolean_t *t svn_client__copy_pair_t *), same_repositories, ignore_externals, + pin_externals, externals_to_pin, ra_session, ctx, iterpool)); } svn_pool_destroy(iterpool); @@ -1811,6 +2644,8 @@ repos_to_wc_copy(svn_boolean_t *timestam const apr_array_header_t *copy_pairs, svn_boolean_t make_parents, svn_boolean_t ignore_externals, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, svn_client_ctx_t *ctx, apr_pool_t *pool) { @@ -1919,6 +2754,7 @@ repos_to_wc_copy(svn_boolean_t *timestam SVN_WC__CALL_WITH_WRITE_LOCK( repos_to_wc_copy_locked(timestamp_sleep, copy_pairs, top_dst_path, ignore_externals, + pin_externals, externals_to_pin, ra_session, ctx, pool), ctx->wc_ctx, lock_abspath, FALSE, pool); return SVN_NO_ERROR; @@ -1945,6 +2781,8 @@ try_copy(svn_boolean_t *timestamp_sleep, svn_boolean_t metadata_only, svn_boolean_t make_parents, svn_boolean_t ignore_externals, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, const apr_hash_t *revprop_table, svn_commit_callback2_t commit_callback, void *commit_baton, @@ -2245,30 +3083,35 @@ try_copy(svn_boolean_t *timestamp_sleep, else { /* We ignore these values, so assert the default value */ - SVN_ERR_ASSERT(allow_mixed_revisions && !metadata_only); + SVN_ERR_ASSERT(allow_mixed_revisions); return svn_error_trace(do_wc_to_wc_copies(timestamp_sleep, - copy_pairs, ctx, pool)); + copy_pairs, + metadata_only, + pin_externals, + externals_to_pin, + ctx, pool)); } } else if ((! srcs_are_urls) && (dst_is_url)) { return svn_error_trace( wc_to_repos_copy(copy_pairs, make_parents, revprop_table, - commit_callback, commit_baton, ctx, pool)); + commit_callback, commit_baton, + pin_externals, externals_to_pin, ctx, pool)); } else if ((srcs_are_urls) && (! dst_is_url)) { return svn_error_trace( repos_to_wc_copy(timestamp_sleep, copy_pairs, make_parents, ignore_externals, - ctx, pool)); + pin_externals, externals_to_pin, ctx, pool)); } else { return svn_error_trace( repos_to_repos_copy(copy_pairs, make_parents, revprop_table, commit_callback, commit_baton, ctx, is_move, - pool)); + pin_externals, externals_to_pin, pool)); } } @@ -2276,11 +3119,14 @@ try_copy(svn_boolean_t *timestamp_sleep, /* Public Interfaces */ svn_error_t * -svn_client_copy6(const apr_array_header_t *sources, +svn_client_copy7(const apr_array_header_t *sources, const char *dst_path, svn_boolean_t copy_as_child, svn_boolean_t make_parents, svn_boolean_t ignore_externals, + svn_boolean_t metadata_only, + svn_boolean_t pin_externals, + const apr_hash_t *externals_to_pin, const apr_hash_t *revprop_table, svn_commit_callback2_t commit_callback, void *commit_baton, @@ -2299,9 +3145,11 @@ svn_client_copy6(const apr_array_header_ sources, dst_path, FALSE /* is_move */, TRUE /* allow_mixed_revisions */, - FALSE /* metadata_only */, + metadata_only, make_parents, ignore_externals, + pin_externals, + externals_to_pin, revprop_table, commit_callback, commit_baton, ctx, @@ -2333,9 +3181,11 @@ svn_client_copy6(const apr_array_header_ sources, dst_path, FALSE /* is_move */, TRUE /* allow_mixed_revisions */, - FALSE /* metadata_only */, + metadata_only, make_parents, ignore_externals, + pin_externals, + externals_to_pin, revprop_table, commit_callback, commit_baton, ctx, @@ -2397,6 +3247,8 @@ svn_client_move7(const apr_array_header_ metadata_only, make_parents, FALSE /* ignore_externals */, + FALSE /* pin_externals */, + NULL /* externals_to_pin */, revprop_table, commit_callback, commit_baton, ctx, @@ -2430,6 +3282,8 @@ svn_client_move7(const apr_array_header_ metadata_only, make_parents, FALSE /* ignore_externals */, + FALSE /* pin_externals */, + NULL /* externals_to_pin */, revprop_table, commit_callback, commit_baton, ctx,
Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/deprecated.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/deprecated.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/deprecated.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/deprecated.c Sun Jun 14 20:58:10 2015 @@ -627,6 +627,28 @@ svn_client_commit(svn_client_commit_info /*** From copy.c ***/ svn_error_t * +svn_client_copy6(const apr_array_header_t *sources, + const char *dst_path, + svn_boolean_t copy_as_child, + svn_boolean_t make_parents, + svn_boolean_t ignore_externals, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool) +{ + return svn_error_trace(svn_client_copy7(sources, dst_path, copy_as_child, + make_parents, ignore_externals, + FALSE /* metadata_only */, + FALSE /* pin_externals */, + NULL /* externals_to_pin */, + revprop_table, + commit_callback, commit_baton, + ctx, pool)); +} + +svn_error_t * svn_client_copy5(svn_commit_info_t **commit_info_p, const apr_array_header_t *sources, const char *dst_path, Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/diff.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/diff.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/diff.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/diff.c Sun Jun 14 20:58:10 2015 @@ -2207,7 +2207,7 @@ do_diff(const char **root_relpath, SVN_ERR(svn_dirent_get_absolute(&abspath1, path_or_url1, scratch_pool)); - SVN_ERR(svn_dirent_get_absolute(&abspath2, path_or_url2, + SVN_ERR(svn_dirent_get_absolute(&abspath2, path_or_url2, scratch_pool)); /* ### What about ddi? */ Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/export.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/export.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/export.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/export.c Sun Jun 14 20:58:10 2015 @@ -1508,7 +1508,7 @@ svn_client_export5(svn_revnum_t *result_ eib.ignore_keywords = ignore_keywords; eib.wc_ctx = ctx->wc_ctx; eib.native_eol = native_eol; - eib.notify_func = ctx->notify_func2;; + eib.notify_func = ctx->notify_func2; eib.notify_baton = ctx->notify_baton2; eib.origin_abspath = from_path_or_url; eib.exported = FALSE; Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/externals.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/externals.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/externals.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/externals.c Sun Jun 14 20:58:10 2015 @@ -171,7 +171,7 @@ switch_dir_external(const char *local_ab if (revision->kind == svn_opt_revision_number) external_rev = revision->value.number; - /* + /* * The code below assumes existing versioned paths are *not* part of * the external's defining working copy. * The working copy library does not support registering externals @@ -242,6 +242,20 @@ switch_dir_external(const char *local_ab FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ra_session, ctx, subpool)); + + /* We just decided that this existing directory is an external, + so update the external registry with this information, like + when checking out an external */ + SVN_ERR(svn_wc__external_register(ctx->wc_ctx, + defining_abspath, + local_abspath, svn_node_dir, + repos_root_url, repos_uuid, + svn_uri_skip_ancestor(repos_root_url, + url, pool), + external_peg_rev, + external_rev, + pool)); + svn_pool_destroy(subpool); goto cleanup; } @@ -524,6 +538,8 @@ switch_file_external(const char *local_a record_url, record_peg_revision, record_revision, + ctx->conflict_func2, + ctx->conflict_baton2, ctx->cancel_func, ctx->cancel_baton, ctx->notify_func2, Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/log.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/log.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/log.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/log.c Sun Jun 14 20:58:10 2015 @@ -303,7 +303,7 @@ limit_receiver(void *baton, svn_log_entr The limitations on TARGETS specified by svn_client_log5 are enforced here. So TARGETS can only contain a single WC path or a URL and zero or more - relative paths -- anything else will raise an error. + relative paths -- anything else will raise an error. PEG_REVISION, TARGETS, and CTX are as per svn_client_log5. @@ -642,7 +642,7 @@ run_ra_get_log(apr_array_header_t *revis apr_array_header_t *log_segments, svn_client__pathrev_t *actual_loc, svn_ra_session_t *ra_session, - /* The following are as per svn_client_log5. */ + /* The following are as per svn_client_log5. */ const apr_array_header_t *targets, int limit, svn_boolean_t discover_changed_paths, @@ -761,7 +761,7 @@ run_ra_get_log(apr_array_header_t *revis So to be safe we handle that case. */ if (matching_segment == NULL) continue; - + /* A segment with a NULL path means there is gap in the history. We'll just proceed and let svn_ra_get_log2 fail with a useful error...*/ Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/merge.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/merge.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/merge.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/merge.c Sun Jun 14 20:58:10 2015 @@ -1267,13 +1267,14 @@ record_skip(merge_cmd_baton_t *merge_b, svn_node_kind_t kind, svn_wc_notify_action_t action, svn_wc_notify_state_t state, + struct merge_dir_baton_t *pdb, apr_pool_t *scratch_pool) { if (merge_b->record_only) return SVN_NO_ERROR; /* ### Why? - Legacy compatibility */ - if (merge_b->merge_source.ancestral - || merge_b->reintegrate_merge) + if ((merge_b->merge_source.ancestral || merge_b->reintegrate_merge) + && !(pdb && pdb->shadowed)) { store_path(merge_b->skipped_abspaths, local_abspath); } @@ -1849,9 +1850,14 @@ merge_file_opened(void **new_file_baton, } else if (fb->tree_conflict_local_node_kind != svn_node_file) { + svn_boolean_t added; fb->shadowed = TRUE; - fb->tree_conflict_reason = svn_wc_conflict_reason_obstructed; + SVN_ERR(svn_wc__node_is_added(&added, merge_b->ctx->wc_ctx, + local_abspath, scratch_pool)); + + fb->tree_conflict_reason = added ? svn_wc_conflict_reason_added + : svn_wc_conflict_reason_obstructed; /* ### Similar to directory */ *skip = TRUE; @@ -1952,8 +1958,14 @@ merge_file_opened(void **new_file_baton, && !is_deleted) { /* Set a tree conflict */ + svn_boolean_t added; + fb->shadowed = TRUE; - fb->tree_conflict_reason = svn_wc_conflict_reason_obstructed; + SVN_ERR(svn_wc__node_is_added(&added, merge_b->ctx->wc_ctx, + local_abspath, scratch_pool)); + + fb->tree_conflict_reason = added ? svn_wc_conflict_reason_added + : svn_wc_conflict_reason_obstructed; } } @@ -2009,7 +2021,8 @@ merge_file_changed(const char *relpath, /* We haven't notified for this node yet: report a skip */ SVN_ERR(record_skip(merge_b, local_abspath, svn_node_file, svn_wc_notify_update_shadowed_update, - fb->skip_reason, scratch_pool)); + fb->skip_reason, fb->parent_baton, + scratch_pool)); } return SVN_NO_ERROR; @@ -2179,7 +2192,8 @@ merge_file_added(const char *relpath, /* We haven't notified for this node yet: report a skip */ SVN_ERR(record_skip(merge_b, local_abspath, svn_node_file, svn_wc_notify_update_shadowed_add, - fb->skip_reason, scratch_pool)); + fb->skip_reason, fb->parent_baton, + scratch_pool)); } return SVN_NO_ERROR; @@ -2390,7 +2404,8 @@ merge_file_deleted(const char *relpath, /* We haven't notified for this node yet: report a skip */ SVN_ERR(record_skip(merge_b, local_abspath, svn_node_file, svn_wc_notify_update_shadowed_delete, - fb->skip_reason, scratch_pool)); + fb->skip_reason, fb->parent_baton, + scratch_pool)); } return SVN_NO_ERROR; @@ -2621,9 +2636,14 @@ merge_dir_opened(void **new_dir_baton, } else if (db->tree_conflict_local_node_kind != svn_node_dir) { + svn_boolean_t added; + db->shadowed = TRUE; + SVN_ERR(svn_wc__node_is_added(&added, merge_b->ctx->wc_ctx, + local_abspath, scratch_pool)); - db->tree_conflict_reason = svn_wc_conflict_reason_obstructed; + db->tree_conflict_reason = added ? svn_wc_conflict_reason_added + : svn_wc_conflict_reason_obstructed; /* ### To avoid breaking tests */ *skip = TRUE; @@ -2766,8 +2786,20 @@ merge_dir_opened(void **new_dir_baton, && !is_deleted) { /* Set a tree conflict */ + svn_boolean_t added; db->shadowed = TRUE; - db->tree_conflict_reason = svn_wc_conflict_reason_obstructed; + + SVN_ERR(svn_wc__node_is_added(&added, merge_b->ctx->wc_ctx, + local_abspath, scratch_pool)); + + db->tree_conflict_reason = added ? svn_wc_conflict_reason_added + : svn_wc_conflict_reason_obstructed; + + if ((merge_b->merge_source.ancestral || merge_b->reintegrate_merge) + && !(pdb && pdb->shadowed)) + { + store_path(merge_b->skipped_abspaths, local_abspath); + } } } @@ -2895,7 +2927,8 @@ merge_dir_changed(const char *relpath, /* We haven't notified for this node yet: report a skip */ SVN_ERR(record_skip(merge_b, local_abspath, svn_node_dir, svn_wc_notify_update_shadowed_update, - db->skip_reason, scratch_pool)); + db->skip_reason, db->parent_baton, + scratch_pool)); } return SVN_NO_ERROR; @@ -2980,7 +3013,8 @@ merge_dir_added(const char *relpath, /* We haven't notified for this node yet: report a skip */ SVN_ERR(record_skip(merge_b, local_abspath, svn_node_dir, svn_wc_notify_update_shadowed_add, - db->skip_reason, scratch_pool)); + db->skip_reason, db->parent_baton, + scratch_pool)); } return SVN_NO_ERROR; @@ -3147,7 +3181,8 @@ merge_dir_deleted(const char *relpath, /* We haven't notified for this node yet: report a skip */ SVN_ERR(record_skip(merge_b, local_abspath, svn_node_dir, svn_wc_notify_update_shadowed_delete, - db->skip_reason, scratch_pool)); + db->skip_reason, db->parent_baton, + scratch_pool)); } return SVN_NO_ERROR; @@ -3329,13 +3364,14 @@ merge_node_absent(const char *relpath, apr_pool_t *scratch_pool) { merge_cmd_baton_t *merge_b = processor->baton; + struct merge_dir_baton_t *db = dir_baton; const char *local_abspath = svn_dirent_join(merge_b->target->abspath, relpath, scratch_pool); SVN_ERR(record_skip(merge_b, local_abspath, svn_node_unknown, svn_wc_notify_skip, svn_wc_notify_state_missing, - scratch_pool)); + db, scratch_pool)); return SVN_NO_ERROR; } @@ -6109,8 +6145,9 @@ insert_parent_and_sibs_of_sw_absent_del_ } /*(parent == NULL) */ /* Add all of PARENT's non-missing children that are not already present.*/ - SVN_ERR(svn_wc__node_get_children(&children, ctx->wc_ctx, - parent_abspath, FALSE, pool, pool)); + SVN_ERR(svn_wc__node_get_children_of_working_node(&children, ctx->wc_ctx, + parent_abspath, + pool, pool)); iterpool = svn_pool_create(pool); for (i = 0; i < children->nelts; i++) { @@ -6592,7 +6629,7 @@ get_mergeinfo_paths(apr_array_header_t * SVN_ERR(svn_wc__node_get_children_of_working_node( &immediate_children, ctx->wc_ctx, - target->abspath, FALSE, scratch_pool, scratch_pool)); + target->abspath, scratch_pool, scratch_pool)); for (j = 0; j < immediate_children->nelts; j++) { @@ -6676,9 +6713,10 @@ get_mergeinfo_paths(apr_array_header_t * const apr_array_header_t *children; int j; - SVN_ERR(svn_wc__node_get_children(&children, + SVN_ERR(svn_wc__node_get_children_of_working_node( + &children, ctx->wc_ctx, - child->abspath, FALSE, + child->abspath, iterpool, iterpool)); for (j = 0; j < children->nelts; j++) { @@ -10247,7 +10285,7 @@ ensure_wc_is_suitable_merge_target(const svn_boolean_t is_modified; SVN_ERR(svn_wc__has_local_mods(&is_modified, ctx->wc_ctx, - target_abspath, + target_abspath, TRUE, ctx->cancel_func, ctx->cancel_baton, scratch_pool)); Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/patch.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/patch.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/patch.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/patch.c Sun Jun 14 20:58:10 2015 @@ -326,7 +326,8 @@ obtain_eol_and_keywords_for_file(apr_has const char *rev_str; const char *author; const char *url; - const char *root_url; + const char *repos_root_url; + const char *repos_relpath; SVN_ERR(svn_wc__node_get_changed_info(&changed_rev, &changed_date, @@ -335,15 +336,17 @@ obtain_eol_and_keywords_for_file(apr_has scratch_pool, scratch_pool)); rev_str = apr_psprintf(scratch_pool, "%ld", changed_rev); - SVN_ERR(svn_wc__node_get_url(&url, wc_ctx, - local_abspath, - scratch_pool, scratch_pool)); - SVN_ERR(svn_wc__node_get_repos_info(NULL, NULL, &root_url, NULL, + SVN_ERR(svn_wc__node_get_repos_info(NULL, &repos_relpath, &repos_root_url, + NULL, wc_ctx, local_abspath, scratch_pool, scratch_pool)); + url = svn_path_url_add_component2(repos_root_url, repos_relpath, + scratch_pool); + SVN_ERR(svn_subst_build_keywords3(keywords, keywords_val->data, - rev_str, url, root_url, changed_date, + rev_str, url, repos_root_url, + changed_date, author, result_pool)); } @@ -908,18 +911,18 @@ write_symlink(void *baton, const char *b { const char *target_abspath = baton; const char *new_name; - const char *link = apr_pstrndup(scratch_pool, buf, len); + const char *sym_link = apr_pstrndup(scratch_pool, buf, len); - if (strncmp(link, "link ", 5) != 0) + if (strncmp(sym_link, "link ", 5) != 0) return svn_error_create(SVN_ERR_IO_WRITE_ERROR, NULL, _("Invalid link representation")); - link += 5; /* Skip "link " */ + sym_link += 5; /* Skip "link " */ /* We assume the entire symlink is written at once, as the patch format is line based */ - SVN_ERR(svn_io_create_unique_link(&new_name, target_abspath, link, + SVN_ERR(svn_io_create_unique_link(&new_name, target_abspath, sym_link, ".tmp", scratch_pool)); SVN_ERR(svn_io_file_rename(new_name, target_abspath, scratch_pool)); @@ -1592,7 +1595,7 @@ static svn_error_t * get_hunk_info(hunk_info_t **hi, patch_target_t *target, target_content_t *content, svn_diff_hunk_t *hunk, svn_linenum_t fuzz, - apr_int64_t previous_offset, + svn_linenum_t previous_offset, svn_boolean_t ignore_whitespace, svn_boolean_t is_prop_hunk, svn_cancel_func_t cancel_func, void *cancel_baton, @@ -1795,7 +1798,7 @@ get_hunk_info(hunk_info_t **hi, patch_ta && (!matched_line || (matched_line > original_start && (matched_line - original_start - > original_start - search_start)))) + > original_start - search_start)))) { svn_linenum_t search_start2 = 1; @@ -2272,7 +2275,7 @@ apply_one_patch(patch_target_t **patch_t int i; static const svn_linenum_t MAX_FUZZ = 2; apr_hash_index_t *hash_index; - apr_int64_t previous_offset = 0; + svn_linenum_t previous_offset = 0; SVN_ERR(init_patch_target(&target, patch, abs_wc_path, wc_ctx, strip_count, remove_tempfiles, result_pool, scratch_pool)); Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/prop_commands.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/prop_commands.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/prop_commands.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/prop_commands.c Sun Jun 14 20:58:10 2015 @@ -527,40 +527,18 @@ svn_client_revprop_set2(const char *prop return SVN_NO_ERROR; } -/* Helper for the remote case of svn_client_propget. - * - * If PROPS is not null, then get the value of property PROPNAME in - * REVNUM, using RA_SESSION. Store the value ('svn_string_t *') in - * PROPS, under the path key "TARGET_PREFIX/TARGET_RELATIVE" - * ('const char *'). - * - * If INHERITED_PROPS is not null, then set *INHERITED_PROPS to a - * depth-first ordered array of svn_prop_inherited_item_t * structures - * representing the PROPNAME properties inherited by the target. If - * INHERITABLE_PROPS in not null and no inheritable properties are found, - * then set *INHERITED_PROPS to an empty array. - * - * Recurse according to DEPTH, similarly to svn_client_propget3(). - * - * KIND is the kind of the node at "TARGET_PREFIX/TARGET_RELATIVE". - * Yes, caller passes this; it makes the recursion more efficient :-). - * - * Allocate PROPS and *INHERITED_PROPS in RESULT_POOL, but do all temporary - * work in SCRATCH_POOL. The two pools can be the same; recursive - * calls may use a different SCRATCH_POOL, however. - */ -static svn_error_t * -remote_propget(apr_hash_t *props, - apr_array_header_t **inherited_props, - const char *propname, - const char *target_prefix, - const char *target_relative, - svn_node_kind_t kind, - svn_revnum_t revnum, - svn_ra_session_t *ra_session, - svn_depth_t depth, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool) +svn_error_t * +svn_client__remote_propget(apr_hash_t *props, + apr_array_header_t **inherited_props, + const char *propname, + const char *target_prefix, + const char *target_relative, + svn_node_kind_t kind, + svn_revnum_t revnum, + svn_ra_session_t *ra_session, + svn_depth_t depth, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) { apr_hash_t *dirents; apr_hash_t *prop_hash = NULL; @@ -672,15 +650,15 @@ remote_propget(apr_hash_t *props, new_target_relative = svn_relpath_join(target_relative, this_name, iterpool); - SVN_ERR(remote_propget(props, NULL, - propname, - target_prefix, - new_target_relative, - this_ent->kind, - revnum, - ra_session, - depth_below_here, - result_pool, iterpool)); + SVN_ERR(svn_client__remote_propget(props, NULL, + propname, + target_prefix, + new_target_relative, + this_ent->kind, + revnum, + ra_session, + depth_below_here, + result_pool, iterpool)); } svn_pool_destroy(iterpool); @@ -970,7 +948,8 @@ svn_client_propget5(apr_hash_t **props, if (!local_explicit_props) *props = apr_hash_make(result_pool); - SVN_ERR(remote_propget(!local_explicit_props ? *props : NULL, + SVN_ERR(svn_client__remote_propget( + !local_explicit_props ? *props : NULL, !local_iprops ? inherited_props : NULL, propname, loc->url, "", kind, loc->rev, ra_session, Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/ra.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/ra.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/ra.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/ra.c Sun Jun 14 20:58:10 2015 @@ -706,7 +706,7 @@ repos_locations(const char **start_url, || (SVN_IS_VALID_REVNUM(end_revnum) && (end_revnum > youngest_rev))) return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL, _("No such revision %ld"), - (start_revnum > youngest_rev) + (start_revnum > youngest_rev) ? start_revnum : end_revnum); if (start_url) Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/resolved.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/resolved.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/resolved.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/resolved.c Sun Jun 14 20:58:10 2015 @@ -144,3 +144,34 @@ svn_client_resolve(const char *path, return svn_error_trace(err); } + + +/*** Dealing with conflicts. ***/ + +const char * +svn_client_conflict_get_local_abspath( + const svn_wc_conflict_description2_t *conflict) +{ + return conflict->local_abspath; +} + +svn_wc_operation_t +svn_client_conflict_get_operation( + const svn_wc_conflict_description2_t *conflict) +{ + return conflict->operation; +} + +svn_wc_conflict_action_t +svn_client_conflict_get_incoming_change( + const svn_wc_conflict_description2_t *conflict) +{ + return conflict->action; +} + +svn_wc_conflict_reason_t +svn_client_conflict_get_local_change( + const svn_wc_conflict_description2_t *conflict) +{ + return conflict->reason; +} Modified: subversion/branches/fsx-1.10/subversion/libsvn_client/update.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_client/update.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_client/update.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_client/update.c Sun Jun 14 20:58:10 2015 @@ -198,7 +198,7 @@ record_conflict(svn_wc_conflict_result_t is not null. Use RA_SESSION_P to run the update if it is not NULL. If it is then - open a new ra session and place it in RA_SESSION_P. This allows + open a new ra session and place it in RA_SESSION_P. This allows repeated calls to update_internal to reuse the same session. */ static svn_error_t * Modified: subversion/branches/fsx-1.10/subversion/libsvn_delta/compat.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_delta/compat.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/libsvn_delta/compat.c (original) +++ subversion/branches/fsx-1.10/subversion/libsvn_delta/compat.c Sun Jun 14 20:58:10 2015 @@ -816,8 +816,9 @@ static svn_error_t * open_delta_target(svn_stream_t **stream, void *baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - const char **delta_target = baton; - return svn_stream_open_unique(stream, delta_target, NULL, + struct change_node *change = baton; + return svn_stream_open_unique(stream, &change->contents_abspath, + NULL, svn_io_file_del_on_pool_cleanup, result_pool, scratch_pool); } @@ -850,8 +851,7 @@ ev2_apply_textdelta(void *file_baton, FALSE, handler_pool); change->contents_changed = TRUE; - target = svn_stream_lazyopen_create(open_delta_target, - &change->contents_abspath, + target = svn_stream_lazyopen_create(open_delta_target, change, FALSE, fb->eb->edit_pool); svn_txdelta_apply(hb->source, target, @@ -1223,15 +1223,23 @@ alter_file_cb(void *baton, apr_pool_t *scratch_pool) { struct editor_baton *eb = baton; - const char *tmp_filename; svn_stream_t *tmp_stream; - svn_checksum_t *md5_checksum; struct change_node *change = insert_change(relpath, eb->changes); + /* Note: this node may already have information in CHANGE as a result + of an earlier copy/move operation. */ + /* ### should we verify the kind is truly a file? */ + change->kind = svn_node_file; + change->changing = revision; + if (props != NULL) + change->props = svn_prop_hash_dup(props, eb->edit_pool); if (contents) { + const char *tmp_filename; + svn_checksum_t *md5_checksum; + /* We may need to re-checksum these contents */ if (checksum && checksum->kind == svn_checksum_md5) md5_checksum = (svn_checksum_t *)checksum; @@ -1246,17 +1254,7 @@ alter_file_cb(void *baton, eb->edit_pool, scratch_pool)); SVN_ERR(svn_stream_copy3(contents, tmp_stream, NULL, NULL, scratch_pool)); - } - /* Note: this node may already have information in CHANGE as a result - of an earlier copy/move operation. */ - - change->kind = svn_node_file; - change->changing = revision; - if (props != NULL) - change->props = svn_prop_hash_dup(props, eb->edit_pool); - if (contents != NULL) - { change->contents_changed = TRUE; change->contents_abspath = tmp_filename; change->checksum = svn_checksum_dup(md5_checksum, eb->edit_pool);
