You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2012/08/16 12:18:03 UTC

svn commit: r1373783 [32/50] - in /subversion/branches/compressed-pristines: ./ build/ build/ac-macros/ build/generator/ build/generator/templates/ build/win32/ contrib/client-side/emacs/ contrib/client-side/svn-push/ contrib/client-side/svnmerge/ cont...

Modified: subversion/branches/compressed-pristines/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/branches/compressed-pristines/subversion/libsvn_wc/upgrade.c?rev=1373783&r1=1373782&r2=1373783&view=diff
==============================================================================
--- subversion/branches/compressed-pristines/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/branches/compressed-pristines/subversion/libsvn_wc/upgrade.c Thu Aug 16 10:17:48 2012
@@ -31,6 +31,7 @@
 
 #include "wc.h"
 #include "adm_files.h"
+#include "conflicts.h"
 #include "entries.h"
 #include "wc_db.h"
 #include "tree_conflicts.h"
@@ -792,7 +793,7 @@ migrate_tree_conflict_data(svn_sqlite__d
      all of them into the new schema.  */
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
-                                    STMT_SELECT_OLD_TREE_CONFLICT));
+                                    STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT));
 
   /* Get all the existing tree conflict data. */
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
@@ -819,7 +820,8 @@ migrate_tree_conflict_data(svn_sqlite__d
   SVN_ERR(svn_sqlite__reset(stmt));
 
   /* Erase all the old tree conflict data.  */
-  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_ERASE_OLD_CONFLICTS));
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                    STMT_UPGRADE_21_ERASE_OLD_CONFLICTS));
   SVN_ERR(svn_sqlite__step_done(stmt));
 
   svn_pool_destroy(iterpool);
@@ -1211,7 +1213,7 @@ bump_to_27(void *baton, svn_sqlite__db_t
   svn_boolean_t have_row;
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
-                                    STMT_HAS_ACTUAL_NODES_CONFLICTS));
+                                  STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   SVN_ERR(svn_sqlite__reset(stmt));
   if (have_row)
@@ -1363,6 +1365,202 @@ bump_to_29(void *baton, svn_sqlite__db_t
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__upgrade_conflict_skel_from_raw(svn_skel_t **conflicts,
+                                       svn_wc__db_t *db,
+                                       const char *wri_abspath,
+                                       const char *local_relpath,
+                                       const char *conflict_old,
+                                       const char *conflict_wrk,
+                                       const char *conflict_new,
+                                       const char *prej_file,
+                                       const char *tree_conflict_data,
+                                       apr_size_t tree_conflict_len,
+                                       apr_pool_t *result_pool,
+                                       apr_pool_t *scratch_pool)
+{
+  svn_skel_t *conflict_data = NULL;
+  
+  if (conflict_old || conflict_new || conflict_wrk)
+    {
+      const char *old_abspath = NULL;
+      const char *new_abspath = NULL;
+      const char *wrk_abspath = NULL;
+
+      conflict_data = svn_wc__conflict_skel_create(result_pool);
+
+      if (conflict_old)
+        SVN_ERR(svn_wc__db_from_relpath(&old_abspath, db, wri_abspath,
+                                        conflict_old,
+                                        scratch_pool, scratch_pool));
+
+      if (conflict_new)
+        SVN_ERR(svn_wc__db_from_relpath(&new_abspath, db, wri_abspath,
+                                        conflict_new,
+                                        scratch_pool, scratch_pool));
+
+      if (conflict_wrk)
+        SVN_ERR(svn_wc__db_from_relpath(&wrk_abspath, db, wri_abspath,
+                                        conflict_wrk,
+                                        scratch_pool, scratch_pool));
+
+      SVN_ERR(svn_wc__conflict_skel_add_text_conflict(conflict_data,
+                                                      db, wri_abspath,
+                                                      wrk_abspath,
+                                                      old_abspath,
+                                                      new_abspath,
+                                                      scratch_pool,
+                                                      scratch_pool));
+    }
+
+  if (prej_file)
+    {
+      const char *prej_abspath;
+
+      if (!conflict_data)
+        conflict_data = svn_wc__conflict_skel_create(result_pool);
+
+      SVN_ERR(svn_wc__db_from_relpath(&prej_abspath, db, wri_abspath,
+                                      prej_file,
+                                      scratch_pool, scratch_pool));
+
+      SVN_ERR(svn_wc__conflict_skel_add_prop_conflict(conflict_data,
+                                                      db, wri_abspath,
+                                                      prej_abspath,
+                                                      NULL, NULL, NULL,
+                                                apr_hash_make(scratch_pool),
+                                                      scratch_pool,
+                                                      scratch_pool));
+    }
+
+  if (tree_conflict_data)
+    {
+      svn_skel_t *tc_skel;
+      const svn_wc_conflict_description2_t *tc;
+      const char *local_abspath;
+
+      if (!conflict_data)
+        conflict_data = svn_wc__conflict_skel_create(scratch_pool);
+
+      tc_skel = svn_skel__parse(tree_conflict_data, tree_conflict_len,
+                                scratch_pool);
+
+      SVN_ERR(svn_wc__db_from_relpath(&local_abspath, db, wri_abspath,
+                                      local_relpath,
+                                      scratch_pool, scratch_pool));
+
+      SVN_ERR(svn_wc__deserialize_conflict(&tc, tc_skel,
+                                           svn_dirent_dirname(local_abspath,
+                                                              scratch_pool),
+                                           scratch_pool, scratch_pool));
+
+      SVN_ERR(svn_wc__conflict_skel_add_tree_conflict(conflict_data,
+                                                      db, wri_abspath,
+                                                      tc->reason,
+                                                      tc->action,
+                                                      scratch_pool,
+                                                      scratch_pool));
+
+      switch (tc->operation)
+        {
+          case svn_wc_operation_update:
+          default:
+            SVN_ERR(svn_wc__conflict_skel_set_op_update(conflict_data,
+                                                       tc->src_left_version,
+                                                       scratch_pool,
+                                                       scratch_pool));
+            break;
+          case svn_wc_operation_switch:
+            SVN_ERR(svn_wc__conflict_skel_set_op_switch(conflict_data,
+                                                        tc->src_left_version,
+                                                        scratch_pool,
+                                                        scratch_pool));
+            break;
+          case svn_wc_operation_merge:
+            SVN_ERR(svn_wc__conflict_skel_set_op_merge(conflict_data,
+                                                       tc->src_left_version,
+                                                       tc->src_right_version,
+                                                       scratch_pool,
+                                                       scratch_pool));
+            break;
+        }
+    }
+  else if (conflict_data)
+    {
+      SVN_ERR(svn_wc__conflict_skel_set_op_update(conflict_data, NULL,
+                                                  scratch_pool,
+                                                  scratch_pool));
+    }
+
+  *conflicts = conflict_data;
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+bump_to_30(void *baton, svn_sqlite__db_t *sdb, apr_pool_t *scratch_pool)
+{
+  struct bump_baton *bb = baton;
+  svn_boolean_t have_row;
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+  svn_sqlite__stmt_t *stmt;
+  svn_sqlite__stmt_t *stmt_store;
+  svn_wc__db_t *db; /* Read only temp db */
+  const char *wri_abspath = bb->wcroot_abspath;
+
+  SVN_ERR(svn_wc__db_open(&db, NULL, FALSE, FALSE,
+                          scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt_store, sdb,
+                                    STMT_UPGRADE_30_SET_CONFLICT));
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                    STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+  while (have_row)
+    {
+      svn_stringbuf_t *skel_data;
+      svn_skel_t *conflict_data;
+      apr_int64_t wc_id = svn_sqlite__column_int64(stmt, 0);
+      const char *local_relpath = svn_sqlite__column_text(stmt, 1, NULL);
+      const char *conflict_old = svn_sqlite__column_text(stmt, 2, NULL);
+      const char *conflict_wrk = svn_sqlite__column_text(stmt, 3, NULL);
+      const char *conflict_new = svn_sqlite__column_text(stmt, 4, NULL);
+      const char *prop_reject = svn_sqlite__column_text(stmt, 5, NULL);
+      apr_size_t tree_conflict_size;
+      const char *tree_conflict_data = svn_sqlite__column_blob(stmt, 6,
+                                               &tree_conflict_size, NULL);
+
+      svn_pool_clear(iterpool);
+
+      SVN_ERR(svn_wc__upgrade_conflict_skel_from_raw(&conflict_data,
+                                                     db, wri_abspath,
+                                                     local_relpath,
+                                                     conflict_old,
+                                                     conflict_wrk,
+                                                     conflict_new,
+                                                     prop_reject,
+                                                     tree_conflict_data,
+                                                     tree_conflict_size,
+                                                     iterpool, iterpool));
+
+      SVN_ERR_ASSERT(conflict_data != NULL);
+
+      skel_data = svn_skel__unparse(conflict_data, iterpool);
+
+      SVN_ERR(svn_sqlite__bindf(stmt_store, "isb", wc_id, local_relpath,
+                                skel_data->data, skel_data->len));
+      SVN_ERR(svn_sqlite__step_done(stmt_store));
+
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+    }
+  SVN_ERR(svn_sqlite__reset(stmt));
+
+  SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_UPGRADE_TO_30));
+  SVN_ERR(svn_wc__db_close(db));
+  return SVN_NO_ERROR;
+}
+
 
 struct upgrade_data_t {
   svn_sqlite__db_t *sdb;
@@ -1544,7 +1742,9 @@ svn_wc__upgrade_sdb(int *result_format,
                     int start_format,
                     apr_pool_t *scratch_pool)
 {
-  struct bump_baton bb = { wcroot_abspath };
+  struct bump_baton bb;
+
+  bb.wcroot_abspath = wcroot_abspath;
 
   if (start_format < SVN_WC__WC_NG_VERSION /* 12 */)
     return svn_error_createf(SVN_ERR_WC_UPGRADE_REQUIRED, NULL,
@@ -1634,6 +1834,13 @@ svn_wc__upgrade_sdb(int *result_format,
         *result_format = 29;
         /* FALLTHROUGH  */
 
+#if SVN_WC__VERSION >= 30
+      case 29:
+        SVN_ERR(svn_sqlite__with_transaction(sdb, bump_to_30, &bb,
+                                             scratch_pool));
+        *result_format = 30;
+        /* FALLTHROUGH  */
+#endif
       /* ### future bumps go here.  */
 #if 0
       case XXX-1:

Modified: subversion/branches/compressed-pristines/subversion/libsvn_wc/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/compressed-pristines/subversion/libsvn_wc/util.c?rev=1373783&r1=1373782&r2=1373783&view=diff
==============================================================================
--- subversion/branches/compressed-pristines/subversion/libsvn_wc/util.c (original)
+++ subversion/branches/compressed-pristines/subversion/libsvn_wc/util.c Thu Aug 16 10:17:48 2012
@@ -285,24 +285,27 @@ svn_wc__conflict_description2_dup(const 
 }
 
 svn_wc_conflict_version_t *
-svn_wc_conflict_version_create(const char *repos_url,
-                               const char *path_in_repos,
-                               svn_revnum_t peg_rev,
-                               svn_node_kind_t node_kind,
-                               apr_pool_t *pool)
+svn_wc_conflict_version_create2(const char *repos_url,
+                                const char *repos_uuid,
+                                const char *repos_relpath,
+                                svn_revnum_t revision,
+                                svn_node_kind_t kind,
+                                apr_pool_t *result_pool)
 {
   svn_wc_conflict_version_t *version;
 
-  version = apr_pcalloc(pool, sizeof(*version));
+  version = apr_pcalloc(result_pool, sizeof(*version));
 
-  SVN_ERR_ASSERT_NO_RETURN(svn_uri_is_canonical(repos_url, pool) &&
-                           svn_relpath_is_canonical(path_in_repos) &&
-                           SVN_IS_VALID_REVNUM(peg_rev));
+    SVN_ERR_ASSERT_NO_RETURN(svn_uri_is_canonical(repos_url, result_pool)
+                             && svn_relpath_is_canonical(repos_relpath)
+                             && SVN_IS_VALID_REVNUM(revision)
+                             /* ### repos_uuid can be NULL :( */);
 
   version->repos_url = repos_url;
-  version->peg_rev = peg_rev;
-  version->path_in_repos = path_in_repos;
-  version->node_kind = node_kind;
+  version->peg_rev = revision;
+  version->path_in_repos = repos_relpath;
+  version->node_kind = kind;
+  version->repos_uuid = repos_uuid;
 
   return version;
 }
@@ -310,7 +313,7 @@ svn_wc_conflict_version_create(const cha
 
 svn_wc_conflict_version_t *
 svn_wc_conflict_version_dup(const svn_wc_conflict_version_t *version,
-                            apr_pool_t *pool)
+                            apr_pool_t *result_pool)
 {
 
   svn_wc_conflict_version_t *new_version;
@@ -318,16 +321,20 @@ svn_wc_conflict_version_dup(const svn_wc
   if (version == NULL)
     return NULL;
 
-  new_version = apr_pcalloc(pool, sizeof(*new_version));
+  new_version = apr_pcalloc(result_pool, sizeof(*new_version));
 
   /* Shallow copy all members. */
   *new_version = *version;
 
   if (version->repos_url)
-    new_version->repos_url = apr_pstrdup(pool, version->repos_url);
+    new_version->repos_url = apr_pstrdup(result_pool, version->repos_url);
 
   if (version->path_in_repos)
-    new_version->path_in_repos = apr_pstrdup(pool, version->path_in_repos);
+    new_version->path_in_repos = apr_pstrdup(result_pool,
+                                             version->path_in_repos);
+
+  if (version->repos_uuid)
+    new_version->repos_uuid = apr_pstrdup(result_pool, version->repos_uuid);
 
   return new_version;
 }
@@ -441,9 +448,8 @@ svn_wc__status2_from_3(svn_wc_status2_t 
   if (old_status->conflicted)
     {
       const svn_wc_conflict_description2_t *tree_conflict;
-      SVN_ERR(svn_wc__db_op_read_tree_conflict(&tree_conflict, wc_ctx->db,
-                                               local_abspath, scratch_pool,
-                                               scratch_pool));
+      SVN_ERR(svn_wc__get_tree_conflict(&tree_conflict, wc_ctx, local_abspath,
+                                        scratch_pool, scratch_pool));
       (*status)->tree_conflict = svn_wc__cd2_to_cd(tree_conflict, result_pool);
     }
 
@@ -546,7 +552,9 @@ svn_wc__fetch_kind_func(svn_kind_t *kind
   const char *local_abspath = svn_dirent_join(sfb->base_abspath, path,
                                               scratch_pool);
 
-  SVN_ERR(svn_wc__db_read_kind(kind, sfb->db, local_abspath, FALSE,
+  SVN_ERR(svn_wc__db_read_kind(kind, sfb->db, local_abspath,
+                               FALSE /* allow_missing */,
+                               FALSE /* show_hidden */,
                                scratch_pool));
 
   return SVN_NO_ERROR;

Modified: subversion/branches/compressed-pristines/subversion/libsvn_wc/wc-metadata.sql
URL: http://svn.apache.org/viewvc/subversion/branches/compressed-pristines/subversion/libsvn_wc/wc-metadata.sql?rev=1373783&r1=1373782&r2=1373783&view=diff
==============================================================================
--- subversion/branches/compressed-pristines/subversion/libsvn_wc/wc-metadata.sql (original)
+++ subversion/branches/compressed-pristines/subversion/libsvn_wc/wc-metadata.sql Thu Aug 16 10:17:48 2012
@@ -107,7 +107,8 @@ CREATE TABLE PRISTINE (
   md5_checksum  TEXT NOT NULL
   );
 
-
+CREATE INDEX I_PRISTINE_MD5 ON PRISTINE (md5_checksum);
+  
 /* ------------------------------------------------------------------------- */
 
 /* The ACTUAL_NODE table describes text changes and property changes
@@ -169,7 +170,10 @@ CREATE TABLE ACTUAL_NODE (
   /* stsp: This is meant for text conflicts, right? What about property
            conflicts? Why do we need these in a column to refer to the
            pristine store? Can't we just parse the checksums from
-           conflict_data as well? */
+           conflict_data as well? 
+     rhuijben: Because that won't allow triggers to handle refcounts.
+               We would have to scan all conflict skels before cleaning up the
+               a single file from the pristine stor */
   older_checksum  TEXT REFERENCES PRISTINE (checksum),
   left_checksum  TEXT REFERENCES PRISTINE (checksum),
   right_checksum  TEXT REFERENCES PRISTINE (checksum),
@@ -462,24 +466,22 @@ CREATE TABLE NODES (
      node does not have any dav-cache. */
   dav_cache  BLOB,
 
-  /* The serialized file external information. */
-  /* ### hack.  hack.  hack.
-     ### This information is already stored in properties, but because the
-     ### current working copy implementation is such a pain, we can't
-     ### readily retrieve it, hence this temporary cache column.
-     ### When it is removed, be sure to remove the extra column from
-     ### the db-tests.
-
-     ### Note: This is only here as a hack, and should *NOT* be added
-     ### to any wc_db APIs.  */
-  file_external  TEXT,
-
+  /* Is there a file external in this location. NULL if there
+     is no file external, otherwise '1'  */
+  /* ### Originally we had a wc-1.0 like skel in this place, so we
+     ### check for NULL.
+     ### In Subversion 1.7 we defined this column as TEXT, but Sqlite
+     ### only uses this information for deciding how to optimize
+     ### anyway. */
+  file_external  INTEGER,
 
   PRIMARY KEY (wc_id, local_relpath, op_depth)
 
   );
 
 CREATE INDEX I_NODES_PARENT ON NODES (wc_id, parent_relpath, op_depth);
+/* I_NODES_MOVED is introduced in format 30 */
+CREATE UNIQUE INDEX I_NODES_MOVED ON NODES (wc_id, moved_to, op_depth);
 
 /* Many queries have to filter the nodes table to pick only that version
    of each node with the highest (most "current") op_depth.  This view
@@ -497,7 +499,7 @@ CREATE VIEW NODES_CURRENT AS
                         AND n2.local_relpath = n.local_relpath);
 
 /* Many queries have to filter the nodes table to pick only that version
-   of each node with the base (least "current") op_depth.  This view
+   of each node with the BASE ("as checked out") op_depth.  This view
    does the heavy lifting for such queries. */
 CREATE VIEW NODES_BASE AS
   SELECT * FROM nodes
@@ -628,6 +630,15 @@ PRAGMA user_version = 20;
 -- STMT_UPGRADE_TO_21
 PRAGMA user_version = 21;
 
+/* For format 21 bump code */
+-- STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT
+SELECT wc_id, local_relpath, tree_conflict_data
+FROM actual_node
+WHERE tree_conflict_data IS NOT NULL
+
+/* For format 21 bump code */
+-- STMT_UPGRADE_21_ERASE_OLD_CONFLICTS
+UPDATE actual_node SET tree_conflict_data = NULL
 
 /* ------------------------------------------------------------------------- */
 
@@ -698,6 +709,15 @@ PRAGMA user_version = 26;
 -- STMT_UPGRADE_TO_27
 PRAGMA user_version = 27;
 
+/* For format 27 bump code */
+-- STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS
+SELECT 1 FROM actual_node
+WHERE NOT ((prop_reject IS NULL) AND (conflict_old IS NULL)
+           AND (conflict_new IS NULL) AND (conflict_working IS NULL)
+           AND (tree_conflict_data IS NULL))
+LIMIT 1
+
+
 /* ------------------------------------------------------------------------- */
 
 /* Format 28 involves no schema changes, it only converts MD5 pristine 
@@ -753,6 +773,39 @@ PRAGMA user_version = 29;
 
 /* ------------------------------------------------------------------------- */
 
+/* Format 30 currently just contains some nice to haves that should be included
+   with the next format bump  */
+-- STMT_UPGRADE_TO_30
+CREATE UNIQUE INDEX IF NOT EXISTS I_NODES_MOVED
+ON NODES (wc_id, moved_to, op_depth);
+
+CREATE INDEX IF NOT EXISTS I_PRISTINE_MD5 ON PRISTINE (md5_checksum);
+
+/* Just to be sure clear out file external skels from pre 1.7.0 development
+   working copies that were never updated by 1.7.0+ style clients */
+UPDATE nodes SET file_external=1 WHERE file_external IS NOT NULL;
+
+PRAGMA user_version = 30;
+
+-- STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE
+SELECT wc_id, local_relpath,
+  conflict_old, conflict_working, conflict_new, prop_reject, tree_conflict_data
+FROM actual_node
+WHERE conflict_old IS NOT NULL
+   OR conflict_working IS NOT NULL
+   OR conflict_new IS NOT NULL
+   OR prop_reject IS NOT NULL
+   OR tree_conflict_data IS NOT NULL
+ORDER by wc_id, local_relpath
+
+-- STMT_UPGRADE_30_SET_CONFLICT
+UPDATE actual_node SET conflict_data = ?3, conflict_old = NULL,
+  conflict_working = NULL, conflict_new = NULL, prop_reject = NULL,
+  tree_conflict_data = NULL
+WHERE wc_id = ?1 and local_relpath = ?2
+
+/* ------------------------------------------------------------------------- */
+
 /* Format YYY introduces new handling for conflict information.  */
 -- format: YYY
 
@@ -765,9 +818,9 @@ PRAGMA user_version = 29;
    number will be, however, so we're just marking it as 99 for now.  */
 -- format: 99
 
-/* TODO: Rename the "absent" presence value to "server-excluded" before
-   the 1.7 release. wc_db.c and this file have references to "absent" which
-   still need to be changed to "server-excluded". */
+/* TODO: Rename the "absent" presence value to "server-excluded". wc_db.c
+   and this file have references to "absent" which still need to be changed
+   to "server-excluded". */
 /* TODO: Un-confuse *_revision column names in the EXTERNALS table to
    "-r<operative> foo@<peg>", as suggested by the patch attached to
    http://svn.haxx.se/dev/archive-2011-09/0478.shtml */

Modified: subversion/branches/compressed-pristines/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/branches/compressed-pristines/subversion/libsvn_wc/wc-queries.sql?rev=1373783&r1=1373782&r2=1373783&view=diff
==============================================================================
--- subversion/branches/compressed-pristines/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/branches/compressed-pristines/subversion/libsvn_wc/wc-queries.sql Thu Aug 16 10:17:48 2012
@@ -51,14 +51,14 @@ ORDER BY op_depth DESC
 -- STMT_SELECT_BASE_NODE
 SELECT repos_id, repos_path, presence, kind, revision, checksum,
   translated_size, changed_revision, changed_date, changed_author, depth,
-  symlink_target, last_mod_time, properties, file_external IS NOT NULL
+  symlink_target, last_mod_time, properties, file_external
 FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
 
 -- STMT_SELECT_BASE_NODE_WITH_LOCK
 SELECT nodes.repos_id, nodes.repos_path, presence, kind, revision,
   checksum, translated_size, changed_revision, changed_date, changed_author,
-  depth, symlink_target, last_mod_time, properties, file_external IS NOT NULL,
+  depth, symlink_target, last_mod_time, properties, file_external,
   /* All the columns until now must match those returned by
      STMT_SELECT_BASE_NODE. The implementation of svn_wc__db_base_get_info()
      assumes that these columns are followed by the lock information) */
@@ -70,7 +70,7 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 
 -- STMT_SELECT_BASE_CHILDREN_INFO
 SELECT local_relpath, nodes.repos_id, nodes.repos_path, presence, kind,
-  revision, depth, file_external IS NOT NULL,
+  revision, depth, file_external,
   lock_token, lock_owner, lock_comment, lock_date
 FROM nodes
 LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id
@@ -102,21 +102,11 @@ ORDER BY op_depth
 LIMIT 1
 
 -- STMT_SELECT_ACTUAL_NODE
-SELECT prop_reject, changelist, conflict_old, conflict_new,
-conflict_working, tree_conflict_data, properties
+SELECT changelist, properties, conflict_data,
+conflict_old, conflict_new, conflict_working, prop_reject, tree_conflict_data
 FROM actual_node
 WHERE wc_id = ?1 AND local_relpath = ?2
 
--- STMT_SELECT_ACTUAL_TREE_CONFLICT
-SELECT tree_conflict_data
-FROM actual_node
-WHERE wc_id = ?1 AND local_relpath = ?2 AND tree_conflict_data IS NOT NULL
-
--- STMT_SELECT_ACTUAL_CHANGELIST
-SELECT changelist
-FROM actual_node
-WHERE wc_id = ?1 AND local_relpath = ?2 AND changelist IS NOT NULL
-
 -- STMT_SELECT_NODE_CHILDREN_INFO
 /* Getting rows in an advantageous order using
      ORDER BY local_relpath, op_depth DESC
@@ -125,11 +115,10 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 SELECT op_depth, nodes.repos_id, nodes.repos_path, presence, kind, revision,
   checksum, translated_size, changed_revision, changed_date, changed_author,
   depth, symlink_target, last_mod_time, properties, lock_token, lock_owner,
-  lock_comment, lock_date, local_relpath, moved_here, moved_to, 
-  file_external IS NOT NULL
+  lock_comment, lock_date, local_relpath, moved_here, moved_to, file_external
 FROM nodes
 LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id
-  AND nodes.repos_path = lock.repos_relpath
+  AND nodes.repos_path = lock.repos_relpath AND op_depth = 0
 WHERE wc_id = ?1 AND parent_relpath = ?2
 
 -- STMT_SELECT_NODE_CHILDREN_WALKER_INFO
@@ -138,9 +127,8 @@ FROM nodes_current
 WHERE wc_id = ?1 AND parent_relpath = ?2
 
 -- STMT_SELECT_ACTUAL_CHILDREN_INFO
-SELECT prop_reject, changelist, conflict_old, conflict_new,
-conflict_working, tree_conflict_data, properties, local_relpath,
-conflict_data
+SELECT local_relpath, changelist, properties, conflict_data,
+conflict_old, conflict_new, conflict_working, prop_reject, tree_conflict_data
 FROM actual_node
 WHERE wc_id = ?1 AND parent_relpath = ?2
 
@@ -165,6 +153,73 @@ INSERT OR REPLACE INTO nodes (
 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14,
         ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22)
 
+-- STMT_SELECT_BASE_PRESENT
+SELECT local_relpath, kind FROM nodes n
+WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND op_depth = 0
+  AND presence in ('normal', 'incomplete')
+  AND NOT EXISTS(SELECT 1 FROM NODES w
+                 WHERE w.wc_id = ?1 AND w.local_relpath = n.local_relpath
+                   AND op_depth > 0)
+ORDER BY local_relpath DESC
+
+-- STMT_SELECT_WORKING_PRESENT
+SELECT local_relpath, kind, checksum, translated_size, last_mod_time
+FROM nodes n
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND presence in ('normal', 'incomplete')
+  AND op_depth = (SELECT MAX(op_depth)
+                  FROM NODES w
+                  WHERE w.wc_id = ?1
+                    AND w.local_relpath = n.local_relpath)
+ORDER BY local_relpath DESC
+
+-- STMT_DELETE_NODE_RECURSIVE
+DELETE FROM NODES
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+
+-- STMT_DELETE_NODE
+DELETE
+FROM NODES
+WHERE wc_id = ?1 AND local_relpath = ?2
+
+-- STMT_DELETE_ACTUAL_FOR_BASE_RECURSIVE
+/* The ACTUAL_NODE applies to BASE, unless there is in at least one op_depth
+   a WORKING node that could have a conflict */
+DELETE FROM actual_node
+WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND EXISTS(SELECT 1 FROM NODES b
+             WHERE b.wc_id = ?1
+               AND b.local_relpath = actual_node.local_relpath
+               AND op_depth = 0)
+  AND NOT EXISTS(SELECT 1 FROM NODES w
+                 WHERE w.wc_id = ?1
+                   AND w.local_relpath = actual_node.local_relpath
+                   AND op_depth > 0
+                   AND presence in ('normal', 'incomplete', 'not-present'))
+
+-- STMT_DELETE_WORKING_BASE_DELETE
+DELETE FROM nodes
+WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND presence = 'base-deleted'
+  AND op_depth > 0
+  AND op_depth = (SELECT MIN(op_depth) FROM nodes n
+                    WHERE n.wc_id = ?1
+                      AND n.local_relpath = nodes.local_relpath
+                      AND op_depth > 0)
+
+-- STMT_DELETE_WORKING_RECURSIVE
+DELETE FROM nodes
+WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND op_depth > 0
+
+-- STMT_DELETE_BASE_RECURSIVE
+DELETE FROM nodes
+WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND op_depth = 0
+
 -- STMT_SELECT_OP_DEPTH_CHILDREN
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth = ?3
@@ -174,23 +229,23 @@ WHERE wc_id = ?1 AND parent_relpath = ?2
 SELECT 1 FROM nodes
 WHERE wc_id = ?1 AND parent_relpath = ?2
   AND (op_depth > ?3 OR (op_depth = ?3 AND presence != 'base-deleted'))
-UNION
+UNION ALL
 SELECT 1 FROM ACTUAL_NODE
 WHERE wc_id = ?1 AND parent_relpath = ?2
 
+/* Delete the nodes shadowed by local_relpath. Not valid for the wc-root */
 -- STMT_DELETE_SHADOWED_RECURSIVE
 DELETE FROM nodes
 WHERE wc_id = ?1
-  AND (local_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND (op_depth < ?3
        OR (op_depth = ?3 AND presence = 'base-deleted'))
 
+/* Get not-present descendants of a copied node. Not valid for the wc-root */
 -- STMT_SELECT_NOT_PRESENT_DESCENDANTS
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1 AND op_depth = ?3
-  AND (parent_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(parent_relpath, ?2))
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND presence == 'not-present'
 
 -- STMT_COMMIT_DESCENDANT_TO_BASE
@@ -259,15 +314,14 @@ INSERT OR REPLACE INTO lock
  lock_date)
 VALUES (?1, ?2, ?3, ?4, ?5, ?6)
 
+/* Not valid for the working copy root */
 -- STMT_SELECT_BASE_NODE_LOCK_TOKENS_RECURSIVE
 SELECT nodes.repos_id, nodes.repos_path, lock_token
 FROM nodes
 LEFT JOIN lock ON nodes.repos_id = lock.repos_id
   AND nodes.repos_path = lock.repos_relpath
 WHERE wc_id = ?1 AND op_depth = 0
-  AND (?2 = ''
-       OR local_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
 
 -- STMT_INSERT_WCROOT
 INSERT INTO wcroot (local_abspath)
@@ -281,23 +335,47 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 SELECT dav_cache FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
 
+-- STMT_SELECT_DELETION_INFO
+SELECT (SELECT b.presence FROM nodes AS b
+         WHERE b.wc_id = ?1 AND b.local_relpath = ?2 AND b.op_depth = 0),
+       work.presence, work.op_depth
+FROM nodes_current AS work
+WHERE work.wc_id = ?1 AND work.local_relpath = ?2 AND work.op_depth > 0
+LIMIT 1
+
+-- STMT_SELECT_DELETION_INFO_SCAN
 /* ### FIXME.  modes_move.moved_to IS NOT NULL works when there is
  only one move but we need something else when there are several. */
--- STMT_SELECT_DELETION_INFO
-SELECT nodes_base.presence, nodes_work.presence, nodes_move.moved_to,
-       nodes_work.op_depth
-FROM nodes AS nodes_work
-LEFT OUTER JOIN nodes nodes_move ON nodes_move.wc_id = nodes_work.wc_id
-  AND nodes_move.local_relpath = nodes_work.local_relpath
-  AND nodes_move.moved_to IS NOT NULL
-LEFT OUTER JOIN nodes nodes_base ON nodes_base.wc_id = nodes_work.wc_id
- AND nodes_base.local_relpath = nodes_work.local_relpath
- AND nodes_base.op_depth = 0
-WHERE nodes_work.wc_id = ?1 AND nodes_work.local_relpath = ?2
-  AND nodes_work.op_depth = (SELECT MAX(op_depth) FROM nodes
-                             WHERE wc_id = ?1 AND local_relpath = ?2
-                                              AND op_depth > 0)
+SELECT (SELECT b.presence FROM nodes AS b
+         WHERE b.wc_id = ?1 AND b.local_relpath = ?2 AND b.op_depth = 0),
+       work.presence, work.op_depth, moved.moved_to
+FROM nodes_current AS work
+LEFT OUTER JOIN nodes AS moved 
+  ON moved.wc_id = work.wc_id
+ AND moved.local_relpath = work.local_relpath
+ AND moved.moved_to IS NOT NULL
+WHERE work.wc_id = ?1 AND work.local_relpath = ?2 AND work.op_depth > 0
+LIMIT 1
 
+-- STMT_SELECT_OP_DEPTH_MOVED_TO
+SELECT op_depth, moved_to, repos_path, revision
+FROM nodes
+WHERE wc_id = ?1 AND local_relpath = ?2
+ AND op_depth <= (SELECT MIN(op_depth) FROM nodes
+                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3)
+ORDER BY op_depth DESC
+
+-- STMT_SELECT_MOVED_TO
+SELECT moved_to
+FROM nodes
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
+
+-- STMT_SELECT_MOVED_HERE
+SELECT moved_here, presence, repos_path, revision
+FROM nodes
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth >= ?3
+ORDER BY op_depth
+                  
 -- STMT_DELETE_LOCK
 DELETE FROM lock
 WHERE repos_id = ?1 AND repos_relpath = ?2
@@ -305,17 +383,20 @@ WHERE repos_id = ?1 AND repos_relpath = 
 -- STMT_CLEAR_BASE_NODE_RECURSIVE_DAV_CACHE
 UPDATE nodes SET dav_cache = NULL
 WHERE dav_cache IS NOT NULL AND wc_id = ?1 AND op_depth = 0
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
 
 -- STMT_RECURSIVE_UPDATE_NODE_REPO
 UPDATE nodes SET repos_id = ?4, dav_cache = NULL
-WHERE wc_id = ?1
-  AND repos_id = ?3
-  AND (?2 = ''
-       OR local_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+/* ### The Sqlite optimizer needs help here ###
+ * WHERE wc_id = ?1
+ *   AND repos_id = ?3
+ *   AND (local_relpath = ?2
+ *        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))*/
+WHERE (wc_id = ?1 AND local_relpath = ?2 AND repos_id = ?3)
+   OR (wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+       AND repos_id = ?3)
+ 
 
 -- STMT_UPDATE_LOCK_REPOS_ID
 UPDATE lock SET repos_id = ?2
@@ -327,39 +408,31 @@ WHERE wc_id = ?1 AND local_relpath = ?2
   AND op_depth = (SELECT MAX(op_depth) FROM nodes
                   WHERE wc_id = ?1 AND local_relpath = ?2)
 
--- STMT_UPDATE_ACTUAL_TREE_CONFLICTS
-UPDATE actual_node SET tree_conflict_data = ?3
-WHERE wc_id = ?1 AND local_relpath = ?2
-
--- STMT_INSERT_ACTUAL_TREE_CONFLICTS
-INSERT INTO actual_node (
-  wc_id, local_relpath, tree_conflict_data, parent_relpath)
-VALUES (?1, ?2, ?3, ?4)
-
--- STMT_UPDATE_ACTUAL_TEXT_CONFLICTS
-UPDATE actual_node SET conflict_old = ?3, conflict_new = ?4,
-  conflict_working = ?5
-WHERE wc_id = ?1 AND local_relpath = ?2
+-- STMT_UPDATE_NODE_FILEINFO_OPDEPTH
+UPDATE nodes SET translated_size = ?3, last_mod_time = ?4
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?5
 
--- STMT_INSERT_ACTUAL_TEXT_CONFLICTS
+-- STMT_INSERT_ACTUAL_CONFLICT
 INSERT INTO actual_node (
-  wc_id, local_relpath, conflict_old, conflict_new, conflict_working,
-  parent_relpath)
-VALUES (?1, ?2, ?3, ?4, ?5, ?6)
-
--- STMT_UPDATE_ACTUAL_PROPERTY_CONFLICTS
-UPDATE actual_node SET prop_reject = ?3
+  wc_id, local_relpath, conflict_data,
+  conflict_old, conflict_new, conflict_working, prop_reject,
+  tree_conflict_data, parent_relpath)
+VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)
+
+-- STMT_UPDATE_ACTUAL_CONFLICT
+UPDATE actual_node SET conflict_data = ?3,
+  conflict_old = ?4, conflict_new = ?5, conflict_working = ?6,
+  prop_reject = ?7, tree_conflict_data = ?8
 WHERE wc_id = ?1 AND local_relpath = ?2
 
--- STMT_INSERT_ACTUAL_PROPERTY_CONFLICTS
-INSERT INTO actual_node (
-  wc_id, local_relpath, prop_reject, parent_relpath)
-VALUES (?1, ?2, ?3, ?4)
-
 -- STMT_UPDATE_ACTUAL_CHANGELISTS
-UPDATE actual_node SET changelist = ?2
-WHERE wc_id = ?1 AND local_relpath IN
-(SELECT local_relpath FROM targets_list WHERE kind = 'file' AND wc_id = ?1)
+UPDATE actual_node SET changelist = ?3
+WHERE wc_id = ?1
+  AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND local_relpath = (SELECT local_relpath FROM targets_list AS t
+                       WHERE wc_id = ?1
+                         AND t.local_relpath = actual_node.local_relpath
+                         AND kind = 'file')
 
 -- STMT_UPDATE_ACTUAL_CLEAR_CHANGELIST
 UPDATE actual_node SET changelist = NULL
@@ -368,7 +441,11 @@ UPDATE actual_node SET changelist = NULL
 -- STMT_MARK_SKIPPED_CHANGELIST_DIRS
 /* 7 corresponds to svn_wc_notify_skip */
 INSERT INTO changelist_list (wc_id, local_relpath, notify, changelist)
-SELECT wc_id, local_relpath, 7, ?1 FROM targets_list WHERE kind = 'dir'
+SELECT wc_id, local_relpath, 7, ?3
+FROM targets_list
+WHERE wc_id = ?1
+  AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND kind = 'dir'
 
 -- STMT_RESET_ACTUAL_WITH_CHANGELIST
 REPLACE INTO actual_node (
@@ -380,53 +457,31 @@ DROP TABLE IF EXISTS changelist_list;
 CREATE TEMPORARY TABLE changelist_list (
   wc_id  INTEGER NOT NULL,
   local_relpath TEXT NOT NULL,
-  notify INTEGER,
-  changelist TEXT NOT NULL
-  );
-CREATE INDEX changelist_list_index ON changelist_list(wc_id, local_relpath);
-/* We have four cases upon which we wish to notify.  The first is easy:
-
-        Action                                  Notification
-        ------                                  ------------
-        INSERT ACTUAL                           cl-set
-
-   The others are a bit more complex:
-        Action          Old CL      New CL      Notification
-        ------          ------      ------      ------------
-        UPDATE ACTUAL   NULL        NOT NULL    cl-set
-        UPDATE ACTUAL   NOT NULL    NOT NULL    cl-set
-        UPDATE ACTUAL   NOT NULL    NULL        cl-clear
-
-Of the following triggers, the first address the first case, and the second
-two address the last three cases.
+  notify INTEGER NOT NULL,
+  changelist TEXT NOT NULL,
+  /* Order NOTIFY descending to make us show clears (27) before adds (26) */
+  PRIMARY KEY (wc_id, local_relpath, notify DESC)
+)
+
+/* Create notify items for when a node is removed from a changelist and
+   when a node is added to a changelist. Make sure nothing is notified
+   if there were no changes.
 */
-DROP TRIGGER IF EXISTS   trigger_changelist_list_actual_cl_insert;
-CREATE TEMPORARY TRIGGER trigger_changelist_list_actual_cl_insert
-BEFORE INSERT ON actual_node
-BEGIN
-    /* 26 corresponds to svn_wc_notify_changelist_set */
-    INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist)
-    VALUES (NEW.wc_id, NEW.local_relpath, 26, NEW.changelist);
-END;
-DROP TRIGGER IF EXISTS   trigger_changelist_list_actual_cl_clear;
-CREATE TEMPORARY TRIGGER trigger_changelist_list_actual_cl_clear
+-- STMT_CREATE_CHANGELIST_TRIGGER
+DROP TRIGGER IF EXISTS   trigger_changelist_list_change;
+CREATE TEMPORARY TRIGGER trigger_changelist_list_change
 BEFORE UPDATE ON actual_node
-WHEN OLD.changelist IS NOT NULL AND
-        (OLD.changelist != NEW.changelist OR NEW.changelist IS NULL)
+WHEN old.changelist IS NOT new.changelist
 BEGIN
-    /* 27 corresponds to svn_wc_notify_changelist_clear */
-    INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist)
-    VALUES (OLD.wc_id, OLD.local_relpath, 27, OLD.changelist);
-END;
-DROP TRIGGER IF EXISTS   trigger_changelist_list_actual_cl_set;
-CREATE TEMPORARY TRIGGER trigger_changelist_list_actual_cl_set
-BEFORE UPDATE ON actual_node
-WHEN NEW.CHANGELIST IS NOT NULL AND
-        (OLD.changelist != NEW.changelist OR OLD.changelist IS NULL)
-BEGIN
-    /* 26 corresponds to svn_wc_notify_changelist_set */
-    INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist)
-    VALUES (NEW.wc_id, NEW.local_relpath, 26, NEW.changelist);
+  /* 27 corresponds to svn_wc_notify_changelist_clear */
+  INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist)
+  SELECT old.wc_id, old.local_relpath, 27, old.changelist
+   WHERE old.changelist is NOT NULL;
+
+  /* 26 corresponds to svn_wc_notify_changelist_set */
+  INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist)
+  SELECT new.wc_id, new.local_relpath, 26, new.changelist
+   WHERE new.changelist IS NOT NULL;
 END
 
 -- STMT_INSERT_CHANGELIST_LIST
@@ -434,16 +489,14 @@ INSERT INTO changelist_list(wc_id, local
 VALUES (?1, ?2, ?3, ?4)
 
 -- STMT_FINALIZE_CHANGELIST
-DROP TRIGGER IF EXISTS trigger_changelist_list_actual_cl_insert;
-DROP TRIGGER IF EXISTS trigger_changelist_list_actual_cl_set;
-DROP TRIGGER IF EXISTS trigger_changelist_list_actual_cl_clear;
-DROP TABLE IF EXISTS changelist_list;
-DROP TABLE IF EXISTS targets_list
+DROP TRIGGER trigger_changelist_list_change;
+DROP TABLE changelist_list;
+DROP TABLE targets_list
 
 -- STMT_SELECT_CHANGELIST_LIST
 SELECT wc_id, local_relpath, notify, changelist
 FROM changelist_list
-ORDER BY wc_id, local_relpath
+ORDER BY wc_id, local_relpath ASC, notify DESC
 
 -- STMT_CREATE_TARGETS_LIST
 DROP TABLE IF EXISTS targets_list;
@@ -451,64 +504,70 @@ CREATE TEMPORARY TABLE targets_list (
   wc_id  INTEGER NOT NULL,
   local_relpath TEXT NOT NULL,
   parent_relpath TEXT,
-  kind TEXT NOT NULL
+  kind TEXT NOT NULL,
+  PRIMARY KEY (wc_id, local_relpath)
   );
-CREATE INDEX targets_list_kind
-  ON targets_list (kind)
 /* need more indicies? */
 
 -- STMT_DROP_TARGETS_LIST
-DROP TABLE IF EXISTS targets_list
+DROP TABLE targets_list
 
 -- STMT_INSERT_TARGET
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
 SELECT wc_id, local_relpath, parent_relpath, kind
-FROM nodes_current WHERE wc_id = ?1 AND local_relpath = ?2
+FROM nodes_current
+WHERE wc_id = ?1
+  AND local_relpath = ?2
 
 -- STMT_INSERT_TARGET_DEPTH_FILES
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
 SELECT wc_id, local_relpath, parent_relpath, kind
 FROM nodes_current
-WHERE wc_id = ?1 AND ((parent_relpath = ?2 AND kind = 'file')
-                      OR local_relpath = ?2)
+WHERE wc_id = ?1
+  AND parent_relpath = ?2
+  AND kind = 'file'
 
 -- STMT_INSERT_TARGET_DEPTH_IMMEDIATES
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
 SELECT wc_id, local_relpath, parent_relpath, kind
 FROM nodes_current
-WHERE wc_id = ?1 AND (parent_relpath = ?2 OR local_relpath = ?2)
+WHERE wc_id = ?1
+  AND parent_relpath = ?2
 
 -- STMT_INSERT_TARGET_DEPTH_INFINITY
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
 SELECT wc_id, local_relpath, parent_relpath, kind
 FROM nodes_current
 WHERE wc_id = ?1
-       AND (?2 = ''
-            OR local_relpath = ?2 
-            OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
 
 -- STMT_INSERT_TARGET_WITH_CHANGELIST
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
 SELECT N.wc_id, N.local_relpath, N.parent_relpath, N.kind
   FROM actual_node AS A JOIN nodes_current AS N
     ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath
- WHERE N.wc_id = ?1 AND A.changelist = ?3 AND N.local_relpath = ?2
+ WHERE N.wc_id = ?1
+   AND N.local_relpath = ?2
+   AND A.changelist = ?3
 
 -- STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_FILES
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
 SELECT N.wc_id, N.local_relpath, N.parent_relpath, N.kind
   FROM actual_node AS A JOIN nodes_current AS N
     ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath
- WHERE N.wc_id = ?1 AND A.changelist = ?3
-       AND ((N.parent_relpath = ?2 AND kind = 'file') OR N.local_relpath = ?2)
+ WHERE N.wc_id = ?1
+   AND N.parent_relpath = ?2
+   AND kind = 'file'
+   AND A.changelist = ?3
 
 -- STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_IMMEDIATES
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
 SELECT N.wc_id, N.local_relpath, N.parent_relpath, N.kind
   FROM actual_node AS A JOIN nodes_current AS N
     ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath
- WHERE N.wc_id = ?1 AND A.changelist = ?3
-       AND (N.parent_relpath = ?2 OR N.local_relpath = ?2)
+ WHERE N.wc_id = ?1
+   AND N.parent_relpath = ?2
+  AND A.changelist = ?3
 
 -- STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_INFINITY
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
@@ -516,33 +575,30 @@ SELECT N.wc_id, N.local_relpath, N.paren
   FROM actual_node AS A JOIN nodes_current AS N
     ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath
  WHERE N.wc_id = ?1
-       AND (?2 = ''
-            OR N.local_relpath = ?2 
-            OR IS_STRICT_DESCENDANT_OF(N.local_relpath, ?2))
-       AND A.changelist = ?3
+   AND IS_STRICT_DESCENDANT_OF(N.local_relpath, ?2)
+   AND A.changelist = ?3
 
--- STMT_SELECT_TARGETS
-SELECT local_relpath, parent_relpath from targets_list
+/* Only used by commented dump_targets() in wc_db.c */
+/*-- STMT_SELECT_TARGETS
+SELECT local_relpath, parent_relpath from targets_list*/
 
 -- STMT_INSERT_ACTUAL_EMPTIES
 INSERT OR IGNORE INTO 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, local_relpath, parent_relpath, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL
+     wc_id, local_relpath, parent_relpath)
+SELECT wc_id, local_relpath, parent_relpath
 FROM targets_list
 
 -- STMT_DELETE_ACTUAL_EMPTY
 DELETE FROM actual_node
 WHERE wc_id = ?1 AND local_relpath = ?2
   AND properties IS NULL
+  AND conflict_data IS NULL
   AND conflict_old IS NULL
   AND conflict_new IS NULL
   AND prop_reject IS NULL
+  AND tree_conflict_data IS NULL
   AND changelist IS NULL
   AND text_mod IS NULL
-  AND tree_conflict_data IS NULL
   AND older_checksum IS NULL
   AND right_checksum IS NULL
   AND left_checksum IS NULL
@@ -550,13 +606,15 @@ WHERE wc_id = ?1 AND local_relpath = ?2
 -- STMT_DELETE_ACTUAL_EMPTIES
 DELETE FROM actual_node
 WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND properties IS NULL
+  AND conflict_data IS NULL
   AND conflict_old IS NULL
   AND conflict_new IS NULL
   AND prop_reject IS NULL
+  AND tree_conflict_data IS NULL
   AND changelist IS NULL
   AND text_mod IS NULL
-  AND tree_conflict_data IS NULL
   AND older_checksum IS NULL
   AND right_checksum IS NULL
   AND left_checksum IS NULL
@@ -582,11 +640,10 @@ WHERE wc_id = ?1 AND local_relpath = ?2
 DELETE FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2
 
--- STMT_DELETE_NODES_RECURSIVE
+-- STMT_DELETE_NODES_ABOVE_DEPTH_RECURSIVE
 DELETE FROM nodes
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth >= ?3
 
@@ -594,18 +651,13 @@ WHERE wc_id = ?1
 DELETE FROM actual_node
 WHERE wc_id = ?1 AND local_relpath = ?2
 
+/* Will not delete recursive when run on the wcroot */
 -- STMT_DELETE_ACTUAL_NODE_RECURSIVE
 DELETE FROM actual_node
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
 
--- STMT_DELETE_ACTUAL_NODE_WITHOUT_CONFLICT
-DELETE FROM actual_node
-WHERE wc_id = ?1 AND local_relpath = ?2
-      AND tree_conflict_data IS NULL
-
 -- STMT_DELETE_ACTUAL_NODE_LEAVING_CHANGELIST
 DELETE FROM actual_node
 WHERE wc_id = ?1
@@ -618,8 +670,7 @@ WHERE wc_id = ?1
 -- STMT_DELETE_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE
 DELETE FROM actual_node
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND (changelist IS NULL
        OR NOT EXISTS (SELECT 1 FROM nodes_current c
@@ -631,11 +682,12 @@ WHERE wc_id = ?1
 UPDATE actual_node
 SET properties = NULL,
     text_mod = NULL,
-    tree_conflict_data = NULL,
+    conflict_data = NULL,
     conflict_old = NULL,
     conflict_new = NULL,
     conflict_working = NULL,
     prop_reject = NULL,
+    tree_conflict_data = NULL,
     older_checksum = NULL,
     left_checksum = NULL,
     right_checksum = NULL
@@ -645,17 +697,17 @@ WHERE wc_id = ?1 AND local_relpath = ?2
 UPDATE actual_node
 SET properties = NULL,
     text_mod = NULL,
-    tree_conflict_data = NULL,
+    conflict_data = NULL,
     conflict_old = NULL,
     conflict_new = NULL,
     conflict_working = NULL,
     prop_reject = NULL,
+    tree_conflict_data = NULL,
     older_checksum = NULL,
     left_checksum = NULL,
     right_checksum = NULL
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
 
 -- STMT_UPDATE_NODE_BASE_DEPTH
@@ -715,32 +767,27 @@ WHERE refcount = 0
 DELETE FROM pristine
 WHERE checksum = ?1 AND refcount = 0
 
--- STMT_SELECT_ACTUAL_CONFLICT_VICTIMS
-SELECT local_relpath
+-- STMT_SELECT_CONFLICT_VICTIMS
+SELECT local_relpath, conflict_data
 FROM actual_node
 WHERE wc_id = ?1 AND parent_relpath = ?2 AND
-  NOT ((prop_reject IS NULL) AND (conflict_old IS NULL)
+  NOT ((conflict_data IS NULL) AND (conflict_old IS NULL)
        AND (conflict_new IS NULL) AND (conflict_working IS NULL)
-       AND (tree_conflict_data IS NULL))
+       AND (prop_reject IS NULL) AND (tree_conflict_data IS NULL))
+
+-- STMT_SELECT_CONFLICT_MARKER_FILES1
+SELECT prop_reject
+FROM actual_node
+WHERE wc_id = ?1 AND local_relpath = ?2
+  AND (prop_reject IS NOT NULL)
 
--- STMT_SELECT_CONFLICT_MARKER_FILES
+-- STMT_SELECT_CONFLICT_MARKER_FILES2
 SELECT prop_reject, conflict_old, conflict_new, conflict_working
 FROM actual_node
-WHERE wc_id = ?1 AND (local_relpath = ?2 OR parent_relpath = ?2)
+WHERE wc_id = ?1 AND parent_relpath = ?2
   AND ((prop_reject IS NOT NULL) OR (conflict_old IS NOT NULL)
        OR (conflict_new IS NOT NULL) OR (conflict_working IS NOT NULL))
 
--- STMT_SELECT_ACTUAL_CHILDREN_TREE_CONFLICT
-SELECT local_relpath, tree_conflict_data
-FROM actual_node
-WHERE wc_id = ?1 AND parent_relpath = ?2 AND tree_conflict_data IS NOT NULL
-
--- STMT_SELECT_CONFLICT_DETAILS
-SELECT prop_reject, conflict_old, conflict_new, conflict_working,
-    tree_conflict_data
-FROM actual_node
-WHERE wc_id = ?1 AND local_relpath = ?2
-
 -- STMT_CLEAR_TEXT_CONFLICT
 UPDATE actual_node SET
   conflict_old = NULL,
@@ -753,6 +800,10 @@ UPDATE actual_node SET
   prop_reject = NULL
 WHERE wc_id = ?1 AND local_relpath = ?2
 
+-- STMT_CLEAR_TREE_CONFLICT
+UPDATE actual_node SET tree_conflict_data = NULL
+WHERE wc_id = ?1 AND local_relpath = ?2
+
 -- STMT_INSERT_WC_LOCK
 INSERT INTO wc_lock (wc_id, local_dir_relpath, locked_levels)
 VALUES (?1, ?2, ?3)
@@ -764,9 +815,8 @@ WHERE wc_id = ?1 AND local_dir_relpath =
 -- STMT_SELECT_ANCESTOR_WCLOCKS
 SELECT local_dir_relpath, locked_levels FROM wc_lock
 WHERE wc_id = ?1
-  AND ((local_dir_relpath <= ?2 AND local_dir_relpath >= ?3)
+  AND ((local_dir_relpath >= ?3 AND local_dir_relpath <= ?2)
        OR local_dir_relpath = '')
-ORDER BY local_dir_relpath DESC
 
 -- STMT_DELETE_WC_LOCK
 DELETE FROM wc_lock
@@ -774,7 +824,8 @@ WHERE wc_id = ?1 AND local_dir_relpath =
 
 -- STMT_FIND_WC_LOCK
 SELECT local_dir_relpath FROM wc_lock
-WHERE wc_id = ?1 AND local_dir_relpath LIKE ?2 ESCAPE '#'
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_dir_relpath, ?2)
 
 -- STMT_DELETE_WC_LOCK_ORPHAN
 DELETE FROM wc_lock
@@ -786,8 +837,7 @@ AND NOT EXISTS (SELECT 1 FROM nodes
 -- STMT_DELETE_WC_LOCK_ORPHAN_RECURSIVE
 DELETE FROM wc_lock
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_dir_relpath = ?2
+  AND (local_dir_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_dir_relpath, ?2))
   AND NOT EXISTS (SELECT 1 FROM nodes
                    WHERE nodes.wc_id = ?1
@@ -852,92 +902,69 @@ SELECT wc_id, local_relpath, ?3 /*op_dep
 FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
 
+/* Not valid on the wc-root */
 -- STMT_UPDATE_OP_DEPTH_INCREASE_RECURSIVE
 UPDATE nodes SET op_depth = ?3 + 1
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+ AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
  AND op_depth = ?3
 
 -- STMT_DOES_NODE_EXIST
 SELECT 1 FROM nodes WHERE wc_id = ?1 AND local_relpath = ?2
 LIMIT 1
 
--- STMT_HAS_SERVER_EXCLUDED_NODES
+-- STMT_HAS_SERVER_EXCLUDED_DESCENDANTS
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND op_depth = 0 AND presence = 'absent'
 LIMIT 1
 
-/* ### Select all server-excluded nodes. */
--- STMT_SELECT_ALL_SERVER_EXCLUDED_NODES
+/* Select all excluded nodes. Not valid on the WC-root */
+-- STMT_SELECT_ALL_EXCLUDED_DESCENDANTS
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND op_depth = 0
-  AND presence = 'absent'
+  AND (presence = 'absent' OR presence = 'excluded')
 
--- STMT_INSERT_WORKING_NODE_COPY_FROM_BASE
+/* Creates a copy from one top level NODE to a different location */
+-- STMT_INSERT_WORKING_NODE_COPY_FROM
 INSERT OR REPLACE INTO nodes (
     wc_id, local_relpath, op_depth, parent_relpath, repos_id,
     repos_path, revision, presence, depth, moved_here, kind, changed_revision,
     changed_date, changed_author, checksum, properties, translated_size,
     last_mod_time, symlink_target, moved_to )
-SELECT src.wc_id, ?3 /*local_relpath*/, ?4 /*op_depth*/, ?5 /*parent_relpath*/,
-    src.repos_id, src.repos_path, src.revision, ?6 /*presence*/, src.depth,
-    ?7/*moved_here*/, src.kind, src.changed_revision, src.changed_date,
-    src.changed_author, src.checksum, src.properties, src.translated_size,
-    src.last_mod_time, src.symlink_target, dst.moved_to
-FROM nodes AS src
-LEFT OUTER JOIN nodes_current dst ON dst.wc_id = src.wc_id
-  AND dst.local_relpath = ?3 AND dst.op_depth = ?4
-WHERE src.wc_id = ?1 AND src.local_relpath = ?2 AND src.op_depth = 0
+SELECT wc_id, ?3 /*local_relpath*/, ?4 /*op_depth*/, ?5 /*parent_relpath*/,
+    repos_id, repos_path, revision, ?6 /*presence*/, depth,
+    ?7/*moved_here*/, kind, changed_revision, changed_date,
+    changed_author, checksum, properties, translated_size,
+    last_mod_time, symlink_target,
+    (SELECT dst.moved_to FROM nodes AS dst
+                         WHERE dst.wc_id = ?1
+                         AND dst.local_relpath = ?3
+                         AND dst.op_depth = ?4)
+FROM nodes_current
+WHERE wc_id = ?1 AND local_relpath = ?2
 
--- STMT_INSERT_WORKING_NODE_COPY_FROM_WORKING
+-- STMT_INSERT_WORKING_NODE_COPY_FROM_DEPTH
 INSERT OR REPLACE INTO nodes (
     wc_id, local_relpath, op_depth, parent_relpath, repos_id,
     repos_path, revision, presence, depth, moved_here, kind, changed_revision,
     changed_date, changed_author, checksum, properties, translated_size,
     last_mod_time, symlink_target, moved_to )
-SELECT src.wc_id, ?3 /*local_relpath*/, ?4 /*op_depth*/, ?5 /*parent_relpath*/,
-    src.repos_id, src.repos_path, src.revision, ?6 /*presence*/, src.depth,
-    ?7 /*moved_here*/, src.kind, src.changed_revision, src.changed_date,
-    src.changed_author, src.checksum, src.properties, src.translated_size,
-    src.last_mod_time, src.symlink_target, dst.moved_to
-FROM nodes_current AS src
-LEFT OUTER JOIN nodes_current dst ON dst.wc_id = src.wc_id
-  AND dst.local_relpath = ?3  AND dst.op_depth = ?4
-WHERE src.wc_id = ?1 AND src.local_relpath = ?2 AND src.op_depth > 0
-
--- STMT_INSERT_WORKING_NODE_COPY_FROM_DEPTH
-INSERT OR REPLACE INTO nodes (
-    wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path,
-    revision, presence, depth, moved_here, kind, changed_revision, changed_date,
-    changed_author, checksum, properties, translated_size, last_mod_time,
-    symlink_target )
 SELECT wc_id, ?3 /*local_relpath*/, ?4 /*op_depth*/, ?5 /*parent_relpath*/,
-    repos_id, repos_path, revision, ?6 /*presence*/, depth, ?7 /*moved_here*/,
-    kind, changed_revision, changed_date, changed_author, checksum,
-    properties, translated_size, last_mod_time, symlink_target
+    repos_id, repos_path, revision, ?6 /*presence*/, depth,
+    ?7 /*moved_here*/, kind, changed_revision, changed_date,
+    changed_author, checksum, properties, translated_size,
+    last_mod_time, symlink_target,
+    (SELECT dst.moved_to FROM nodes AS dst
+                         WHERE dst.wc_id = ?1
+                         AND dst.local_relpath = ?3
+                         AND dst.op_depth = ?4)
 FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?8
 
--- STMT_INSERT_ACTUAL_NODE_FROM_ACTUAL_NODE
-INSERT OR REPLACE INTO 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, ?3 /*local_relpath*/, ?4 /*parent_relpath*/, properties,
-     conflict_old, conflict_new, conflict_working,
-     prop_reject, changelist, text_mod, tree_conflict_data
-FROM actual_node
-WHERE wc_id = ?1 AND local_relpath = ?2
-
 -- STMT_UPDATE_BASE_REVISION
 UPDATE nodes SET revision = ?3
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
@@ -963,6 +990,24 @@ SELECT presence, kind, def_local_relpath
 FROM externals WHERE wc_id = ?1 AND local_relpath = ?2
 LIMIT 1
 
+-- STMT_DELETE_FILE_EXTERNALS
+DELETE FROM nodes
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND op_depth = 0
+  AND file_external IS NOT NULL
+
+-- STMT_DELETE_FILE_EXTERNAL_REGISTATIONS
+DELETE FROM externals
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND kind != 'dir'
+
+-- STMT_DELETE_EXTERNAL_REGISTATIONS
+DELETE FROM externals
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+
 /* Select all committable externals, i.e. only unpegged ones on the same
  * repository as the target path ?2, that are defined by WC ?1 to
  * live below the target path. It does not matter which ancestor has the
@@ -977,55 +1022,76 @@ LIMIT 1
  * inside an unversioned dir, because commit still breaks on those.
  * Once that's been fixed, the conditions below "--->8---" become obsolete. */
 -- STMT_SELECT_COMMITTABLE_EXTERNALS_BELOW
-SELECT local_relpath, kind, repos_id, def_repos_relpath, repository.root
-FROM externals
-LEFT OUTER JOIN repository ON repository.id = externals.repos_id
-WHERE wc_id = ?1
-  AND def_revision IS NULL
-  AND repos_id = (SELECT repos_id FROM nodes
-                  WHERE nodes.local_relpath = ?2)
-  AND ( ((NOT ?3)
-         AND (?2 = ''
-              /* Want only the cildren of e.local_relpath;
-               * externals can't have a local_relpath = ''. */
-              OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
-        OR
-        ((?3)
-         AND parent_relpath = ?2) )
+SELECT local_relpath, kind, def_repos_relpath,
+       (SELECT root FROM repository AS r
+         WHERE r.id = e.repos_id)
+FROM externals AS e
+WHERE e.wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(e.local_relpath, ?2)
+  AND e.def_revision IS NULL
+  AND e.repos_id = (SELECT repos_id
+                    FROM nodes AS n
+                    WHERE n.wc_id = ?1
+                      AND n.local_relpath = ''
+                      AND n.op_depth = 0)
+  AND ( (NOT ?3) OR (parent_relpath = ?2) )
   /* ------>8----- */
   AND (EXISTS (SELECT 1 FROM nodes
-               WHERE nodes.wc_id = externals.wc_id
-               AND nodes.local_relpath = externals.parent_relpath))
+               WHERE nodes.wc_id = e.wc_id
+               AND nodes.local_relpath = e.parent_relpath))
 
 -- STMT_SELECT_EXTERNALS_DEFINED
 SELECT local_relpath, def_local_relpath
 FROM externals
-WHERE wc_id = ?1 
-  AND (?2 = ''
-       OR def_local_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(def_local_relpath, ?2))
-
--- STMT_UPDATE_EXTERNAL_FILEINFO
-UPDATE externals SET recorded_size = ?3, recorded_mod_time = ?4
-WHERE wc_id = ?1 AND local_relpath = ?2
+/* ### The Sqlite optimizer needs help here ###
+ * WHERE wc_id = ?1
+ *   AND (def_local_relpath = ?2
+ *        OR IS_STRICT_DESCENDANT_OF(def_local_relpath, ?2)) */
+WHERE (wc_id = ?1 AND def_local_relpath = ?2)
+   OR (wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(def_local_relpath, ?2))
 
 -- STMT_DELETE_EXTERNAL
 DELETE FROM externals
 WHERE wc_id = ?1 AND local_relpath = ?2
 
 -- STMT_SELECT_EXTERNAL_PROPERTIES
+/* ### It would be nice if Sqlite would handle
+ * SELECT IFNULL((SELECT properties FROM actual_node a
+ *                WHERE a.wc_id = ?1 AND A.local_relpath = n.local_relpath),
+ *               properties),
+ *        local_relpath, depth
+ * FROM nodes_current n
+ * WHERE wc_id = ?1
+ *   AND (local_relpath = ?2
+ *        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+ *   AND kind = 'dir' AND presence IN ('normal', 'incomplete')
+ * ### But it would take a double table scan execution plan for it.
+ * ### Maybe there is something else going on? */
 SELECT IFNULL((SELECT properties FROM actual_node a
                WHERE a.wc_id = ?1 AND A.local_relpath = n.local_relpath),
               properties),
        local_relpath, depth
-FROM nodes n
-WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
-  AND kind = 'dir' AND presence='normal'
-  AND op_depth=(SELECT MAX(op_depth) FROM nodes o
-                WHERE o.wc_id = ?1 AND o.local_relpath = n.local_relpath)
+FROM nodes_current n
+WHERE wc_id = ?1 AND local_relpath = ?2
+  AND kind = 'dir' AND presence IN ('normal', 'incomplete')
+UNION ALL
+SELECT IFNULL((SELECT properties FROM actual_node a
+               WHERE a.wc_id = ?1 AND A.local_relpath = n.local_relpath),
+              properties),
+       local_relpath, depth
+FROM nodes_current n
+WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND kind = 'dir' AND presence IN ('normal', 'incomplete')
+
+-- STMT_SELECT_CURRENT_PROPS_RECURSIVE
+/* ### Ugly OR to make sqlite use the proper optimizations */
+SELECT IFNULL((SELECT properties FROM actual_node a
+               WHERE a.wc_id = ?1 AND A.local_relpath = n.local_relpath),
+              properties),
+       local_relpath
+FROM nodes_current n
+WHERE (wc_id = ?1 AND local_relpath = ?2)
+   OR (wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
 
 /* ------------------------------------------------------------------------- */
 
@@ -1033,11 +1099,9 @@ WHERE wc_id = ?1
 
 -- STMT_INSERT_ACTUAL_NODE
 INSERT OR REPLACE INTO actual_node (
-  wc_id, local_relpath, parent_relpath, properties, conflict_old,
-  conflict_new,
-  conflict_working, prop_reject, changelist, text_mod,
-  tree_conflict_data)
-VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, NULL, ?10)
+  wc_id, local_relpath, parent_relpath, properties, changelist, conflict_data,
+  conflict_old, conflict_new, conflict_working, prop_reject, tree_conflict_data)
+VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)
 
 /* ------------------------------------------------------------------------- */
 
@@ -1052,16 +1116,8 @@ INSERT INTO actual_node (
   wc_id, local_relpath, conflict_data, parent_relpath)
 VALUES (?1, ?2, ?3, ?4)
 
--- STMT_SELECT_OLD_TREE_CONFLICT
-SELECT wc_id, local_relpath, tree_conflict_data
-FROM actual_node
-WHERE tree_conflict_data IS NOT NULL
-
--- STMT_ERASE_OLD_CONFLICTS
-UPDATE actual_node SET tree_conflict_data = NULL
-
 -- STMT_SELECT_ALL_FILES
-SELECT DISTINCT local_relpath FROM nodes
+SELECT local_relpath FROM nodes_current
 WHERE wc_id = ?1 AND parent_relpath = ?2 AND kind = 'file'
 
 -- STMT_UPDATE_NODE_PROPS
@@ -1072,72 +1128,61 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 SELECT 1 FROM nodes WHERE op_depth > 0
 LIMIT 1
 
--- STMT_HAS_ACTUAL_NODES_CONFLICTS
-SELECT 1 FROM actual_node
-WHERE NOT ((prop_reject IS NULL) AND (conflict_old IS NULL)
-           AND (conflict_new IS NULL) AND (conflict_working IS NULL)
-           AND (tree_conflict_data IS NULL))
-LIMIT 1
-
-/* ------------------------------------------------------------------------- */
-/* PROOF OF CONCEPT: Complex queries for callback walks, caching results
-                     in a temporary table. */
+/* --------------------------------------------------------------------------
+ * Complex queries for callback walks, caching results in a temporary table.
+ *
+ * These target table are then used for joins against NODES, or for reporting
+ */
 
--- STMT_CREATE_NODE_PROPS_CACHE
-DROP TABLE IF EXISTS temp__node_props_cache;
-CREATE TEMPORARY TABLE temp__node_props_cache (
-  local_Relpath TEXT NOT NULL,
+-- STMT_CREATE_TARGET_PROP_CACHE
+DROP TABLE IF EXISTS target_prop_cache;
+CREATE TEMPORARY TABLE target_prop_cache (
+  local_relpath TEXT NOT NULL PRIMARY KEY,
   kind TEXT NOT NULL,
   properties BLOB
-  );
+);
 /* ###  Need index?
 CREATE UNIQUE INDEX temp__node_props_cache_unique
   ON temp__node_props_cache (local_relpath) */
 
--- STMT_CACHE_NODE_PROPS
-INSERT INTO temp__node_props_cache(local_relpath, kind, properties)
- SELECT local_relpath, kind, properties FROM nodes_current
-  WHERE wc_id = ?1
-    AND local_relpath IN (SELECT local_relpath FROM targets_list)
-    AND presence IN ('normal', 'incomplete')
+-- STMT_CACHE_TARGET_PROPS
+INSERT INTO target_prop_cache(local_relpath, kind, properties)
+ SELECT n.local_relpath, n.kind,
+        IFNULL((SELECT properties FROM actual_node AS a
+                 WHERE a.wc_id = n.wc_id
+                   AND a.local_relpath = n.local_relpath),
+               n.properties)
+   FROM targets_list AS t
+   JOIN nodes_current AS n ON t.wc_id= n.wc_id
+                          AND t.local_relpath = n.local_relpath
+  WHERE t.wc_id = ?1
+    AND (presence='normal' OR presence='incomplete')
+
+-- STMT_CACHE_TARGET_PRISTINE_PROPS
+INSERT INTO target_prop_cache(local_relpath, kind, properties)
+ SELECT n.local_relpath, n.kind,
+        CASE n.presence
+          WHEN 'base-deleted'
+          THEN (SELECT properties FROM nodes AS p
+                 WHERE p.wc_id = n.wc_id
+                   AND p.local_relpath = n.local_relpath
+                   AND p.op_depth < n.op_depth
+                 ORDER BY p.op_depth DESC /* LIMIT 1 */)
+          ELSE properties END
+  FROM targets_list AS t
+  JOIN nodes_current AS n ON t.wc_id= n.wc_id
+                          AND t.local_relpath = n.local_relpath
+  WHERE t.wc_id = ?1
+    AND (presence = 'normal'
+         OR presence = 'incomplete'
+         OR presence = 'base-deleted')
 
--- STMT_CACHE_ACTUAL_PROPS
-UPDATE temp__node_props_cache 
-   SET properties=
-        IFNULL((SELECT properties FROM actual_node a
-                 WHERE a.wc_id = ?1
-                   AND a.local_relpath = temp__node_props_cache.local_relpath),
-               properties)
-
--- STMT_CACHE_NODE_BASE_PROPS
-INSERT INTO temp__node_props_cache (local_relpath, kind, properties)
-  SELECT local_relpath, kind, properties FROM nodes_base
-  WHERE wc_id = ?1
-    AND local_relpath IN (SELECT local_relpath FROM targets_list)
-    AND presence IN ('normal', 'incomplete')
-
--- STMT_CACHE_NODE_PRISTINE_PROPS
-INSERT INTO temp__node_props_cache(local_relpath, kind, properties)
- SELECT local_relpath, kind, 
-        IFNULL((SELECT properties FROM nodes nn
-                 WHERE n.presence = 'base-deleted'
-                   AND nn.wc_id = n.wc_id
-                   AND nn.local_relpath = n.local_relpath
-                   AND nn.op_depth < n.op_depth
-                 ORDER BY op_depth DESC),
-               properties)
-  FROM nodes_current n
-  WHERE wc_id = ?1
-    AND local_relpath IN (SELECT local_relpath FROM targets_list)
-    AND presence IN ('normal', 'incomplete', 'base-deleted')
-
--- STMT_SELECT_RELEVANT_PROPS_FROM_CACHE
-SELECT local_relpath, properties FROM temp__node_props_cache
+-- STMT_SELECT_ALL_TARGET_PROP_CACHE
+SELECT local_relpath, properties FROM target_prop_cache
 ORDER BY local_relpath
 
--- STMT_DROP_NODE_PROPS_CACHE
-DROP TABLE IF EXISTS temp__node_props_cache;
-
+-- STMT_DROP_TARGET_PROP_CACHE
+DROP TABLE target_prop_cache;
 
 -- STMT_CREATE_REVERT_LIST
 DROP TABLE IF EXISTS revert_list;
@@ -1145,6 +1190,7 @@ CREATE TEMPORARY TABLE revert_list (
    /* need wc_id if/when revert spans multiple working copies */
    local_relpath TEXT NOT NULL,
    actual INTEGER NOT NULL,         /* 1 if an actual row, 0 if a nodes row */
+   conflict_data BLOB,
    conflict_old TEXT,
    conflict_new TEXT,
    conflict_working TEXT,
@@ -1167,39 +1213,51 @@ DROP TRIGGER IF EXISTS   trigger_revert_
 CREATE TEMPORARY TRIGGER trigger_revert_list_actual_delete
 BEFORE DELETE ON actual_node
 BEGIN
-   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_old,
-                                       conflict_new, conflict_working,
-                                       prop_reject, notify)
-   SELECT OLD.local_relpath, 1,
+   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_data,
+                                      conflict_old, conflict_new,
+                                      conflict_working, prop_reject, notify)
+   SELECT OLD.local_relpath, 1, OLD.conflict_data,
           OLD.conflict_old, OLD.conflict_new, OLD.conflict_working,
           OLD.prop_reject,
           CASE
-          WHEN OLD.properties IS NOT NULL OR OLD.tree_conflict_data IS NOT NULL
-          THEN 1 ELSE NULL END;
+            WHEN OLD.properties IS NOT NULL
+            THEN 1
+            WHEN NOT EXISTS(SELECT 1 FROM NODES n
+                            WHERE n.wc_id = OLD.wc_id
+                              AND n.local_relpath = OLD.local_relpath)
+            THEN 1
+            ELSE NULL
+          END;
 END;
 DROP TRIGGER IF EXISTS   trigger_revert_list_actual_update;
 CREATE TEMPORARY TRIGGER trigger_revert_list_actual_update
 BEFORE UPDATE ON actual_node
 BEGIN
-   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_old,
-                                       conflict_new, conflict_working,
-                                       prop_reject, notify)
-   SELECT OLD.local_relpath, 1,
+   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_data,
+                                      conflict_old, conflict_new,
+                                      conflict_working, prop_reject, notify)
+   SELECT OLD.local_relpath, 1, OLD.conflict_data,
           OLD.conflict_old, OLD.conflict_new, OLD.conflict_working,
           OLD.prop_reject,
           CASE
-          WHEN OLD.properties IS NOT NULL OR OLD.tree_conflict_data IS NOT NULL
-          THEN 1 ELSE NULL END;
+            WHEN OLD.properties IS NOT NULL
+            THEN 1
+            WHEN NOT EXISTS(SELECT 1 FROM NODES n
+                            WHERE n.wc_id = OLD.wc_id
+                              AND n.local_relpath = OLD.local_relpath)
+            THEN 1
+            ELSE NULL
+          END;
 END
 
 -- STMT_DROP_REVERT_LIST_TRIGGERS
-DROP TRIGGER IF EXISTS trigger_revert_list_nodes;
-DROP TRIGGER IF EXISTS trigger_revert_list_actual_delete;
-DROP TRIGGER IF EXISTS trigger_revert_list_actual_update
+DROP TRIGGER trigger_revert_list_nodes;
+DROP TRIGGER trigger_revert_list_actual_delete;
+DROP TRIGGER trigger_revert_list_actual_update
 
 -- STMT_SELECT_REVERT_LIST
-SELECT conflict_old, conflict_new, conflict_working, prop_reject, notify,
-       actual, op_depth, repos_id, kind
+SELECT actual, notify, kind, op_depth, repos_id, conflict_data,
+       conflict_old, conflict_new, conflict_working, prop_reject
 FROM revert_list
 WHERE local_relpath = ?1
 ORDER BY actual DESC
@@ -1207,7 +1265,7 @@ ORDER BY actual DESC
 -- STMT_SELECT_REVERT_LIST_COPIED_CHILDREN
 SELECT local_relpath, kind
 FROM revert_list
-WHERE local_relpath LIKE ?1 ESCAPE '#'
+WHERE IS_STRICT_DESCENDANT_OF(local_relpath, ?1)
   AND op_depth >= ?2
   AND repos_id IS NOT NULL
 ORDER BY local_relpath
@@ -1218,13 +1276,15 @@ DELETE FROM revert_list WHERE local_relp
 -- STMT_SELECT_REVERT_LIST_RECURSIVE
 SELECT DISTINCT local_relpath
 FROM revert_list
-WHERE (local_relpath = ?1 OR local_relpath LIKE ?2 ESCAPE '#')
+WHERE (local_relpath = ?1
+       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?1))
   AND (notify OR actual = 0)
 ORDER BY local_relpath
 
 -- STMT_DELETE_REVERT_LIST_RECURSIVE
 DELETE FROM revert_list
-WHERE local_relpath = ?1 OR local_relpath LIKE ?2 ESCAPE '#'
+WHERE (local_relpath = ?1
+       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?1))
 
 -- STMT_DROP_REVERT_LIST
 DROP TABLE IF EXISTS revert_list
@@ -1237,14 +1297,18 @@ CREATE TEMPORARY TABLE delete_list (
    local_relpath TEXT PRIMARY KEY NOT NULL UNIQUE
    )
 
-/* This matches the selection in STMT_INSERT_DELETE_FROM_NODE_RECURSIVE */
+/* This matches the selection in STMT_INSERT_DELETE_FROM_NODE_RECURSIVE.
+   A subquery is used instead of nodes_current to avoid a table scan */
 -- STMT_INSERT_DELETE_LIST
 INSERT INTO delete_list(local_relpath)
-SELECT local_relpath FROM nodes_current
+SELECT local_relpath FROM nodes AS n
 WHERE wc_id = ?1
   AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth >= ?3
+  AND op_depth = (SELECT MAX(s.op_depth) FROM nodes AS s
+                  WHERE s.wc_id = ?1
+                    AND s.local_relpath = n.local_relpath)
   AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'absent')
 
 -- STMT_SELECT_DELETE_LIST
@@ -1252,7 +1316,7 @@ SELECT local_relpath FROM delete_list
 ORDER BY local_relpath
 
 -- STMT_FINALIZE_DELETE
-DROP TABLE IF EXISTS delete_list
+DROP TABLE delete_list
 
 
 /* ------------------------------------------------------------------------- */
@@ -1263,9 +1327,8 @@ DROP TABLE IF EXISTS delete_list
 SELECT MIN(revision), MAX(revision),
        MIN(changed_revision), MAX(changed_revision) FROM nodes
   WHERE wc_id = ?1
-    AND (?2 = ''
-       OR local_relpath = ?2
-       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+    AND (local_relpath = ?2
+         OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
     AND presence IN ('normal', 'incomplete')
     AND file_external IS NULL
     AND op_depth = 0
@@ -1273,8 +1336,7 @@ SELECT MIN(revision), MAX(revision),
 -- STMT_HAS_SPARSE_NODES
 SELECT 1 FROM nodes
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth = 0
   AND (presence IN ('absent', 'excluded')
@@ -1285,8 +1347,7 @@ LIMIT 1
 -- STMT_SUBTREE_HAS_TREE_MODIFICATIONS
 SELECT 1 FROM nodes
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth > 0
 LIMIT 1
@@ -1294,8 +1355,7 @@ LIMIT 1
 -- STMT_SUBTREE_HAS_PROP_MODIFICATIONS
 SELECT 1 FROM actual_node
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND properties IS NOT NULL
 LIMIT 1
@@ -1372,8 +1432,7 @@ LIMIT 1
 -- STMT_SELECT_BASE_FILES_RECURSIVE
 SELECT local_relpath, translated_size, last_mod_time FROM nodes AS n
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth = 0
   AND kind='file'

Modified: subversion/branches/compressed-pristines/subversion/libsvn_wc/wc.h
URL: http://svn.apache.org/viewvc/subversion/branches/compressed-pristines/subversion/libsvn_wc/wc.h?rev=1373783&r1=1373782&r2=1373783&view=diff
==============================================================================
--- subversion/branches/compressed-pristines/subversion/libsvn_wc/wc.h (original)
+++ subversion/branches/compressed-pristines/subversion/libsvn_wc/wc.h Thu Aug 16 10:17:48 2012
@@ -151,6 +151,9 @@ extern "C" {
  *
  * == 1.7.x shipped with format 29
  *
+ * The bump to 30 switched the conflict storage to a skel inside conflict_data.
+ * Also clears some known invalid state.
+ *
  * Please document any further format changes here.
  */
 
@@ -182,6 +185,9 @@ extern "C" {
 /* A version < this has no work queue (see workqueue.h).  */
 #define SVN_WC__HAS_WORK_QUEUE 13
 
+/* The first version that uses conflict skels for all conflicts */
+#define SVN_WC__USES_CONFLICT_SKELS 30
+
 /* Return true iff error E indicates an "is not a working copy" type
    of error, either because something wasn't a working copy at all, or
    because it's a working copy from a previous version (in need of
@@ -392,16 +398,6 @@ svn_wc__internal_file_modified_p(svn_boo
    When MERGE_OPTIONS are specified, they are used by the internal
    diff3 routines, or passed to the external diff3 tool.
 
-   If CONFLICT_FUNC is non-NULL, then call it with CONFLICT_BATON if a
-   conflict is encountered, giving the callback a chance to resolve
-   the conflict (before marking the file 'conflicted').
-
-   When LEFT_VERSION and RIGHT_VERSION are non-NULL, pass them to the
-   conflict resolver as older_version and their_version.
-
-   ## TODO: We should store the information in LEFT_VERSION and RIGHT_VERSION
-            in the working copy for future retrieval via svn info.
-
    WRI_ABSPATH describes in which working copy information should be
    retrieved. (Interesting for merging file externals).
 
@@ -418,12 +414,11 @@ svn_wc__internal_file_modified_p(svn_boo
 */
 svn_error_t *
 svn_wc__internal_merge(svn_skel_t **work_items,
+                       svn_skel_t **conflict_skel,
                        enum svn_wc_merge_outcome_t *merge_outcome,
                        svn_wc__db_t *db,
                        const char *left_abspath,
-                       const svn_wc_conflict_version_t *left_version,
                        const char *right_abspath,
-                       const svn_wc_conflict_version_t *right_version,
                        const char *target_abspath,
                        const char *wri_abspath,
                        const char *left_label,
@@ -434,8 +429,6 @@ svn_wc__internal_merge(svn_skel_t **work
                        const char *diff3_cmd,
                        const apr_array_header_t *merge_options,
                        const apr_array_header_t *prop_diff,
-                       svn_wc_conflict_resolver_func2_t conflict_func,
-                       void *conflict_baton,
                        svn_cancel_func_t cancel_func,
                        void *cancel_baton,
                        apr_pool_t *result_pool,
@@ -571,7 +564,6 @@ svn_error_t *
 svn_wc__internal_remove_from_revision_control(svn_wc__db_t *db,
                                               const char *local_abspath,
                                               svn_boolean_t destroy_wf,
-                                              svn_boolean_t instant_error,
                                               svn_cancel_func_t cancel_func,
                                               void *cancel_baton,
                                               apr_pool_t *scratch_pool);
@@ -627,12 +619,16 @@ svn_wc__internal_get_origin(svn_boolean_
                             apr_pool_t *result_pool,
                             apr_pool_t *scratch_pool);
 
-/* Internal version of svn_wc__node_get_commit_base_rev */
+/* Internal version of svn_wc__node_get_commit_base() */
 svn_error_t *
-svn_wc__internal_get_commit_base_rev(svn_revnum_t *commit_base_revision,
-                                     svn_wc__db_t *db,
-                                     const char *local_abspath,
-                                     apr_pool_t *scratch_pool);
+svn_wc__internal_get_commit_base(svn_revnum_t *commit_base_revision,
+                                 const char **repos_relpath,
+                                 const char **repos_root_url,
+                                 const char **repos_uuid,
+                                 svn_wc__db_t *db,
+                                 const char *local_abspath,
+                                 apr_pool_t *result_pool,
+                                 apr_pool_t *scratch_pool);
 
 
 /* Internal version of svn_wc__node_get_repos_info() */
@@ -656,6 +652,20 @@ svn_wc__upgrade_sdb(int *result_format,
                     int start_format,
                     apr_pool_t *scratch_pool);
 
+/* Create a conflict skel from the old separated data */
+svn_error_t *
+svn_wc__upgrade_conflict_skel_from_raw(svn_skel_t **conflicts,
+                                       svn_wc__db_t *db,
+                                       const char *wri_abspath,
+                                       const char *local_relpath,
+                                       const char *conflict_old,
+                                       const char *conflict_wrk,
+                                       const char *conflict_new,
+                                       const char *prej_file,
+                                       const char *tree_conflict_data,
+                                       apr_size_t tree_conflict_len,
+                                       apr_pool_t *result_pool,
+                                       apr_pool_t *scratch_pool);
 
 svn_error_t *
 svn_wc__wipe_postupgrade(const char *dir_abspath,
@@ -693,6 +703,22 @@ svn_wc__write_check(svn_wc__db_t *db,
                     const char *local_abspath,
                     apr_pool_t *scratch_pool);
 
+/* Read into CONFLICTS svn_wc_conflict_description2_t* structs
+ * for all conflicts that have LOCAL_ABSPATH as victim.
+ *
+ * Victim must be versioned or be part of a tree conflict.
+ *
+ * Allocate *CONFLICTS in RESULT_POOL and do temporary allocations in
+ * SCRATCH_POOL
+ */
+svn_error_t *
+svn_wc__read_conflicts(const apr_array_header_t **conflicts,
+                       svn_wc__db_t *db,
+                       const char *local_abspath,
+                       apr_pool_t *result_pool,
+                       apr_pool_t *scratch_pool);
+
+
 /* Perform the actual merge of file changes between an original file,
    identified by ORIGINAL_CHECKSUM (an empty file if NULL) to a new file
    identified by NEW_CHECKSUM in the working copy identified by WRI_ABSPATH.
@@ -705,6 +731,7 @@ svn_wc__write_check(svn_wc__db_t *db,
  */
 svn_error_t *
 svn_wc__perform_file_merge(svn_skel_t **work_items,
+                           svn_skel_t **conflict_skel,
                            enum svn_wc_merge_outcome_t *merge_outcome,
                            svn_wc__db_t *db,
                            const char *local_abspath,
@@ -717,8 +744,6 @@ svn_wc__perform_file_merge(svn_skel_t **
                            svn_revnum_t target_revision,
                            const apr_array_header_t *propchanges,
                            const char *diff3_cmd,
-                           svn_wc_conflict_resolver_func2_t conflict_func,
-                           void *conflict_baton,
                            svn_cancel_func_t cancel_func,
                            void *cancel_baton,
                            apr_pool_t *result_pool,