You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2012/06/29 23:11:31 UTC
svn commit: r1355561 - in /subversion/trunk/subversion: include/svn_wc.h
libsvn_wc/conflicts.c libsvn_wc/conflicts.h
tests/libsvn_wc/conflict-data-test.c
Author: rhuijben
Date: Fri Jun 29 21:11:30 2012
New Revision: 1355561
URL: http://svn.apache.org/viewvc?rev=1355561&view=rev
Log:
Implement serializing and deserializing tree conflict in the new
combined conflict skels.
* subversion/include/svn_wc.h
(svn_wc_conflict_reason_t): Add note.
* subversion/libsvn_wc/conflicts.c
(local_change_map,
incoming_change_map): New token maps.
(svn_wc__conflict_skel_add_tree_conflict,
svn_wc__conflict_read_tree_conflict): New functions.
* subversion/libsvn_wc/conflicts.h
(svn_wc__conflict_skel_add_tree_conflict): Add db, wri pair like the other
add funtions.
(svn_wc__conflict_read_tree_conflict): New function.
* subversion/tests/libsvn_wc/conflict-data-test.c
(test_serialize_tree_conflict): Rename to ...
(test_serialize_tree_conflict_data): ... this.
(test_serialize_tree_conflict): New function.
(test_funcs): Update references to show the difference between old and new
data. Add new test.
Modified:
subversion/trunk/subversion/include/svn_wc.h
subversion/trunk/subversion/libsvn_wc/conflicts.c
subversion/trunk/subversion/libsvn_wc/conflicts.h
subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c
Modified: subversion/trunk/subversion/include/svn_wc.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1355561&r1=1355560&r2=1355561&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Fri Jun 29 21:11:30 2012
@@ -1584,6 +1584,8 @@ typedef enum svn_wc_conflict_reason_t
/** Object is moved away. @since New in 1.8. */
svn_wc_conflict_reason_moved_away,
/** Object is moved away and was edited post-move. @since New in 1.8. */
+ /* ### Do we really need this. The edit state is on a different node,
+ which might just change while the tree conflict exists? */
svn_wc_conflict_reason_moved_away_and_edited,
/** Object is moved here. @since New in 1.8. */
svn_wc_conflict_reason_moved_here
Modified: subversion/trunk/subversion/libsvn_wc/conflicts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/conflicts.c?rev=1355561&r1=1355560&r2=1355561&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_wc/conflicts.c Fri Jun 29 21:11:30 2012
@@ -448,6 +448,73 @@ svn_wc__conflict_skel_add_prop_conflict(
return SVN_NO_ERROR;
}
+/* A map for svn_wc_conflict_reason_t values. */
+static const svn_token_map_t local_change_map[] =
+{
+ { "edited", svn_wc_conflict_reason_edited },
+ { "obstructed", svn_wc_conflict_reason_obstructed },
+ { "deleted", svn_wc_conflict_reason_deleted },
+ { "missing", svn_wc_conflict_reason_missing },
+ { "unversioned", svn_wc_conflict_reason_unversioned },
+ { "added", svn_wc_conflict_reason_added },
+ { "replaced", svn_wc_conflict_reason_replaced },
+ { "moved-away", svn_wc_conflict_reason_moved_away },
+ { "moved-here", svn_wc_conflict_reason_moved_here },
+ /* ### Do we really need this. The edit state is on a different node,
+ which might just change while the tree conflict exists? */
+ { "moved-and-edited", svn_wc_conflict_reason_moved_away_and_edited },
+ { NULL }
+};
+
+static const svn_token_map_t incoming_change_map[] =
+{
+ { "edited", svn_wc_conflict_action_edit },
+ { "added", svn_wc_conflict_action_add },
+ { "deleted", svn_wc_conflict_action_delete },
+ { "replaced", svn_wc_conflict_action_replace },
+ { NULL }
+};
+
+svn_error_t *
+svn_wc__conflict_skel_add_tree_conflict(svn_skel_t *conflict_skel,
+ svn_wc__db_t *db,
+ const char *wri_abspath,
+ svn_wc_conflict_reason_t local_change,
+ svn_wc_conflict_action_t incoming_change,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ svn_skel_t *tree_conflict;
+ svn_skel_t *markers;
+
+ SVN_ERR(conflict__get_conflict(&tree_conflict, conflict_skel,
+ SVN_WC__CONFLICT_KIND_TREE));
+
+ SVN_ERR_ASSERT(!tree_conflict); /* ### Use proper error? */
+
+ tree_conflict = svn_skel__make_empty_list(result_pool);
+
+ svn_skel__prepend_str(
+ svn_token__to_word(incoming_change_map, incoming_change),
+ tree_conflict, result_pool);
+
+ svn_skel__prepend_str(
+ svn_token__to_word(local_change_map, local_change),
+ tree_conflict, result_pool);
+
+ /* Tree conflicts have no marker files */
+ markers = svn_skel__make_empty_list(result_pool);
+ svn_skel__prepend(markers, tree_conflict);
+
+ svn_skel__prepend_str(SVN_WC__CONFLICT_KIND_TREE, tree_conflict,
+ result_pool);
+
+ /* And add it to the conflict skel */
+ svn_skel__prepend(tree_conflict, conflict_skel->children->next);
+
+ return SVN_NO_ERROR;
+}
+
/* A map for svn_wc_operation_t values. */
static const svn_token_map_t operation_map[] =
{
@@ -652,8 +719,55 @@ svn_wc__conflict_read_prop_conflict(cons
else
SVN_ERR(svn_skel__parse_proplist(their_props, c, result_pool));
}
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__conflict_read_tree_conflict(svn_wc_conflict_reason_t *local_change,
+ svn_wc_conflict_action_t *incoming_change,
+ svn_wc__db_t *db,
+ const char *wri_abspath,
+ const svn_skel_t *conflict_skel,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ svn_skel_t *tree_conflict;
+ svn_skel_t *c;
+
+ SVN_ERR(conflict__get_conflict(&tree_conflict, conflict_skel,
+ SVN_WC__CONFLICT_KIND_TREE));
+
+ if (!tree_conflict)
+ return svn_error_create(SVN_ERR_WC_MISSING, NULL, _("Conflict not set"));
+
+ c = tree_conflict->children;
+
+ c = c->next; /* Skip "tree" */
+
+ c = c->next; /* Skip markers */
+
+ if (local_change)
+ {
+ int value = svn_token__from_mem(local_change_map, c->data, c->len);
+
+ if (value != SVN_TOKEN_UNKNOWN)
+ *local_change = value;
+ else
+ *local_change = svn_wc_conflict_reason_edited;
+ }
c = c->next;
+ if (incoming_change)
+ {
+ int value = svn_token__from_mem(incoming_change_map, c->data, c->len);
+
+ if (value != SVN_TOKEN_UNKNOWN)
+ *incoming_change = value;
+ else
+ *incoming_change = svn_wc_conflict_action_edit;
+ }
+
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_wc/conflicts.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/conflicts.h?rev=1355561&r1=1355560&r2=1355561&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/conflicts.h (original)
+++ subversion/trunk/subversion/libsvn_wc/conflicts.h Fri Jun 29 21:11:30 2012
@@ -205,6 +205,8 @@ svn_wc__conflict_skel_add_prop_conflict(
*/
svn_error_t *
svn_wc__conflict_skel_add_tree_conflict(svn_skel_t *conflict_skel,
+ svn_wc__db_t *db,
+ const char *wri_abspath,
svn_wc_conflict_reason_t local_change,
svn_wc_conflict_action_t incoming_change,
apr_pool_t *result_pool,
@@ -275,6 +277,23 @@ svn_wc__conflict_read_prop_conflict(cons
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
+/* Reads back the original data stored by svn_wc__conflict_add_tree_conflict()
+ * in CONFLICT_SKEL for a node in DB, WRI_ABSPATH.
+ *
+ * Values as documented for svn_wc__conflict_add_tree_conflict().
+ *
+ * Output arguments can be NULL if the value is not necessary
+ * Allocate the result in RESULT_POOL. Perform temporary allocations in
+ * SCRATCH_POOL.
+ */
+svn_error_t *
+svn_wc__conflict_read_tree_conflict(svn_wc_conflict_reason_t *local_change,
+ svn_wc_conflict_action_t *incoming_change,
+ svn_wc__db_t *db,
+ const char *wri_abspath,
+ const svn_skel_t *conflict_skel,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
/* Create the necessary marker files for the conflicts stored in
* CONFLICT_SKEL and return the work items to fill the markers from
Modified: subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c?rev=1355561&r1=1355560&r2=1355561&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c Fri Jun 29 21:11:30 2012
@@ -156,7 +156,7 @@ test_deserialize_tree_conflict(apr_pool_
}
static svn_error_t *
-test_serialize_tree_conflict(apr_pool_t *pool)
+test_serialize_tree_conflict_data(apr_pool_t *pool)
{
svn_wc_conflict_description2_t *conflict;
const char *tree_conflict_data;
@@ -451,6 +451,53 @@ test_serialize_text_conflict(const svn_t
return SVN_NO_ERROR;
}
+static svn_error_t *
+test_serialize_tree_conflict(const svn_test_opts_t *opts,
+ apr_pool_t *pool)
+{
+ svn_test__sandbox_t sbox;
+ svn_skel_t *conflict_skel;
+ svn_boolean_t complete;
+
+ SVN_ERR(svn_test__sandbox_create(&sbox, "test_serialize_tree_conflict", opts, pool));
+
+ conflict_skel = svn_wc__conflict_skel_create(pool);
+
+ SVN_ERR(svn_wc__conflict_skel_add_tree_conflict(
+ conflict_skel,
+ sbox.wc_ctx->db, sbox.wc_abspath,
+ svn_wc_conflict_reason_moved_away,
+ svn_wc_conflict_action_delete,
+ pool, pool));
+
+ SVN_ERR(svn_wc__conflict_skel_set_op_switch(
+ conflict_skel,
+ svn_wc_conflict_version_create2("http://my-repos/svn",
+ "uuid", "trunk", 12,
+ svn_node_dir, pool),
+ pool, pool));
+
+ SVN_ERR(svn_wc__conflict_skel_is_complete(&complete, conflict_skel));
+ SVN_TEST_ASSERT(complete); /* Everything available */
+
+ {
+ svn_wc_conflict_reason_t local_change;
+ svn_wc_conflict_action_t incoming_change;
+
+ SVN_ERR(svn_wc__conflict_read_tree_conflict(&local_change,
+ &incoming_change,
+ 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);
+ }
+
+ return SVN_NO_ERROR;
+}
+
/* The test table. */
struct svn_test_descriptor_t test_funcs[] =
@@ -458,14 +505,16 @@ struct svn_test_descriptor_t test_funcs[
SVN_TEST_NULL,
SVN_TEST_PASS2(test_deserialize_tree_conflict,
"deserialize tree conflict"),
- SVN_TEST_PASS2(test_serialize_tree_conflict,
- "serialize tree conflict"),
+ SVN_TEST_PASS2(test_serialize_tree_conflict_data,
+ "serialize tree conflict data"),
SVN_TEST_OPTS_PASS(test_read_write_tree_conflicts,
- "read and write tree conflicts"),
+ "read and write tree conflict data"),
SVN_TEST_OPTS_PASS(test_serialize_prop_conflict,
"read and write a property conflict"),
SVN_TEST_OPTS_PASS(test_serialize_text_conflict,
"read and write a text conflict"),
+ SVN_TEST_OPTS_PASS(test_serialize_tree_conflict,
+ "read and write a tree conflict"),
SVN_TEST_NULL
};