summaryrefslogtreecommitdiff
path: root/subversion/tests/libsvn_wc/conflict-data-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/tests/libsvn_wc/conflict-data-test.c')
-rw-r--r--subversion/tests/libsvn_wc/conflict-data-test.c178
1 files changed, 164 insertions, 14 deletions
diff --git a/subversion/tests/libsvn_wc/conflict-data-test.c b/subversion/tests/libsvn_wc/conflict-data-test.c
index 97d22ea..7d89825 100644
--- a/subversion/tests/libsvn_wc/conflict-data-test.c
+++ b/subversion/tests/libsvn_wc/conflict-data-test.c
@@ -134,7 +134,7 @@ compare_file_content(const char *file_abspath,
* conflict, or are both NULL. Return an error if not.
*
* Compare the property values found in files named by
- * ACTUAL->base_abspath, ACTUAL->my_abspath, ACTUAL->merged_abspath
+ * ACTUAL->base_abspath, ACTUAL->my_abspath, ACTUAL->merged_file
* with EXPECTED_BASE_VAL, EXPECTED_MY_VAL, EXPECTED_THEIR_VAL
* respectively, ignoring the corresponding fields in EXPECTED. */
static svn_error_t *
@@ -236,8 +236,8 @@ test_deserialize_tree_conflict(apr_pool_t *pool)
SVN_ERR(svn_wc__deserialize_conflict(&conflict, skel, "", pool, pool));
if ((conflict->node_kind != exp_conflict->node_kind) ||
- (conflict->action != exp_conflict->action) ||
- (conflict->reason != exp_conflict->reason) ||
+ (conflict->action != exp_conflict->action) ||
+ (conflict->reason != exp_conflict->reason) ||
(conflict->operation != exp_conflict->operation) ||
(strcmp(conflict->local_abspath, exp_conflict->local_abspath) != 0))
return fail(pool, "Unexpected tree conflict");
@@ -289,10 +289,12 @@ test_read_write_tree_conflicts(const svn_test_opts_t *opts,
SVN_ERR(svn_test__sandbox_create(&sbox, "read_write_tree_conflicts", opts, pool));
parent_abspath = svn_dirent_join(sbox.wc_abspath, "A", pool);
- SVN_ERR(svn_wc__db_op_add_directory(sbox.wc_ctx->db, parent_abspath,
- NULL /*props*/, NULL, pool));
child1_abspath = svn_dirent_join(parent_abspath, "foo", pool);
child2_abspath = svn_dirent_join(parent_abspath, "bar", pool);
+ SVN_ERR(sbox_wc_mkdir(&sbox, "A"));
+ SVN_ERR(sbox_wc_mkdir(&sbox, "A/bar"));
+ SVN_ERR(sbox_file_write(&sbox, "A/foo", ""));
+ SVN_ERR(sbox_wc_add(&sbox, "A/foo"));
conflict1 = tree_conflict_create(child1_abspath, svn_node_file,
svn_wc_operation_merge,
@@ -606,22 +608,22 @@ test_serialize_tree_conflict(const svn_test_opts_t *opts,
SVN_TEST_ASSERT(complete); /* Everything available */
{
- svn_wc_conflict_reason_t local_change;
- svn_wc_conflict_action_t incoming_change;
+ svn_wc_conflict_reason_t reason;
+ svn_wc_conflict_action_t action;
const char *moved_away_op_root_abspath;
- SVN_ERR(svn_wc__conflict_read_tree_conflict(&local_change,
- &incoming_change,
+ SVN_ERR(svn_wc__conflict_read_tree_conflict(&reason,
+ &action,
&moved_away_op_root_abspath,
sbox.wc_ctx->db,
sbox.wc_abspath,
conflict_skel,
pool, pool));
- SVN_TEST_ASSERT(local_change == svn_wc_conflict_reason_moved_away);
- SVN_TEST_ASSERT(incoming_change == svn_wc_conflict_action_delete);
- SVN_TEST_ASSERT(!strcmp(moved_away_op_root_abspath,
- sbox_wc_path(&sbox, "A/B")));
+ SVN_TEST_ASSERT(reason == svn_wc_conflict_reason_moved_away);
+ SVN_TEST_ASSERT(action == svn_wc_conflict_action_delete);
+ SVN_TEST_STRING_ASSERT(moved_away_op_root_abspath,
+ sbox_wc_path(&sbox, "A/B"));
}
return SVN_NO_ERROR;
@@ -807,9 +809,152 @@ test_prop_conflicts(const svn_test_opts_t *opts,
return SVN_NO_ERROR;
}
+static svn_error_t *
+test_prop_conflict_resolving(const svn_test_opts_t *opts,
+ apr_pool_t *pool)
+{
+ svn_test__sandbox_t b;
+ svn_skel_t *conflict;
+ const char *A_abspath;
+ const char *marker_abspath;
+ apr_hash_t *conflicted_props;
+ apr_hash_t *props;
+ const char *value;
+
+ SVN_ERR(svn_test__sandbox_create(&b, "test_prop_resolving", opts, pool));
+ SVN_ERR(sbox_wc_mkdir(&b, "A"));
+
+ SVN_ERR(sbox_wc_propset(&b, "prop-1", "r1", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-2", "r1", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-3", "r1", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-4", "r1", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-5", "r1", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-6", "r1", "A"));
+
+ SVN_ERR(sbox_wc_commit(&b, ""));
+ SVN_ERR(sbox_wc_propset(&b, "prop-1", "r2", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-2", "r2", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-3", "r2", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-4", NULL, "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-5", NULL, "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-7", "r2", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-8", "r2", "A"));
+ SVN_ERR(sbox_wc_commit(&b, ""));
+
+ SVN_ERR(sbox_wc_propset(&b, "prop-1", "mod", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-2", "mod", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-3", "mod", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-4", "mod", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-5", "mod", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-6", "mod", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-7", "mod", "A"));
+ SVN_ERR(sbox_wc_propset(&b, "prop-8", "mod", "A"));
+
+ SVN_ERR(sbox_wc_update(&b, "", 1));
+
+ A_abspath = sbox_wc_path(&b, "A");
+ SVN_ERR(svn_wc__db_read_conflict(&conflict, NULL, NULL,
+ b.wc_ctx->db, A_abspath,
+ pool, pool));
+
+ /* We have tree conflicts... */
+ SVN_TEST_ASSERT(conflict != NULL);
+
+ SVN_ERR(svn_wc__conflict_read_prop_conflict(&marker_abspath,
+ NULL, NULL, NULL,
+ &conflicted_props,
+ b.wc_ctx->db, A_abspath,
+ conflict,
+ pool, pool));
+
+ SVN_TEST_ASSERT(conflicted_props != NULL);
+ /* All properties but r6 are conflicted */
+ SVN_TEST_ASSERT(apr_hash_count(conflicted_props) == 7);
+ SVN_TEST_ASSERT(! svn_hash_gets(conflicted_props, "prop-6"));
+
+ /* Let's resolve a few conflicts */
+ SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-1",
+ svn_wc_conflict_choose_mine_conflict));
+ SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-2",
+ svn_wc_conflict_choose_theirs_conflict));
+ SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-3",
+ svn_wc_conflict_choose_merged));
+
+ SVN_ERR(svn_wc__db_read_conflict(&conflict, NULL, NULL,
+ b.wc_ctx->db, A_abspath,
+ pool, pool));
+
+ /* We have tree conflicts... */
+ SVN_TEST_ASSERT(conflict != NULL);
+
+ SVN_ERR(svn_wc__conflict_read_prop_conflict(&marker_abspath,
+ NULL, NULL, NULL,
+ &conflicted_props,
+ b.wc_ctx->db, A_abspath,
+ conflict,
+ pool, pool));
+
+ SVN_TEST_ASSERT(conflicted_props != NULL);
+ SVN_TEST_ASSERT(apr_hash_count(conflicted_props) == 4);
+
+ SVN_ERR(svn_wc__db_read_props(&props, b.wc_ctx->db, A_abspath,
+ pool, pool));
+
+ value = svn_prop_get_value(props, "prop-1");
+ SVN_TEST_STRING_ASSERT(value, "mod");
+ value = svn_prop_get_value(props, "prop-2");
+ SVN_TEST_STRING_ASSERT(value, "r1");
+ value = svn_prop_get_value(props, "prop-3");
+ SVN_TEST_STRING_ASSERT(value, "mod");
+
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_binary_file_conflict(const svn_test_opts_t *opts,
+ apr_pool_t *pool)
+{
+ svn_test__sandbox_t sbox;
+ const apr_array_header_t *conflicts;
+ svn_wc_conflict_description2_t *desc;
+
+ SVN_ERR(svn_test__sandbox_create(&sbox, "test_binary_file_conflict", opts, pool));
+
+ /* Create and add a binary file. */
+ SVN_ERR(sbox_file_write(&sbox, "binary-file", "\xff\xff"));
+ SVN_ERR(sbox_wc_add(&sbox, "binary-file"));
+ SVN_ERR(sbox_wc_propset(&sbox, SVN_PROP_MIME_TYPE,
+ "application/octet-stream", "binary-file"));
+ SVN_ERR(sbox_wc_commit(&sbox, "binary-file")); /* r1 */
+
+ /* Make a change to the binary file. */
+ SVN_ERR(sbox_file_write(&sbox, "binary-file", "\xfc\xfc\xfc\xfc\xfc\xfc"));
+ SVN_ERR(sbox_wc_commit(&sbox, "binary-file")); /* r2 */
+
+ /* Update back to r1, make a conflicting change to binary file. */
+ SVN_ERR(sbox_wc_update(&sbox, "binary-file", 1));
+ SVN_ERR(sbox_file_write(&sbox, "binary-file", "\xfd\xfd\xfd\xfd"));
+
+ /* Update to HEAD and ensure the conflict is marked as binary. */
+ SVN_ERR(sbox_wc_update(&sbox, "binary-file", 2));
+ SVN_ERR(svn_wc__read_conflicts(&conflicts, NULL, sbox.wc_ctx->db,
+ sbox_wc_path(&sbox, "binary-file"),
+ FALSE /* create_tempfiles */,
+ FALSE /* only_tree_conflict */,
+ pool, pool));
+ SVN_TEST_ASSERT(conflicts->nelts == 1);
+ desc = APR_ARRAY_IDX(conflicts, 0, svn_wc_conflict_description2_t *);
+ SVN_TEST_ASSERT(desc->is_binary);
+
+ return SVN_NO_ERROR;
+}
+
+
/* The test table. */
-struct svn_test_descriptor_t test_funcs[] =
+static int max_threads = 1;
+
+static struct svn_test_descriptor_t test_funcs[] =
{
SVN_TEST_NULL,
SVN_TEST_PASS2(test_deserialize_tree_conflict,
@@ -826,6 +971,11 @@ struct svn_test_descriptor_t test_funcs[] =
"read and write a tree conflict"),
SVN_TEST_OPTS_PASS(test_prop_conflicts,
"test prop conflicts"),
+ SVN_TEST_OPTS_PASS(test_prop_conflict_resolving,
+ "test property conflict resolving"),
+ SVN_TEST_OPTS_PASS(test_binary_file_conflict,
+ "test binary file conflict"),
SVN_TEST_NULL
};
+SVN_TEST_MAIN