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/11 22:38:17 UTC

svn commit: r1034155 - in /subversion/trunk/subversion: libsvn_wc/upgrade.c libsvn_wc/wc-metadata.sql libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c tests/cmdline/upgrade_tests.py tests/cmdline/upgrade_tests_data/upgrade_tc.tar.bz2

Author: hwright
Date: Thu Nov 11 21:38:17 2010
New Revision: 1034155

URL: http://svn.apache.org/viewvc?rev=1034155&view=rev
Log:
Implement upgrade code from format 20 to format 21, wherein the tree conflict
data moves from being stored on the parent node to the actual victim node.

This does not yet actually upgrade the format, that will happen in a subsequent
commit.  (Note: the test should function in either environment.)

* subversion/tests/cmdline/upgrade_tests.py
  (upgrade_tree_conflict_data): New.
  (test_list): Run the new test.

* subversion/tests/cmdline/upgrade_tests_data/upgrade_tc.tar.bz2:
  New.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_INSERT_NEW_CONFLICT): Remove obsolete (and not even valid) query.
 
* subversion/libsvn_wc/wc-metadata.sql
  (STMT_UPGRADE_TO_21): New.
 
* subversion/libsvn_wc/wc_db.c:
  Define TREE_CONFLICTS_ON_CHILDREN if given the proper SVN_WC__VERSION.

* subversion/libsvn_wc/upgrade.c
  (kind_to_word, conflict_kind_to_word, conflict_action_to_word,
   conflict_reason_to_word, wc_operation_to_word, db_kind_from_node_kind):
    Remove old cruft.
  (migrate_single_tree_conflict_data): Rewrite for the updated conflict
    storage paradigm.
  (migrate_tree_conflict_data): Same.
  (bump_to_21): New.
  (bump_to_XXX): Remove cruft.
  (svn_wc__upgrade_sdb): Add VERSION-wrapped upgrade case.

Added:
    subversion/trunk/subversion/tests/cmdline/upgrade_tests_data/upgrade_tc.tar.bz2   (with props)
Modified:
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/libsvn_wc/wc-metadata.sql
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/tests/cmdline/upgrade_tests.py

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1034155&r1=1034154&r2=1034155&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Thu Nov 11 21:38:17 2010
@@ -632,91 +632,6 @@ bump_to_13(void *baton, svn_sqlite__db_t
 }
 
 
-#if 0 /* ### no tree conflict migration yet */
-
-/* ### duplicated from wc_db.c  */
-static const char *
-kind_to_word(svn_wc__db_kind_t kind)
-{
-  switch (kind)
-    {
-    case svn_wc__db_kind_dir:
-      return "dir";
-    case svn_wc__db_kind_file:
-      return "file";
-    case svn_wc__db_kind_symlink:
-      return "symlink";
-    case svn_wc__db_kind_unknown:
-      return "unknown";
-    case svn_wc__db_kind_subdir:
-      return "subdir";
-    default:
-      SVN_ERR_MALFUNCTION_NO_RETURN();
-    }
-}
-
-
-/* */
-static const char *
-conflict_kind_to_word(svn_wc_conflict_kind_t conflict_kind)
-{
-  switch (conflict_kind)
-    {
-    case svn_wc_conflict_kind_text:
-      return "text";
-    case svn_wc_conflict_kind_property:
-      return "property";
-    case svn_wc_conflict_kind_tree:
-      return "tree";
-    default:
-      SVN_ERR_MALFUNCTION_NO_RETURN();
-    }
-}
-
-
-/* */
-static const char *
-conflict_action_to_word(svn_wc_conflict_action_t action)
-{
-  return svn_token__to_word(svn_wc__conflict_action_map, action);
-}
-
-
-/* */
-static const char *
-conflict_reason_to_word(svn_wc_conflict_reason_t reason)
-{
-  return svn_token__to_word(svn_wc__conflict_reason_map, reason);
-}
-
-
-/* */
-static const char *
-wc_operation_to_word(svn_wc_operation_t operation)
-{
-  return svn_token__to_word(svn_wc__operation_map, operation);
-}
-
-
-/* */
-static svn_wc__db_kind_t
-db_kind_from_node_kind(svn_node_kind_t node_kind)
-{
-  switch (node_kind)
-    {
-    case svn_node_file:
-      return svn_wc__db_kind_file;
-    case svn_node_dir:
-      return svn_wc__db_kind_dir;
-    case svn_node_unknown:
-    case svn_node_none:
-      return svn_wc__db_kind_unknown;
-    default:
-      SVN_ERR_MALFUNCTION_NO_RETURN();
-    }
-}
-
-
 /* */
 static svn_error_t *
 migrate_single_tree_conflict_data(svn_sqlite__db_t *sdb,
@@ -725,14 +640,10 @@ migrate_single_tree_conflict_data(svn_sq
                                   const char *local_relpath,
                                   apr_pool_t *scratch_pool)
 {
-  svn_sqlite__stmt_t *insert_stmt;
   apr_hash_t *conflicts;
   apr_hash_index_t *hi;
   apr_pool_t *iterpool;
 
-  SVN_ERR(svn_sqlite__get_statement(&insert_stmt, sdb,
-                                    STMT_INSERT_NEW_CONFLICT));
-
   SVN_ERR(svn_wc__read_tree_conflicts(&conflicts, tree_conflict_data,
                                       local_relpath, scratch_pool));
 
@@ -744,8 +655,10 @@ migrate_single_tree_conflict_data(svn_sq
       const svn_wc_conflict_description2_t *conflict =
           svn__apr_hash_index_val(hi);
       const char *conflict_relpath;
-      apr_int64_t left_repos_id;
-      apr_int64_t right_repos_id;
+      const char *conflict_data;
+      svn_sqlite__stmt_t *stmt;
+      svn_boolean_t have_row;
+      svn_skel_t *skel;
 
       svn_pool_clear(iterpool);
 
@@ -754,72 +667,34 @@ migrate_single_tree_conflict_data(svn_sq
                                            conflict->local_abspath, iterpool),
                                          iterpool);
 
-      /* Optionally get the right repos ids. */
-      if (conflict->src_left_version)
-        {
-          SVN_ERR(svn_wc__db_upgrade_get_repos_id(
-                    &left_repos_id,
-                    sdb,
-                    conflict->src_left_version->repos_url,
-                    iterpool));
-        }
+      SVN_ERR(svn_wc__serialize_conflict(&skel, conflict, iterpool, iterpool));
+      conflict_data = svn_skel__unparse(skel, iterpool)->data;
 
-      if (conflict->src_right_version)
-        {
-          SVN_ERR(svn_wc__db_upgrade_get_repos_id(
-                    &right_repos_id,
-                    sdb,
-                    conflict->src_right_version->repos_url,
-                    iterpool));
-        }
+      /* See if we need to update or insert an ACTUAL node. */
+      SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_SELECT_ACTUAL_NODE));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, conflict_relpath));
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+      SVN_ERR(svn_sqlite__reset(stmt));
 
-      SVN_ERR(svn_sqlite__bindf(insert_stmt, "is", wc_id, conflict_relpath));
-
-      SVN_ERR(svn_sqlite__bind_text(insert_stmt, 3,
-                                    svn_dirent_dirname(conflict_relpath,
-                                                       iterpool)));
-      SVN_ERR(svn_sqlite__bind_text(insert_stmt, 4,
-                                    kind_to_word(db_kind_from_node_kind(
-                                                        conflict->node_kind))));
-      SVN_ERR(svn_sqlite__bind_text(insert_stmt, 5,
-                                    conflict_kind_to_word(conflict->kind)));
-
-      if (conflict->property_name)
-        SVN_ERR(svn_sqlite__bind_text(insert_stmt, 6,
-                                      conflict->property_name));
-
-      SVN_ERR(svn_sqlite__bind_text(insert_stmt, 7,
-                              conflict_action_to_word(conflict->action)));
-      SVN_ERR(svn_sqlite__bind_text(insert_stmt, 8,
-                              conflict_reason_to_word(conflict->reason)));
-      SVN_ERR(svn_sqlite__bind_text(insert_stmt, 9,
-                              wc_operation_to_word(conflict->operation)));
-
-      if (conflict->src_left_version)
+      if (have_row)
         {
-          SVN_ERR(svn_sqlite__bind_int64(insert_stmt, 10, left_repos_id));
-          SVN_ERR(svn_sqlite__bind_text(insert_stmt, 11,
-                                   conflict->src_left_version->path_in_repos));
-          SVN_ERR(svn_sqlite__bind_int64(insert_stmt, 12,
-                                       conflict->src_left_version->peg_rev));
-          SVN_ERR(svn_sqlite__bind_text(insert_stmt, 13,
-                                        kind_to_word(db_kind_from_node_kind(
-                                    conflict->src_left_version->node_kind))));
+          /* There is an existing ACTUAL row, so just update it. */
+          SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                            STMT_UPDATE_ACTUAL_CONFLICT_DATA));
         }
-
-      if (conflict->src_right_version)
+      else
         {
-          SVN_ERR(svn_sqlite__bind_int64(insert_stmt, 14, right_repos_id));
-          SVN_ERR(svn_sqlite__bind_text(insert_stmt, 15,
-                                 conflict->src_right_version->path_in_repos));
-          SVN_ERR(svn_sqlite__bind_int64(insert_stmt, 16,
-                                       conflict->src_right_version->peg_rev));
-          SVN_ERR(svn_sqlite__bind_text(insert_stmt, 17,
-                                        kind_to_word(db_kind_from_node_kind(
-                                    conflict->src_right_version->node_kind))));
+          /* We need to insert an ACTUAL row with the tree conflict data. */
+          SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                            STMT_INSERT_ACTUAL_CONFLICT_DATA));
         }
 
-      SVN_ERR(svn_sqlite__insert(NULL, insert_stmt));
+      SVN_ERR(svn_sqlite__bindf(stmt, "iss", wc_id, conflict_relpath,
+                                conflict_data));
+      if (!have_row)
+        SVN_ERR(svn_sqlite__bind_text(stmt, 4, local_relpath));
+
+      SVN_ERR(svn_sqlite__step_done(stmt));
     }
 
   svn_pool_destroy(iterpool);
@@ -830,22 +705,20 @@ migrate_single_tree_conflict_data(svn_sq
 
 /* */
 static svn_error_t *
-migrate_tree_conflicts(svn_sqlite__db_t *sdb,
-                       apr_pool_t *scratch_pool)
+migrate_tree_conflict_data(svn_sqlite__db_t *sdb, apr_pool_t *scratch_pool)
 {
-  svn_sqlite__stmt_t *select_stmt;
-  svn_sqlite__stmt_t *erase_stmt;
+  svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
 
   /* Iterate over each node which has a set of tree conflicts, then insert
      all of them into the new schema.  */
 
-  SVN_ERR(svn_sqlite__get_statement(&select_stmt, sdb,
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
                                     STMT_SELECT_OLD_TREE_CONFLICT));
 
   /* Get all the existing tree conflict data. */
-  SVN_ERR(svn_sqlite__step(&have_row, select_stmt));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
   while (have_row)
     {
       apr_int64_t wc_id;
@@ -854,33 +727,28 @@ migrate_tree_conflicts(svn_sqlite__db_t 
 
       svn_pool_clear(iterpool);
 
-      wc_id = svn_sqlite__column_int64(select_stmt, 0);
-      local_relpath = svn_sqlite__column_text(select_stmt, 1, iterpool);
-      tree_conflict_data = svn_sqlite__column_text(select_stmt, 2,
-                                                   iterpool);
+      wc_id = svn_sqlite__column_int64(stmt, 0);
+      local_relpath = svn_sqlite__column_text(stmt, 1, iterpool);
+      tree_conflict_data = svn_sqlite__column_text(stmt, 2, iterpool);
 
-      SVN_ERR(migrate_single_tree_conflict_data(sdb,
-                                                tree_conflict_data,
+      SVN_ERR(migrate_single_tree_conflict_data(sdb, tree_conflict_data,
                                                 wc_id, local_relpath,
                                                 iterpool));
 
       /* We don't need to do anything but step over the previously
          prepared statement. */
-      SVN_ERR(svn_sqlite__step(&have_row, select_stmt));
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
     }
-  SVN_ERR(svn_sqlite__reset(select_stmt));
+  SVN_ERR(svn_sqlite__reset(stmt));
 
   /* Erase all the old tree conflict data.  */
-  SVN_ERR(svn_sqlite__get_statement(&erase_stmt, sdb,
-                                    STMT_ERASE_OLD_CONFLICTS));
-  SVN_ERR(svn_sqlite__step_done(erase_stmt));
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_ERASE_OLD_CONFLICTS));
+  SVN_ERR(svn_sqlite__step_done(stmt));
 
   svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
 }
 
-#endif /* ### no tree conflict migration yet */
-
 
 /* */
 static svn_error_t *
@@ -1204,23 +1072,14 @@ bump_to_20(void *baton, svn_sqlite__db_t
   return SVN_NO_ERROR;
 }
 
-
-#if 0 /* ### no tree conflict migration yet */
-
-/* */
 static svn_error_t *
-bump_to_XXX(void *baton, svn_sqlite__db_t *sdb, apr_pool_t *scratch_pool)
+bump_to_21(void *baton, svn_sqlite__db_t *sdb, apr_pool_t *scratch_pool)
 {
-  const char *wcroot_abspath = ((struct bump_baton *)baton)->wcroot_abspath;
-
-  SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_UPGRADE_TO_XXX));
-
-  SVN_ERR(migrate_tree_conflicts(sdb, scratch_pool));
-
+  SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_UPGRADE_TO_21));
+  SVN_ERR(migrate_tree_conflict_data(sdb, scratch_pool));
   return SVN_NO_ERROR;
 }
 
-#endif /* ### no tree conflict migration yet */
 
 struct upgrade_data_t {
   svn_sqlite__db_t *sdb;
@@ -1503,6 +1362,14 @@ svn_wc__upgrade_sdb(int *result_format,
         *result_format = 20;
         /* FALLTHROUGH  */
 
+#if SVN_WC__VERSION >= 21
+      case 20:
+        SVN_ERR(svn_sqlite__with_transaction(sdb, bump_to_21, &bb,
+                                             scratch_pool));
+        *result_format = 21;
+        /* FALLTHROUGH  */
+#endif
+
       /* ### future bumps go here.  */
 #if 0
       case XXX-1:

Modified: subversion/trunk/subversion/libsvn_wc/wc-metadata.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-metadata.sql?rev=1034155&r1=1034154&r2=1034155&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-metadata.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-metadata.sql Thu Nov 11 21:38:17 2010
@@ -626,6 +626,16 @@ DROP TABLE WORKING_NODE;
 
 PRAGMA user_version = 20;
 
+
+/* ------------------------------------------------------------------------- */
+
+/* Format 21 involves no schema changes, it moves the tree conflict victim
+   information to victime nodes, rather than parents. */
+
+-- STMT_UPGRADE_TO_21
+PRAGMA user_version = 21;
+
+
 /* ------------------------------------------------------------------------- */
 
 /* Format YYY introduces new handling for conflict information.  */

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1034155&r1=1034154&r2=1034155&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Thu Nov 11 21:38:17 2010
@@ -753,15 +753,6 @@ SELECT wc_id, local_relpath, tree_confli
 FROM actual_node
 WHERE tree_conflict_data IS NOT NULL;
 
--- STMT_INSERT_NEW_CONFLICT
-INSERT INTO conflict_victim (
-  wc_id, local_relpath, parent_relpath, node_kind, conflict_kind,
-  property_name, conflict_action, conflict_reason, operation,
-  left_repos_id, left_repos_relpath, left_peg_rev, left_kind,
-  right_repos_id, right_repos_relpath, right_peg_rev, right_kind)
-VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15,
-  ?16, ?17);
-
 -- STMT_ERASE_OLD_CONFLICTS
 UPDATE actual_node SET tree_conflict_data = NULL;
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1034155&r1=1034154&r2=1034155&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Nov 11 21:38:17 2010
@@ -55,7 +55,9 @@
 #define NOT_IMPLEMENTED() SVN__NOT_IMPLEMENTED()
 
 
-/* #define TREE_CONFLICTS_ON_CHILDREN */
+#if SVN_WC__VERSION >= 21
+  #define TREE_CONFLICTS_ON_CHILDREN
+#endif
 
 
 /*

Modified: subversion/trunk/subversion/tests/cmdline/upgrade_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/upgrade_tests.py?rev=1034155&r1=1034154&r2=1034155&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/upgrade_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/upgrade_tests.py Thu Nov 11 21:38:17 2010
@@ -672,6 +672,25 @@ def dirs_only_upgrade(sbox):
       })
   run_and_verify_status_no_server(sbox.wc_dir, expected_status)
 
+
+def upgrade_tree_conflict_data(sbox):
+  "upgrade tree conflict data (f20->f21)"
+
+  sbox.build(create_wc = False)
+  wc_dir = sbox.wc_dir
+  replace_sbox_with_tarfile(sbox, 'upgrade_tc.tar.bz2')
+
+  # Check and see if we can still read our tree conflicts
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
+  expected_status.tweak('A/D/G/pi', status='D ', treeconflict='C')
+  expected_status.tweak('A/D/G/tau', status='! ', treeconflict='C',
+                        wc_rev=None)
+  expected_status.tweak('A/D/G/rho', status='A ', copied='+',
+                        treeconflict='C', wc_rev='-')
+
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+
 ########################################################################
 # Run the tests
 
@@ -693,6 +712,7 @@ test_list = [ None,
               missing_dirs2,
               XFail(delete_and_keep_local),
               dirs_only_upgrade,
+              upgrade_tree_conflict_data,
              ]
 
 

Added: subversion/trunk/subversion/tests/cmdline/upgrade_tests_data/upgrade_tc.tar.bz2
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/upgrade_tests_data/upgrade_tc.tar.bz2?rev=1034155&view=auto
==============================================================================
Binary file - no diff available.

Propchange: subversion/trunk/subversion/tests/cmdline/upgrade_tests_data/upgrade_tc.tar.bz2
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream