Author: julianfoad
Date: Fri Jul 9 17:34:05 2010
New Revision: 962616
URL: http://svn.apache.org/viewvc?rev=962616&view=rev
Log:
Add experimental, incomplete code for migrating to a single DB (per WC).
Guard it in "#ifdef SINGLE_DB".
(I'm committing this in its current state of incompleteness because I'm
going away for a while and I expect it to be somewhat useful and not
harmful.)
* subversion/libsvn_wc/upgrade.c
(bump_baton): Add a new field to hold the real WC root directory. (Note:
there is no code yet to initialize it.)
(bump_to_19): New function to migrate one directory to to real WC root.
(svn_wc__upgrade_sdb): Call bump_to_19 if required.
* subversion/libsvn_wc/wc-queries.sql
(STMT_ATTACH_WCROOT_DB,
STMT_COPY_BASE_NODE_TABLE_TO_WCROOT_DB,
STMT_COPY_WORKING_NODE_TABLE_TO_WCROOT_DB,
STMT_COPY_ACTUAL_NODE_TABLE_TO_WCROOT_DB,
STMT_COPY_LOCK_TABLE_TO_WCROOT_DB,
STMT_COPY_PRISTINE_TABLE_TO_WCROOT_DB): New statements.
Modified:
subversion/trunk/subversion/libsvn_wc/upgrade.c
subversion/trunk/subversion/libsvn_wc/wc-queries.sql
Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=962616&r1=962615&r2=962616&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Fri Jul 9 17:34:05 2010
@@ -860,6 +860,9 @@ migrate_locks(const char *wcroot_abspath
struct bump_baton {
const char *wcroot_abspath;
+#ifdef SINGLE_DB
+ const char *single_db_wcroot_abspath;
+#endif
};
/* */
@@ -1134,6 +1137,74 @@ bump_to_17(void *baton, svn_sqlite__db_t
}
+#ifdef SINGLE_DB
+/* Migrate one directory to a Single DB (per WC): if this is a subdirectory,
+ * move all of its DB rows and pristine texts to the real WC-root.
+ *
+ * ### JAF: This is experimental code for others to use or ignore until I
+ * get back to it. It may need to be re-written in a completely
+ * different way. Especially, it probably wants to be moved from
+ * the auto-upgrade code path to the manual-upgrade code path.
+ * How to make the caller provide the BATON->wcroot_abspath and
+ */
+static svn_error_t *
+bump_to_19(void *baton, svn_sqlite__db_t *sdb, apr_pool_t *scratch_pool)
+{
+ struct bump_baton *bb = baton;
+ const char *this_wc_dir_abspath = bb->wcroot_abspath;
+ const char *single_db_wcroot_abspath = bb->single_db_wcroot_abspath;
+ const char *this_wc_dir_relpath
+ = svn_relpath_is_child(single_db_wcroot_abspath, this_wc_dir_abspath,
+ scratch_pool);
+ const char *parent_wc_dir_relpath
+ = svn_relpath_dirname(this_wc_dir_relpath, scratch_pool);
+ const char *single_db_sdb_abspath;
+ svn_sqlite__stmt_t *stmt;
+
+ /* If this is the single-DB WC root directory, there is nothing to do for
+ * this particular directory. */
+ if (strcmp(this_wc_dir_abspath, single_db_wcroot_abspath) == 0)
+ return SVN_NO_ERROR;
+
+ /* Get the path to the WC-root SDB as a native style path, UTF-8-encoded. */
+ single_db_sdb_abspath = svn_wc__adm_child(single_db_wcroot_abspath, "wc.db",
+ scratch_pool);
+ /* ### TODO: convert path to native style */
+
+ /* Attach the single-db so we can write into it. */
+ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_ATTACH_WCROOT_DB));
+ SVN_ERR(svn_sqlite__bindf(stmt, "s", single_db_sdb_abspath));
+ SVN_ERR(svn_sqlite__step_done(stmt));
+
+ /* ### TODO: the REPOSITORY table */
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+ STMT_COPY_BASE_NODE_TABLE_TO_WCROOT_DB));
+ SVN_ERR(svn_sqlite__bindf(stmt, "ss", this_wc_dir_relpath,
parent_wc_dir_relpath));
+ SVN_ERR(svn_sqlite__update(NULL, stmt));
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+
STMT_COPY_WORKING_NODE_TABLE_TO_WCROOT_DB));
+ SVN_ERR(svn_sqlite__bindf(stmt, "ss", this_wc_dir_relpath,
parent_wc_dir_relpath));
+ SVN_ERR(svn_sqlite__update(NULL, stmt));
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+ STMT_COPY_ACTUAL_NODE_TABLE_TO_WCROOT_DB));
+ SVN_ERR(svn_sqlite__bindf(stmt, "ss", this_wc_dir_relpath,
parent_wc_dir_relpath));
+ SVN_ERR(svn_sqlite__update(NULL, stmt));
+
+ SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_COPY_LOCK_TABLE_TO_WCROOT_DB));
+
+ SVN_ERR(svn_sqlite__exec_statements(sdb,
STMT_COPY_PRISTINE_TABLE_TO_WCROOT_DB));
+
+ /* ### TODO: move the pristine text files from this_wc_dir_abspath to
+ * single_db_wcroot_abspath. */
+
+ return SVN_NO_ERROR;
+}
+#endif /* SINGLE_DB */
+
+
#if 0 /* ### no tree conflict migration yet */
/* */
@@ -1402,6 +1473,16 @@ svn_wc__upgrade_sdb(int *result_format,
/* FALLTHROUGH */
#endif
+#if (SVN_WC__VERSION > 18)
+ case 18:
+ /* Merge all subdirectory DBs and pristines into the WC-root. */
+ SVN_ERR(svn_sqlite__with_transaction(sdb, bump_to_19, &bb,
+ scratch_pool));
+
+ *result_format = 19;
+ /* FALLTHROUGH */
+#endif
+
/* ### future bumps go here. */
#if 0
case 98:
Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=962616&r1=962615&r2=962616&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Fri Jul 9 17:34:05
2010
@@ -582,6 +582,86 @@ SELECT 0, null, wc_id FROM BASE_NODE WHE
UNION
SELECT 1, presence, wc_id FROM WORKING_NODE WHERE local_relpath = ?1;
+-- STMT_ATTACH_WCROOT_DB
+/* ?1 is the path to the WC-root DB file to attach. */
+ATTACH ?1 AS root;
+
+-- STMT_COPY_BASE_NODE_TABLE_TO_WCROOT_DB
+/* Copy BASE_NODE to WC-root DB: first the '' row, then the rest. */
+/* ?1 is the wc_relpath of the subdirectory that we're processing. */
+/* ?2 is the wc_relpath of the parent of the subdir we're processing. */
+INSERT INTO root.BASE_NODE (
+ wc_id, local_relpath, repos_id, repos_relpath, parent_relpath,
+ presence,
+ revnum, kind, checksum, translated_size, changed_rev, changed_date,
+ changed_author, depth, last_mod_time, properties )
+SELECT wc_id, ?1,
+ repos_id, repos_relpath, ?2 AS parent_relpath, presence,
+ revnum, kind, checksum, translated_size, changed_rev, changed_date,
+ changed_author, depth, last_mod_time, properties FROM BASE_NODE
+WHERE local_relpath = '';
+INSERT INTO root.BASE_NODE (
+ wc_id, local_relpath, repos_id, repos_relpath, parent_relpath,
+ presence,
+ revnum, kind, checksum, translated_size, changed_rev, changed_date,
+ changed_author, depth, last_mod_time, properties )
+SELECT wc_id, ?1 || '/' || local_relpath,
+ repos_id, repos_relpath, ?1 AS parent_relpath, presence,
+ revnum, kind, checksum, translated_size, changed_rev, changed_date,
+ changed_author, depth, last_mod_time, properties FROM BASE_NODE
+WHERE local_relpath != '';
+
+-- STMT_COPY_WORKING_NODE_TABLE_TO_WCROOT_DB
+INSERT INTO root.WORKING_NODE (
+ wc_id, local_relpath, parent_relpath, presence, kind, checksum,
+ translated_size, changed_rev, changed_date, changed_author, depth,
+ symlink_target, last_mod_time, properties, copyfrom_repos_id,
+ copyfrom_repos_path, copyfrom_revnum )
+SELECT wc_id, ?1, ?2 AS parent_relpath,
+ presence, kind, checksum,
+ translated_size, changed_rev, changed_date, changed_author, depth,
+ symlink_target, last_mod_time, properties, copyfrom_repos_id,
+ copyfrom_repos_path, copyfrom_revnum FROM WORKING_NODE
+WHERE local_relpath = '';
+INSERT INTO root.WORKING_NODE (
+ wc_id, local_relpath, parent_relpath, presence, kind, checksum,
+ translated_size, changed_rev, changed_date, changed_author, depth,
+ symlink_target, last_mod_time, properties, copyfrom_repos_id,
+ copyfrom_repos_path, copyfrom_revnum )
+SELECT wc_id, ?1 || '/' || local_relpath, ?1 AS parent_relpath,
+ presence, kind, checksum,
+ translated_size, changed_rev, changed_date, changed_author, depth,
+ symlink_target, last_mod_time, properties, copyfrom_repos_id,
+ copyfrom_repos_path, copyfrom_revnum FROM WORKING_NODE
+WHERE local_relpath != '';
+/* TODO - maybe: WHERE kind != 'subdir'; */
+
+-- STMT_COPY_ACTUAL_NODE_TABLE_TO_WCROOT_DB
+INSERT INTO root.ACTUAL_NODE (
+ wc_id, local_relpath, parent_relpath, properties,
+ conflict_old, conflict_new, conflict_working,
+ prop_reject, changelist, text_mod, tree_conflict_data )
+SELECT wc_id, ?1, ?2 AS parent_relpath, properties,
+ conflict_old, conflict_new, conflict_working,
+ prop_reject, changelist, text_mod, tree_conflict_data FROM ACTUAL_NODE
+WHERE local_relpath = '';
+INSERT INTO root.ACTUAL_NODE (
+ wc_id, local_relpath, parent_relpath, properties,
+ conflict_old, conflict_new, conflict_working,
+ prop_reject, changelist, text_mod, tree_conflict_data )
+SELECT wc_id, ?1 || '/' || local_relpath, ?1 AS parent_relpath, properties,
+ conflict_old, conflict_new, conflict_working,
+ prop_reject, changelist, text_mod, tree_conflict_data FROM ACTUAL_NODE
+WHERE local_relpath != '';
+
+-- STMT_COPY_LOCK_TABLE_TO_WCROOT_DB
+INSERT INTO root.LOCK
+SELECT * FROM LOCK;
+
+-- STMT_COPY_PRISTINE_TABLE_TO_WCROOT_DB
+INSERT INTO root.PRISTINE
+SELECT * FROM PRISTINE;
+
/* ------------------------------------------------------------------------- */