You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/11/12 19:00:32 UTC
svn commit: r1034495 - in /subversion/trunk/subversion: libsvn_wc/entries.c
libsvn_wc/tree_conflicts.c libsvn_wc/tree_conflicts.h
tests/libsvn_wc/tree-conflict-data-test.c
Author: hwright
Date: Fri Nov 12 18:00:32 2010
New Revision: 1034495
URL: http://svn.apache.org/viewvc?rev=1034495&view=rev
Log:
Move the read_tree_conflicts() function to the file of its only caller, and
update the tests to test serialization directly.
* subversion/tests/libsvn_wc/tree-conflict-data-test.c
(test_write_tree_conflict): Test serialization directly.
(test_write_2_tree_conflicts): Remove obsolete test.
(test_funcs): Remove removed test.
* subversion/libsvn_wc/tree_conflicts.c
(svn_wc__write_tree_conflicts): Moved to entries.c.
* subversion/libsvn_wc/tree_conflicts.h
(svn_wc__write_tree_conflicts): Remove declaration from here.
* subversion/libsvn_wc/entries.c
(write_tree_conflicts): Moved here from tree_conflicts.c.
(read_one_entry): Update call size of above.
Modified:
subversion/trunk/subversion/libsvn_wc/entries.c
subversion/trunk/subversion/libsvn_wc/tree_conflicts.c
subversion/trunk/subversion/libsvn_wc/tree_conflicts.h
subversion/trunk/subversion/tests/libsvn_wc/tree-conflict-data-test.c
Modified: subversion/trunk/subversion/libsvn_wc/entries.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/entries.c?rev=1034495&r1=1034494&r2=1034495&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/entries.c (original)
+++ subversion/trunk/subversion/libsvn_wc/entries.c Fri Nov 12 18:00:32 2010
@@ -471,6 +471,42 @@ get_base_info_for_deleted(svn_wc_entry_t
}
+/*
+ * Encode tree conflict descriptions into a single string.
+ *
+ * Set *CONFLICT_DATA to a string, allocated in POOL, that encodes the tree
+ * conflicts in CONFLICTS in a form suitable for storage in a single string
+ * field in a WC entry. CONFLICTS is a hash of zero or more pointers to
+ * svn_wc_conflict_description2_t objects, index by their basenames. All of the
+ * conflict victim paths must be siblings.
+ *
+ * Do all allocations in POOL.
+ *
+ * @see svn_wc__read_tree_conflicts()
+ */
+static svn_error_t *
+write_tree_conflicts(const char **conflict_data,
+ apr_hash_t *conflicts,
+ apr_pool_t *pool)
+{
+ svn_skel_t *skel = svn_skel__make_empty_list(pool);
+ apr_hash_index_t *hi;
+
+ for (hi = apr_hash_first(pool, conflicts); hi; hi = apr_hash_next(hi))
+ {
+ svn_skel_t *c_skel;
+
+ SVN_ERR(svn_wc__serialize_conflict(&c_skel, svn__apr_hash_index_val(hi),
+ pool, pool));
+ svn_skel__prepend(c_skel, skel);
+ }
+
+ *conflict_data = svn_skel__unparse(skel, pool)->data;
+
+ return SVN_NO_ERROR;
+}
+
+
/* Read one entry from wc_db. It will be allocated in RESULT_POOL and
returned in *NEW_ENTRY.
@@ -586,9 +622,8 @@ read_one_entry(const svn_wc_entry_t **ne
if (tree_conflicts)
{
- SVN_ERR(svn_wc__write_tree_conflicts(&entry->tree_conflict_data,
- tree_conflicts,
- result_pool));
+ SVN_ERR(write_tree_conflicts(&entry->tree_conflict_data,
+ tree_conflicts, result_pool));
}
}
Modified: subversion/trunk/subversion/libsvn_wc/tree_conflicts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/tree_conflicts.c?rev=1034495&r1=1034494&r2=1034495&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/tree_conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_wc/tree_conflicts.c Fri Nov 12 18:00:32 2010
@@ -376,29 +376,6 @@ svn_wc__serialize_conflict(svn_skel_t **
svn_error_t *
-svn_wc__write_tree_conflicts(const char **conflict_data,
- apr_hash_t *conflicts,
- apr_pool_t *pool)
-{
- svn_skel_t *skel = svn_skel__make_empty_list(pool);
- apr_hash_index_t *hi;
-
- for (hi = apr_hash_first(pool, conflicts); hi; hi = apr_hash_next(hi))
- {
- svn_skel_t *c_skel;
-
- SVN_ERR(svn_wc__serialize_conflict(&c_skel, svn__apr_hash_index_val(hi),
- pool, pool));
- svn_skel__prepend(c_skel, skel);
- }
-
- *conflict_data = svn_skel__unparse(skel, pool)->data;
-
- return SVN_NO_ERROR;
-}
-
-
-svn_error_t *
svn_wc__del_tree_conflict(svn_wc_context_t *wc_ctx,
const char *victim_abspath,
apr_pool_t *scratch_pool)
Modified: subversion/trunk/subversion/libsvn_wc/tree_conflicts.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/tree_conflicts.h?rev=1034495&r1=1034494&r2=1034495&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/tree_conflicts.h (original)
+++ subversion/trunk/subversion/libsvn_wc/tree_conflicts.h Fri Nov 12 18:00:32 2010
@@ -74,23 +74,6 @@ svn_wc__deserialize_conflict(const svn_w
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
-/*
- * Encode tree conflict descriptions into a single string.
- *
- * Set *CONFLICT_DATA to a string, allocated in POOL, that encodes the tree
- * conflicts in CONFLICTS in a form suitable for storage in a single string
- * field in a WC entry. CONFLICTS is a hash of zero or more pointers to
- * svn_wc_conflict_description2_t objects, index by their basenames. All of the
- * conflict victim paths must be siblings.
- *
- * Do all allocations in POOL.
- *
- * @see svn_wc__read_tree_conflicts()
- */
-svn_error_t *
-svn_wc__write_tree_conflicts(const char **conflict_data,
- apr_hash_t *conflicts,
- apr_pool_t *pool);
/* Token mapping tables. */
extern const svn_token_map_t svn_wc__operation_map[];
Modified: subversion/trunk/subversion/tests/libsvn_wc/tree-conflict-data-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/tree-conflict-data-test.c?rev=1034495&r1=1034494&r2=1034495&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/tree-conflict-data-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/tree-conflict-data-test.c Fri Nov 12 18:00:32 2010
@@ -87,9 +87,9 @@ test_write_tree_conflict(apr_pool_t *poo
{
svn_wc_conflict_description2_t *conflict;
const char *tree_conflict_data;
- apr_hash_t *conflicts;
const char *expected;
const char *local_abspath;
+ svn_skel_t *skel;
SVN_ERR(svn_dirent_get_absolute(&local_abspath, "Foo.c", pool));
@@ -99,14 +99,11 @@ test_write_tree_conflict(apr_pool_t *poo
conflict->action = svn_wc_conflict_action_delete;
conflict->reason = svn_wc_conflict_reason_edited;
- conflicts = apr_hash_make(pool);
- apr_hash_set(conflicts, conflict->local_abspath, APR_HASH_KEY_STRING,
- conflict);
+ SVN_ERR(svn_wc__serialize_conflict(&skel, conflict, pool, pool));
+ tree_conflict_data = svn_skel__unparse(skel, pool)->data;
- expected = "((conflict Foo.c file update deleted edited "
- "(version 0 2 -1 0 0 ) (version 0 2 -1 0 0 )))";
-
- SVN_ERR(svn_wc__write_tree_conflicts(&tree_conflict_data, conflicts, pool));
+ expected = "(conflict Foo.c file update deleted edited "
+ "(version 0 2 -1 0 0 ) (version 0 2 -1 0 0 ))";
if (strcmp(expected, tree_conflict_data) != 0)
return fail(pool, "Unexpected text from tree conflict\n"
@@ -116,60 +113,6 @@ test_write_tree_conflict(apr_pool_t *poo
return SVN_NO_ERROR;
}
-static svn_error_t *
-test_write_2_tree_conflicts(apr_pool_t *pool)
-{
- svn_wc_conflict_description2_t *conflict1, *conflict2;
- apr_hash_t *conflicts;
- const char *tree_conflict_data;
- const char *expected1;
- const char *expected2;
- const char *local_abspath;
-
- SVN_ERR(svn_dirent_get_absolute(&local_abspath, "Foo.c", pool));
- conflict1 = svn_wc_conflict_description_create_tree2(
- local_abspath, svn_node_file, svn_wc_operation_update,
- NULL, NULL, pool);
- conflict1->action = svn_wc_conflict_action_delete;
- conflict1->reason = svn_wc_conflict_reason_edited;
-
- SVN_ERR(svn_dirent_get_absolute(&local_abspath, "Bar.h", pool));
- conflict2 = svn_wc_conflict_description_create_tree2(
- local_abspath, svn_node_file, svn_wc_operation_update,
- NULL, NULL, pool);
- conflict2->action = svn_wc_conflict_action_edit;
- conflict2->reason = svn_wc_conflict_reason_deleted;
-
- conflicts = apr_hash_make(pool);
- apr_hash_set(conflicts, conflict1->local_abspath, APR_HASH_KEY_STRING,
- conflict1);
- apr_hash_set(conflicts, conflict2->local_abspath, APR_HASH_KEY_STRING,
- conflict2);
-
- /* We don't know the order the hash will spit out the data, so just test
- for both possibilities. */
- expected1 = "((conflict Foo.c file update deleted edited "
- "(version 0 2 -1 0 0 ) (version 0 2 -1 0 0 )) "
- "(conflict Bar.h file update edited deleted "
- "(version 0 2 -1 0 0 ) (version 0 2 -1 0 0 )))";
- expected2 = "((conflict Bar.h file update edited deleted "
- "(version 0 2 -1 0 0 ) (version 0 2 -1 0 0 )) "
- "(conflict Foo.c file update deleted edited "
- "(version 0 2 -1 0 0 ) (version 0 2 -1 0 0 )))";
-
- SVN_ERR(svn_wc__write_tree_conflicts(&tree_conflict_data, conflicts, pool));
-
- if (strcmp(expected1, tree_conflict_data) != 0
- && strcmp(expected2, tree_conflict_data) != 0)
- return fail(pool, "Unexpected text from tree conflict\n"
- " Expected: %s\n"
- " OR %s\n"
- " Actual: %s\n", expected1, expected2,
- tree_conflict_data);
-
- return SVN_NO_ERROR;
-}
-
#ifdef THIS_TEST_RAISES_MALFUNCTION
static svn_error_t *
test_write_invalid_tree_conflicts(apr_pool_t *pool)
@@ -271,8 +214,6 @@ struct svn_test_descriptor_t test_funcs[
"read 1 tree conflict"),
SVN_TEST_PASS2(test_write_tree_conflict,
"write 1 tree conflict"),
- SVN_TEST_PASS2(test_write_2_tree_conflicts,
- "write 2 tree conflicts"),
#ifdef THIS_TEST_RAISES_MALFUNCTION
SVN_TEST_PASS2(test_write_invalid_tree_conflicts,
"detect broken tree conflict data while writing"),