Author: stsp Date: Sun Oct 16 17:51:29 2016 New Revision: 1765177 URL: http://svn.apache.org/viewvc?rev=1765177&view=rev Log: Add another conflict resolver test (XFAIL).
* subversion/tests/libsvn_client/conflicts-test.c (propval_different): New global constant. (create_wc_with_file_add_vs_file_add_update_conflict): New helper function. (test_update_incoming_added_file_text_merge, test_funcs): New test (XFAIL). Modified: subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c Modified: subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c?rev=1765177&r1=1765176&r2=1765177&view=diff ============================================================================== --- subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c (original) +++ subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c Sun Oct 16 17:51:29 2016 @@ -171,6 +171,7 @@ static const char *new_dir_name = "newdi /* File property content. */ static const char *propval_trunk = "This is a property on the trunk."; static const char *propval_branch = "This is a property on the branch."; +static const char *propval_different = "This is a different property value."; /* File content. */ static const char *modified_file_on_branch_content = @@ -3233,6 +3234,183 @@ test_update_incoming_dir_move_with_neste return SVN_NO_ERROR; } +/* A helper function which prepares a working copy for the tests below. */ +static svn_error_t * +create_wc_with_file_add_vs_file_add_update_conflict(svn_test__sandbox_t *b) +{ + static const char *new_file_path; + svn_client_ctx_t *ctx; + static const char *trunk_url; + svn_opt_revision_t opt_rev; + svn_client_status_t *status; + struct status_baton sb; + svn_client_conflict_t *conflict; + svn_boolean_t tree_conflicted; + + SVN_ERR(sbox_add_and_commit_greek_tree(b)); + + /* Add a new file and commit. */ + new_file_path = svn_relpath_join(trunk_path, new_file_name, b->pool); + SVN_ERR(sbox_file_write(b, new_file_path, + "This is a new file on the trunk\n")); + SVN_ERR(sbox_wc_add(b, new_file_path)); + SVN_ERR(sbox_wc_propset(b, "prop", "propval", new_file_path)); + SVN_ERR(sbox_wc_commit(b, "")); + + /* Update into the past. */ + SVN_ERR(sbox_wc_update(b, "", 1)); + + /* Add a differnt file and commit. */ + new_file_path = svn_relpath_join(trunk_path, new_file_name, b->pool); + SVN_ERR(sbox_file_write(b, new_file_path, + "This is a different new file on the trunk\n")); + SVN_ERR(sbox_wc_add(b, new_file_path)); + SVN_ERR(sbox_wc_propset(b, "prop", propval_different, new_file_path)); + + /* Update to HEAD. + * This should raise an "incoming add vs local add" tree conflict. */ + SVN_ERR(sbox_wc_update(b, "", SVN_INVALID_REVNUM)); + + SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool)); + + opt_rev.kind = svn_opt_revision_head; + opt_rev.value.number = SVN_INVALID_REVNUM; + trunk_url = apr_pstrcat(b->pool, b->repos_url, "/", trunk_path, SVN_VA_NULL); + + /* Ensure that the file has the expected status. */ + sb.result_pool = b->pool; + SVN_ERR(svn_client_status6(NULL, ctx, sbox_wc_path(b, new_file_path), + &opt_rev, svn_depth_unknown, TRUE, TRUE, + TRUE, TRUE, FALSE, TRUE, NULL, + status_func, &sb, b->pool)); + status = sb.status; + SVN_TEST_ASSERT(status->kind == svn_node_file); + SVN_TEST_ASSERT(status->versioned); + SVN_TEST_ASSERT(status->conflicted); + SVN_TEST_ASSERT(status->node_status == svn_wc_status_replaced); + SVN_TEST_ASSERT(status->text_status == svn_wc_status_modified); + SVN_TEST_ASSERT(status->prop_status == svn_wc_status_modified); + SVN_TEST_ASSERT(!status->copied); + SVN_TEST_ASSERT(!status->switched); + SVN_TEST_ASSERT(!status->file_external); + SVN_TEST_ASSERT(status->moved_from_abspath == NULL); + SVN_TEST_ASSERT(status->moved_to_abspath == NULL); + + SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, new_file_path), + ctx, b->pool, b->pool)); + + /* Ensure that the expected tree conflict is present. */ + SVN_ERR(svn_client_conflict_get_conflicted(NULL, NULL, &tree_conflicted, + conflict, b->pool, b->pool)); + SVN_TEST_ASSERT(tree_conflicted); + SVN_TEST_ASSERT(svn_client_conflict_get_local_change(conflict) == + svn_wc_conflict_reason_added); + SVN_TEST_ASSERT(svn_client_conflict_get_incoming_change(conflict) == + svn_wc_conflict_action_add); + + return SVN_NO_ERROR; +} + +static svn_error_t * +test_update_incoming_added_file_text_merge(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_client_ctx_t *ctx; + svn_client_conflict_t *conflict; + const char *new_file_path; + svn_boolean_t text_conflicted; + apr_array_header_t *props_conflicted; + svn_boolean_t tree_conflicted; + struct status_baton sb; + struct svn_client_status_t *status; + svn_opt_revision_t opt_rev; + const svn_string_t *propval; + + svn_test__sandbox_t *b = apr_palloc(pool, sizeof(*b)); + + SVN_ERR(svn_test__sandbox_create(b, "update_incoming_added_file_text_merge", + opts, pool)); + + SVN_ERR(create_wc_with_file_add_vs_file_add_update_conflict(b)); + + /* Resolve the tree conflict. */ + SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool)); + + new_file_path = svn_relpath_join(trunk_path, new_file_name, b->pool); + SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, new_file_path), + ctx, b->pool, b->pool)); + + /* Check available tree conflict resolution options. */ + { + svn_client_conflict_option_id_t expected_opts[] = { + svn_client_conflict_option_postpone, + svn_client_conflict_option_accept_current_wc_state, + -1 /* end of list */ + }; + SVN_ERR(assert_tree_conflict_options(conflict, ctx, expected_opts, pool)); + } + + SVN_ERR(svn_client_conflict_tree_get_details(conflict, ctx, pool)); + + /* Check available tree conflict resolution options. */ + /* XFAIL: The list of options remains unchanged after get_details(). */ + { + svn_client_conflict_option_id_t expected_opts[] = { + svn_client_conflict_option_postpone, + svn_client_conflict_option_accept_current_wc_state, + svn_client_conflict_option_incoming_added_file_text_merge, + svn_client_conflict_option_incoming_added_file_replace_and_merge, + -1 /* end of list */ + }; + SVN_ERR(assert_tree_conflict_options(conflict, ctx, expected_opts, pool)); + } + + SVN_ERR(svn_client_conflict_tree_resolve_by_id( + conflict, + svn_client_conflict_option_incoming_added_file_text_merge, + ctx, b->pool)); + + /* Ensure that the file has the expected status. */ + opt_rev.kind = svn_opt_revision_working; + sb.result_pool = b->pool; + SVN_ERR(svn_client_status6(NULL, ctx, sbox_wc_path(b, new_file_path), + &opt_rev, svn_depth_unknown, TRUE, TRUE, + TRUE, TRUE, FALSE, TRUE, NULL, + status_func, &sb, b->pool)); + status = sb.status; + SVN_TEST_ASSERT(status->kind == svn_node_file); + SVN_TEST_ASSERT(status->versioned); + SVN_TEST_ASSERT(status->conflicted); + SVN_TEST_ASSERT(status->node_status == svn_wc_status_modified); + SVN_TEST_ASSERT(status->text_status == svn_wc_status_conflicted); + SVN_TEST_ASSERT(status->prop_status == svn_wc_status_modified); + SVN_TEST_ASSERT(!status->copied); + SVN_TEST_ASSERT(!status->switched); + SVN_TEST_ASSERT(!status->file_external); + SVN_TEST_ASSERT(status->moved_from_abspath == NULL); + SVN_TEST_ASSERT(status->moved_to_abspath == NULL); + + SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, new_file_path), + ctx, b->pool, b->pool)); + + /* We should have a text conflict instead of a tree conflict. */ + SVN_ERR(svn_client_conflict_get_conflicted(&text_conflicted, + &props_conflicted, + &tree_conflicted, + conflict, b->pool, b->pool)); + SVN_TEST_ASSERT(text_conflicted && + props_conflicted->nelts == 0 && + !tree_conflicted); + + /* Verify the merged property value. ### Should we have a prop conflict? */ + SVN_ERR(svn_wc_prop_get2(&propval, ctx->wc_ctx, + sbox_wc_path(b, new_file_path), + "prop", b->pool, b->pool)); + SVN_TEST_STRING_ASSERT(propval->data, propval_different); + + return SVN_NO_ERROR; +} + /* ========================================================================== */ @@ -3291,6 +3469,8 @@ static struct svn_test_descriptor_t test "merge incoming file move with new line of history"), SVN_TEST_OPTS_XFAIL(test_update_incoming_dir_move_with_nested_file_move, "update incoming dir move with nested file move"), + SVN_TEST_OPTS_XFAIL(test_update_incoming_added_file_text_merge, + "update incoming add file text merge"), SVN_TEST_NULL };