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 18:18:27 UTC

svn commit: r1034476 - in /subversion/trunk/subversion: libsvn_wc/tree_conflicts.c libsvn_wc/tree_conflicts.h libsvn_wc/upgrade.c tests/libsvn_wc/tree-conflict-data-test.c

Author: hwright
Date: Fri Nov 12 17:18:27 2010
New Revision: 1034476

URL: http://svn.apache.org/viewvc?rev=1034476&view=rev
Log:
Move the read_tree_conflicts() function to upgrade.c, as that is now the only
place where it is (and will be) used.  Update the tests, including the removal
of a couple of obsolete tests.

* subversion/tests/libsvn_wc/tree-conflict-data-test.c
  (test_read_tree_conflict): Test deserialization directly, rather than via
    svn_wc__read_tree_conflicts().
  (test_read_2_tree_conflicts, broken_tree_conflict_test_data,
   test_read_invalid_tree_conflicts): Remove.
  (test_funcs): Don't run removed tests.

* subversion/libsvn_wc/tree_conflicts.c
  (svn_wc__read_tree_conflicts): Move from here to upgrade.c.

* subversion/libsvn_wc/tree_conflicts.h
  (svn_wc__read_tree_conflicts): Remove declaration.

* subversion/libsvn_wc/upgrade.c
  (read_tree_conflicts): Moved here from tree_conflicts.c.
  (migrate_single_tree_conflict_data): Update function reference.

Modified:
    subversion/trunk/subversion/libsvn_wc/tree_conflicts.c
    subversion/trunk/subversion/libsvn_wc/tree_conflicts.h
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/tests/libsvn_wc/tree-conflict-data-test.c

Modified: subversion/trunk/subversion/libsvn_wc/tree_conflicts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/tree_conflicts.c?rev=1034476&r1=1034475&r2=1034476&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/tree_conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_wc/tree_conflicts.c Fri Nov 12 17:18:27 2010
@@ -267,47 +267,6 @@ svn_wc__deserialize_conflict(const svn_w
 }
 
 
-/* ### this is BAD. the CONFLICTS structure should not be dependent upon
-   ### DIR_PATH. each conflict should be labeled with an entry name, not
-   ### a whole path. (and a path which happens to vary based upon invocation
-   ### of the user client and these APIs)  */
-svn_error_t *
-svn_wc__read_tree_conflicts(apr_hash_t **conflicts,
-                            const char *conflict_data,
-                            const char *dir_path,
-                            apr_pool_t *pool)
-{
-  const svn_skel_t *skel;
-  apr_pool_t *iterpool;
-
-  *conflicts = apr_hash_make(pool);
-
-  if (conflict_data == NULL)
-    return SVN_NO_ERROR;
-
-  skel = svn_skel__parse(conflict_data, strlen(conflict_data), pool);
-  if (skel == NULL)
-    return svn_error_create(SVN_ERR_WC_CORRUPT, NULL,
-                            _("Error parsing tree conflict skel"));
-
-  iterpool = svn_pool_create(pool);
-  for (skel = skel->children; skel != NULL; skel = skel->next)
-    {
-      const svn_wc_conflict_description2_t *conflict;
-
-      svn_pool_clear(iterpool);
-      SVN_ERR(svn_wc__deserialize_conflict(&conflict, skel, dir_path,
-                                           pool, iterpool));
-      if (conflict != NULL)
-        apr_hash_set(*conflicts, svn_dirent_basename(conflict->local_abspath,
-                                                     pool),
-                     APR_HASH_KEY_STRING, conflict);
-    }
-  svn_pool_destroy(iterpool);
-
-  return SVN_NO_ERROR;
-}
-
 /* Prepend to SKEL the string corresponding to enumeration value N, as found
  * in MAP. */
 static svn_error_t *

Modified: subversion/trunk/subversion/libsvn_wc/tree_conflicts.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/tree_conflicts.h?rev=1034476&r1=1034475&r2=1034476&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/tree_conflicts.h (original)
+++ subversion/trunk/subversion/libsvn_wc/tree_conflicts.h Fri Nov 12 17:18:27 2010
@@ -92,20 +92,6 @@ svn_wc__write_tree_conflicts(const char 
                              apr_hash_t *conflicts,
                              apr_pool_t *pool);
 
-/*
- * Read tree conflict descriptions from @a conflict_data.  Set @a *conflicts
- * to a hash of pointers to svn_wc_conflict_description2_t objects indexed by
- * svn_wc_conflict_description2_t.local_abspath, all newly allocated in @a
- * pool.  @a dir_path is the path to the working copy directory whose conflicts
- * are being read.  The conflicts read are the tree conflicts on the immediate
- * child nodes of @a dir_path.  Do all allocations in @a pool.
- */
-svn_error_t *
-svn_wc__read_tree_conflicts(apr_hash_t **conflicts,
-                            const char *conflict_data,
-                            const char *dir_path,
-                            apr_pool_t *pool);
-
 /* Token mapping tables.  */
 extern const svn_token_map_t svn_wc__operation_map[];
 extern const svn_token_map_t svn_wc__conflict_action_map[];

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1034476&r1=1034475&r2=1034476&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Fri Nov 12 17:18:27 2010
@@ -631,6 +631,60 @@ bump_to_13(void *baton, svn_sqlite__db_t
   return SVN_NO_ERROR;
 }
 
+/*
+ * Read tree conflict descriptions from @a conflict_data.  Set @a *conflicts
+ * to a hash of pointers to svn_wc_conflict_description2_t objects indexed by
+ * svn_wc_conflict_description2_t.local_abspath, all newly allocated in @a
+ * pool.  @a dir_path is the path to the working copy directory whose conflicts
+ * are being read.  The conflicts read are the tree conflicts on the immediate
+ * child nodes of @a dir_path.  Do all allocations in @a pool.
+ *
+ * Note: There were some concerns about this function:
+ *
+ * ### this is BAD. the CONFLICTS structure should not be dependent upon
+ * ### DIR_PATH. each conflict should be labeled with an entry name, not
+ * ### a whole path. (and a path which happens to vary based upon invocation
+ * ### of the user client and these APIs)
+ *
+ * those assumptions were baked into former versions of the data model, so
+ * they have to stick around here.  But they have been removed from the
+ * New Way. */
+static svn_error_t *
+read_tree_conflicts(apr_hash_t **conflicts,
+                    const char *conflict_data,
+                    const char *dir_path,
+                    apr_pool_t *pool)
+{
+  const svn_skel_t *skel;
+  apr_pool_t *iterpool;
+
+  *conflicts = apr_hash_make(pool);
+
+  if (conflict_data == NULL)
+    return SVN_NO_ERROR;
+
+  skel = svn_skel__parse(conflict_data, strlen(conflict_data), pool);
+  if (skel == NULL)
+    return svn_error_create(SVN_ERR_WC_CORRUPT, NULL,
+                            _("Error parsing tree conflict skel"));
+
+  iterpool = svn_pool_create(pool);
+  for (skel = skel->children; skel != NULL; skel = skel->next)
+    {
+      const svn_wc_conflict_description2_t *conflict;
+
+      svn_pool_clear(iterpool);
+      SVN_ERR(svn_wc__deserialize_conflict(&conflict, skel, dir_path,
+                                           pool, iterpool));
+      if (conflict != NULL)
+        apr_hash_set(*conflicts, svn_dirent_basename(conflict->local_abspath,
+                                                     pool),
+                     APR_HASH_KEY_STRING, conflict);
+    }
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
 
 /* */
 static svn_error_t *
@@ -644,8 +698,8 @@ migrate_single_tree_conflict_data(svn_sq
   apr_hash_index_t *hi;
   apr_pool_t *iterpool;
 
-  SVN_ERR(svn_wc__read_tree_conflicts(&conflicts, tree_conflict_data,
-                                      local_relpath, scratch_pool));
+  SVN_ERR(read_tree_conflicts(&conflicts, tree_conflict_data, local_relpath,
+                              scratch_pool));
 
   iterpool = svn_pool_create(scratch_pool);
   for (hi = apr_hash_first(scratch_pool, conflicts);

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=1034476&r1=1034475&r2=1034476&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 17:18:27 2010
@@ -53,15 +53,14 @@ fail(apr_pool_t *pool, const char *fmt, 
 static svn_error_t *
 test_read_tree_conflict(apr_pool_t *pool)
 {
-  svn_wc_conflict_description2_t *conflict;
-  apr_hash_t *conflicts;
+  const svn_wc_conflict_description2_t *conflict;
   svn_wc_conflict_description2_t *exp_conflict;
   const char *tree_conflict_data;
-  apr_hash_index_t *hi;
   const char *local_abspath;
+  const svn_skel_t *skel;
 
-  tree_conflict_data = "((conflict Foo.c file update deleted edited "
-                         "(version 0  2 -1 0  0 ) (version 0  2 -1 0  0 )))";
+  tree_conflict_data = "(conflict Foo.c file update deleted edited "
+                        "(version 0  2 -1 0  0 ) (version 0  2 -1 0  0 ))";
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, "Foo.c", pool));
   exp_conflict = svn_wc_conflict_description_create_tree2(
@@ -70,11 +69,8 @@ test_read_tree_conflict(apr_pool_t *pool
   exp_conflict->action = svn_wc_conflict_action_delete;
   exp_conflict->reason = svn_wc_conflict_reason_edited;
 
-  SVN_ERR(svn_wc__read_tree_conflicts(&conflicts, tree_conflict_data, "",
-                                      pool));
-
-  hi = apr_hash_first(pool, conflicts);
-  conflict = svn__apr_hash_index_val(hi);
+  skel = svn_skel__parse(tree_conflict_data, strlen(tree_conflict_data), pool);
+  SVN_ERR(svn_wc__deserialize_conflict(&conflict, skel, "", pool, pool));
 
   if ((conflict->node_kind != exp_conflict->node_kind) ||
       (conflict->action    != exp_conflict->action) ||
@@ -87,113 +83,6 @@ test_read_tree_conflict(apr_pool_t *pool
 }
 
 static svn_error_t *
-test_read_2_tree_conflicts(apr_pool_t *pool)
-{
-  const char *tree_conflict_data;
-  svn_wc_conflict_description2_t *conflict1, *conflict2;
-  apr_hash_t *conflicts;
-  svn_wc_conflict_description2_t *exp_conflict1, *exp_conflict2;
-  apr_hash_index_t *hi;
-  const char *local_abspath;
-
-  tree_conflict_data =
-    "((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 )))";
-
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, "Foo.c", pool));
-  exp_conflict1 = svn_wc_conflict_description_create_tree2(
-                        local_abspath, svn_node_file, svn_wc_operation_update,
-                        NULL, NULL, pool);
-  exp_conflict1->action = svn_wc_conflict_action_delete;
-  exp_conflict1->reason = svn_wc_conflict_reason_edited;
-
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, "Bar.h", pool));
-  exp_conflict2 = svn_wc_conflict_description_create_tree2(
-                        local_abspath, svn_node_file, svn_wc_operation_update,
-                         NULL, NULL, pool);
-  exp_conflict2->action = svn_wc_conflict_action_edit;
-  exp_conflict2->reason = svn_wc_conflict_reason_deleted;
-
-  SVN_ERR(svn_wc__read_tree_conflicts(&conflicts, tree_conflict_data, "",
-                                      pool));
-
-  hi = apr_hash_first(pool, conflicts);
-  conflict1 = svn__apr_hash_index_val(hi);
-  if ((conflict1->node_kind != exp_conflict1->node_kind) ||
-      (conflict1->action    != exp_conflict1->action) ||
-      (conflict1->reason    != exp_conflict1->reason) ||
-      (conflict1->operation != exp_conflict1->operation) ||
-      (strcmp(conflict1->local_abspath, exp_conflict1->local_abspath) != 0))
-    return fail(pool, "Tree conflict struct #1 has bad data");
-
-  hi = apr_hash_next(hi);
-  conflict2 = svn__apr_hash_index_val(hi);
-  if ((conflict2->node_kind != exp_conflict2->node_kind) ||
-      (conflict2->action    != exp_conflict2->action) ||
-      (conflict2->reason    != exp_conflict2->reason) ||
-      (conflict2->operation != exp_conflict2->operation) ||
-      (strcmp(conflict2->local_abspath, exp_conflict2->local_abspath) != 0))
-    return fail(pool, "Tree conflict struct #2 has bad data");
-
-  return SVN_NO_ERROR;
-}
-
-/* This needs to be adjusted in case the constants for the
- * delimiters change... */
-static const char* broken_tree_conflict_test_data[] = {
-  /* Missing descriptions */
-  "|Bar.h:file:update:edited:deleted::::::::",
-  "Foo.c:file:update:deleted:edited::::::::|",
-  "|||||||",
-  "",
-  /* Missing fields */
-  "Foo.c:fileupdate:deleted:edited::::::::",
-  "Foo.c",
-  "::::",
-  ":::",
-  "Foo.c:::::::::::::;",
-  /* Bad separators */
-  "Foo.c:file:update:deleted:edited::::::::$Bar.h:file:update:edited:deleted::::::::",
-  "Foo.c|file|update|deleted|edited:::::::::Bar.h|file|update|edited|deleted::::::::",
-  /* Missing separators */
-  "Foo.c:file:update:deleted:edited::::::::Bar.h:file:update:edited:deleted::::::::",
-  "Foo.c:fileupdate:deleted:edited::::::::",
-  /* Unescaped separators */
-  "F|oo.c:file:update:deleted:edited::::::::",
-  "F:oo.c:file:update:deleted:edited::::::::",
-  /* Unescaped escape */
-  "Foo.c\\:file:update:deleted:edited::::::::",
-  "Foo.c\\",
-  /* Illegally escaped char */
-  "\\Foo.c:file:update:deleted:edited::::::::",
-  NULL
-};
-
-static svn_error_t *
-test_read_invalid_tree_conflicts(apr_pool_t *pool)
-{
-  int i;
-  const char *tree_conflict_data;
-  apr_hash_t *conflicts;
-  svn_error_t *err;
-
-  for (i = 0; broken_tree_conflict_test_data[i] != NULL; i++)
-    {
-      tree_conflict_data = broken_tree_conflict_test_data[i];
-      err = svn_wc__read_tree_conflicts(&conflicts, tree_conflict_data, "",
-                                        pool);
-      if (err == SVN_NO_ERROR)
-        return fail(pool,
-                    "Error in broken tree conflict data was not detected:\n"
-                    "  %s", tree_conflict_data);
-      svn_error_clear(err);
-    }
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
 test_write_tree_conflict(apr_pool_t *pool)
 {
   svn_wc_conflict_description2_t *conflict;
@@ -380,10 +269,6 @@ struct svn_test_descriptor_t test_funcs[
     SVN_TEST_NULL,
     SVN_TEST_PASS2(test_read_tree_conflict,
                    "read 1 tree conflict"),
-    SVN_TEST_PASS2(test_read_2_tree_conflicts,
-                   "read 2 tree conflicts"),
-    SVN_TEST_XFAIL2(test_read_invalid_tree_conflicts,
-                    "detect broken tree conflict data"),
     SVN_TEST_PASS2(test_write_tree_conflict,
                    "write 1 tree conflict"),
     SVN_TEST_PASS2(test_write_2_tree_conflicts,