You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by pr...@apache.org on 2013/03/18 10:35:29 UTC

svn commit: r1457684 [15/22] - in /subversion/branches/verify-keep-going: ./ build/ build/ac-macros/ build/generator/ build/generator/templates/ notes/ subversion/bindings/javahl/native/ subversion/bindings/javahl/src/org/apache/subversion/javahl/ subv...

Modified: subversion/branches/verify-keep-going/subversion/libsvn_wc/wc_db_update_move.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_wc/wc_db_update_move.c?rev=1457684&r1=1457683&r2=1457684&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_wc/wc_db_update_move.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_wc/wc_db_update_move.c Mon Mar 18 09:35:24 2013
@@ -114,7 +114,6 @@
  */
 
 struct tc_editor_baton {
-  svn_skel_t **work_items;
   svn_wc__db_t *db;
   svn_wc__db_wcroot_t *wcroot;
   const char *move_root_dst_relpath;
@@ -126,9 +125,7 @@ struct tc_editor_baton {
   svn_wc_operation_t operation;
   svn_wc_conflict_version_t *old_version;
   svn_wc_conflict_version_t *new_version;
-  svn_wc_notify_func2_t notify_func;
-  void *notify_baton;
-  apr_pool_t *result_pool;
+  apr_pool_t *result_pool;  /* For things that live as long as the baton. */
 };
 
 /* 
@@ -161,13 +158,13 @@ update_move_list_add(svn_wc__db_wcroot_t
 
 /* Send all notifications stored in the notification list, and then
  * remove the temporary database table. */
-static svn_error_t *
-update_move_list_notify(svn_wc__db_wcroot_t *wcroot,
-                        svn_revnum_t old_revision,
-                        svn_revnum_t new_revision,
-                        svn_wc_notify_func2_t notify_func,
-                        void *notify_baton,
-                        apr_pool_t *scratch_pool)
+svn_error_t *
+svn_wc__db_update_move_list_notify(svn_wc__db_wcroot_t *wcroot,
+                                   svn_revnum_t old_revision,
+                                   svn_revnum_t new_revision,
+                                   svn_wc_notify_func2_t notify_func,
+                                   void *notify_baton,
+                                   apr_pool_t *scratch_pool)
 {
   svn_sqlite__stmt_t *stmt;
 
@@ -215,9 +212,16 @@ update_move_list_notify(svn_wc__db_wcroo
   return SVN_NO_ERROR;
 }
 
+/* Mark a tree-conflict on LOCAL_RELPATH if such a tree-conflict does
+   not already exist. */
 static svn_error_t *
-mark_tree_conflict(struct tc_editor_baton *b,
-                   const char *local_relpath,
+mark_tree_conflict(const char *local_relpath,
+                   svn_wc__db_wcroot_t *wcroot,
+                   svn_wc__db_t *db,
+                   const svn_wc_conflict_version_t *old_version,
+                   const svn_wc_conflict_version_t *new_version,
+                   const char *move_root_dst_relpath,
+                   svn_wc_operation_t operation,
                    svn_node_kind_t old_kind,
                    svn_node_kind_t new_kind,
                    const char *old_repos_relpath,
@@ -228,34 +232,34 @@ mark_tree_conflict(struct tc_editor_bato
 {
   svn_error_t *err;
   svn_skel_t *conflict;
-  svn_wc_conflict_version_t *old_version, *new_version;
+  svn_wc_conflict_version_t *conflict_old_version, *conflict_new_version;
   const char *move_src_op_root_abspath
     = move_src_op_root_relpath
-    ? svn_dirent_join(b->wcroot->abspath,
+    ? svn_dirent_join(wcroot->abspath,
                       move_src_op_root_relpath, scratch_pool)
     : NULL;
   const char *old_repos_relpath_part
     = old_repos_relpath
-    ? svn_relpath_skip_ancestor(b->old_version->path_in_repos,
+    ? svn_relpath_skip_ancestor(old_version->path_in_repos,
                                 old_repos_relpath)
     : NULL;
   const char *new_repos_relpath
     = old_repos_relpath_part
-    ? svn_relpath_join(b->new_version->path_in_repos, old_repos_relpath_part,
+    ? svn_relpath_join(new_version->path_in_repos, old_repos_relpath_part,
                        scratch_pool)
     : NULL;
 
   if (!new_repos_relpath)
     new_repos_relpath
-      = svn_relpath_join(b->new_version->path_in_repos,
-                         svn_relpath_skip_ancestor(b->move_root_dst_relpath,
+      = svn_relpath_join(new_version->path_in_repos,
+                         svn_relpath_skip_ancestor(move_root_dst_relpath,
                                                    local_relpath),
                          scratch_pool);
 
-  err = svn_wc__db_read_conflict_internal(&conflict, b->wcroot, local_relpath,
+  err = svn_wc__db_read_conflict_internal(&conflict, wcroot, local_relpath,
                                           scratch_pool, scratch_pool);
   if (err && err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
-    return err;
+    return svn_error_trace(err);
   else if (err)
     {
       svn_error_clear(err);
@@ -264,16 +268,16 @@ mark_tree_conflict(struct tc_editor_bato
 
   if (conflict)
     {
-      svn_wc_operation_t operation;
+      svn_wc_operation_t conflict_operation;
       svn_boolean_t tree_conflicted;
 
-      SVN_ERR(svn_wc__conflict_read_info(&operation, NULL, NULL, NULL,
+      SVN_ERR(svn_wc__conflict_read_info(&conflict_operation, NULL, NULL, NULL,
                                          &tree_conflicted,
-                                         b->db, b->wcroot->abspath, conflict,
+                                         db, wcroot->abspath, conflict,
                                          scratch_pool, scratch_pool));
 
-      if (operation != svn_wc_operation_update
-          && operation != svn_wc_operation_switch)
+      if (conflict_operation != svn_wc_operation_update
+          && conflict_operation != svn_wc_operation_switch)
         return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
                                  _("'%s' already in conflict"),
                                  svn_dirent_local_style(local_relpath,
@@ -288,7 +292,7 @@ mark_tree_conflict(struct tc_editor_bato
           SVN_ERR(svn_wc__conflict_read_tree_conflict(&existing_reason,
                                                       &existing_action,
                                                       &existing_abspath,
-                                                      b->db, b->wcroot->abspath,
+                                                      db, wcroot->abspath,
                                                       conflict,
                                                       scratch_pool,
                                                       scratch_pool));
@@ -296,7 +300,7 @@ mark_tree_conflict(struct tc_editor_bato
               || action != existing_action
               || (reason == svn_wc_conflict_reason_moved_away
                   && strcmp(move_src_op_root_relpath,
-                            svn_dirent_skip_ancestor(b->wcroot->abspath,
+                            svn_dirent_skip_ancestor(wcroot->abspath,
                                                      existing_abspath))))
             return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
                                      _("'%s' already in conflict"),
@@ -310,11 +314,9 @@ mark_tree_conflict(struct tc_editor_bato
   else
     conflict = svn_wc__conflict_skel_create(scratch_pool);
 
-  b->conflict_root_relpath = apr_pstrdup(b->result_pool, local_relpath);
-
   SVN_ERR(svn_wc__conflict_skel_add_tree_conflict(
-                     conflict, b->db,
-                     svn_dirent_join(b->wcroot->abspath, local_relpath,
+                     conflict, db,
+                     svn_dirent_join(wcroot->abspath, local_relpath,
                                      scratch_pool),
                      reason,
                      action,
@@ -322,48 +324,44 @@ mark_tree_conflict(struct tc_editor_bato
                      scratch_pool,
                      scratch_pool));
 
-  if (reason != svn_wc_conflict_reason_unversioned)
+  if (reason != svn_wc_conflict_reason_unversioned
+      && old_repos_relpath != NULL /* no local additions */)
     {
-      old_version = svn_wc_conflict_version_create2(b->old_version->repos_url,
-                                                    b->old_version->repos_uuid,
-                                                    old_repos_relpath,
-                                                    b->old_version->peg_rev,
-                                                    old_kind,
-                                                    scratch_pool);
+      conflict_old_version = svn_wc_conflict_version_create2(
+                               old_version->repos_url, old_version->repos_uuid,
+                               old_repos_relpath, old_version->peg_rev,
+                               old_kind, scratch_pool);
     }
   else
-    old_version = NULL;
+    conflict_old_version = NULL;
 
-  new_version = svn_wc_conflict_version_create2(b->new_version->repos_url,
-                                                b->new_version->repos_uuid,
-                                                new_repos_relpath,
-                                                b->new_version->peg_rev,
-                                                new_kind,
-                                                scratch_pool);
+  conflict_new_version = svn_wc_conflict_version_create2(
+                           new_version->repos_url, new_version->repos_uuid,
+                           new_repos_relpath, new_version->peg_rev,
+                           new_kind, scratch_pool);
 
-  if (b->operation == svn_wc_operation_update)
+  if (operation == svn_wc_operation_update)
     {
       SVN_ERR(svn_wc__conflict_skel_set_op_update(
-                conflict, old_version, new_version,
+                conflict, conflict_old_version, conflict_new_version,
                 scratch_pool, scratch_pool));
     }
   else
     {
-      assert(b->operation == svn_wc_operation_switch);
+      assert(operation == svn_wc_operation_switch);
       SVN_ERR(svn_wc__conflict_skel_set_op_switch(
-                  conflict, old_version, new_version,
+                  conflict, conflict_old_version, conflict_new_version,
                   scratch_pool, scratch_pool));
     }
 
-  SVN_ERR(svn_wc__db_mark_conflict_internal(b->wcroot, local_relpath,
+  SVN_ERR(svn_wc__db_mark_conflict_internal(wcroot, local_relpath,
                                             conflict, scratch_pool));
 
-  if (b->notify_func)
-    SVN_ERR(update_move_list_add(b->wcroot, local_relpath,
-                                 svn_wc_notify_tree_conflict,
-                                 new_kind,
-                                 svn_wc_notify_state_inapplicable,
-                                 svn_wc_notify_state_inapplicable));
+  SVN_ERR(update_move_list_add(wcroot, local_relpath,
+                               svn_wc_notify_tree_conflict,
+                               new_kind,
+                               svn_wc_notify_state_inapplicable,
+                               svn_wc_notify_state_inapplicable));
   return SVN_NO_ERROR;
 }
 
@@ -437,13 +435,17 @@ check_tree_conflict(svn_boolean_t *is_co
                                        b->wcroot, conflict_root_relpath,
                                        scratch_pool, scratch_pool));
 
-  SVN_ERR(mark_tree_conflict(b, conflict_root_relpath, old_kind, new_kind,
+  SVN_ERR(mark_tree_conflict(conflict_root_relpath,
+                             b->wcroot, b->db, b->old_version, b->new_version,
+                             b->move_root_dst_relpath, b->operation,
+                             old_kind, new_kind,
                              old_repos_relpath,
                              (move_dst_relpath
                               ? svn_wc_conflict_reason_moved_away
                               : svn_wc_conflict_reason_deleted),
                              action, move_src_op_root_relpath,
                              scratch_pool));
+  b->conflict_root_relpath = apr_pstrdup(b->result_pool, conflict_root_relpath);
 
   return SVN_NO_ERROR;
 }
@@ -459,7 +461,7 @@ tc_editor_add_directory(void *baton,
   struct tc_editor_baton *b = baton;
   int op_depth = relpath_depth(b->move_root_dst_relpath);
   const char *move_dst_repos_relpath;
-  svn_kind_t move_dst_kind;
+  svn_node_kind_t move_dst_kind;
   svn_boolean_t is_conflicted;
   const char *abspath;
   svn_node_kind_t old_kind;
@@ -469,7 +471,7 @@ tc_editor_add_directory(void *baton,
 
   /* Update NODES, only the bits not covered by the later call to
      replace_moved_layer. */
-  SVN_ERR(svn_wc__db_extend_parent_delete(b->wcroot, relpath, svn_kind_dir,
+  SVN_ERR(svn_wc__db_extend_parent_delete(b->wcroot, relpath, svn_node_dir,
                                           op_depth, scratch_pool));
 
   err = svn_wc__db_depth_get_info(NULL, &move_dst_kind, NULL,
@@ -481,18 +483,18 @@ tc_editor_add_directory(void *baton,
   if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
     {
       svn_error_clear(err);
-      old_kind = svn_kind_none;
+      old_kind = svn_node_none;
       move_dst_repos_relpath = NULL;
     }
   else
     {
       SVN_ERR(err);
-      old_kind = svn__node_kind_from_kind(move_dst_kind);
+      old_kind = move_dst_kind;
     }
 
   /* Check for NODES tree-conflict. */
   SVN_ERR(check_tree_conflict(&is_conflicted, b, relpath,
-                              move_dst_kind, svn_node_dir,
+                              old_kind, svn_node_dir,
                               move_dst_repos_relpath,
                               svn_wc_conflict_action_add,
                               scratch_pool));
@@ -507,17 +509,21 @@ tc_editor_add_directory(void *baton,
     {
     case svn_node_file:
     default:
-      SVN_ERR(mark_tree_conflict(b, relpath, old_kind, svn_node_dir,
+      SVN_ERR(mark_tree_conflict(relpath, b->wcroot, b->db, b->old_version,
+                                 b->new_version, b->move_root_dst_relpath,
+                                 b->operation, old_kind, svn_node_dir,
                                  move_dst_repos_relpath,
                                  svn_wc_conflict_reason_unversioned,
                                  svn_wc_conflict_action_add, NULL,
                                  scratch_pool));
+      b->conflict_root_relpath = apr_pstrdup(b->result_pool, relpath);
       action = svn_wc_notify_tree_conflict;
+      is_conflicted = TRUE;
       break;
 
     case svn_node_none:
       SVN_ERR(svn_wc__wq_build_dir_install(&work_item, b->db, abspath,
-                                           scratch_pool, b->result_pool));
+                                           scratch_pool, scratch_pool));
 
       SVN_ERR(svn_wc__db_wq_add(b->db, b->wcroot->abspath, work_item,
                                 scratch_pool));
@@ -526,7 +532,7 @@ tc_editor_add_directory(void *baton,
       break;
     }
 
-  if (b->notify_func)
+  if (!is_conflicted)
     SVN_ERR(update_move_list_add(b->wcroot, relpath,
                                  action,
                                  svn_node_dir,
@@ -547,7 +553,7 @@ tc_editor_add_file(void *baton,
   struct tc_editor_baton *b = baton;
   int op_depth = relpath_depth(b->move_root_dst_relpath);
   const char *move_dst_repos_relpath;
-  svn_kind_t move_dst_kind;
+  svn_node_kind_t move_dst_kind;
   svn_node_kind_t old_kind;
   svn_boolean_t is_conflicted;
   const char *abspath;
@@ -556,7 +562,7 @@ tc_editor_add_file(void *baton,
 
   /* Update NODES, only the bits not covered by the later call to
      replace_moved_layer. */
-  SVN_ERR(svn_wc__db_extend_parent_delete(b->wcroot, relpath, svn_kind_file,
+  SVN_ERR(svn_wc__db_extend_parent_delete(b->wcroot, relpath, svn_node_file,
                                           op_depth, scratch_pool));
 
   err = svn_wc__db_depth_get_info(NULL, &move_dst_kind, NULL,
@@ -568,13 +574,13 @@ tc_editor_add_file(void *baton,
   if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
     {
       svn_error_clear(err);
-      old_kind = svn_kind_none;
+      old_kind = svn_node_none;
       move_dst_repos_relpath = NULL;
     }
   else
     {
       SVN_ERR(err);
-      old_kind = svn__node_kind_from_kind(move_dst_kind);
+      old_kind = move_dst_kind;
     }
   
   /* Check for NODES tree-conflict. */
@@ -591,11 +597,14 @@ tc_editor_add_file(void *baton,
 
   if (old_kind != svn_node_none)
     {
-      SVN_ERR(mark_tree_conflict(b, relpath, old_kind, svn_node_file,
+      SVN_ERR(mark_tree_conflict(relpath, b->wcroot, b->db, b->old_version,
+                                 b->new_version, b->move_root_dst_relpath,
+                                 b->operation, old_kind, svn_node_file,
                                  move_dst_repos_relpath,
                                  svn_wc_conflict_reason_unversioned,
                                  svn_wc_conflict_action_add, NULL,
                                  scratch_pool));
+      b->conflict_root_relpath = apr_pstrdup(b->result_pool, relpath);
       return SVN_NO_ERROR;
     }
 
@@ -607,17 +616,16 @@ tc_editor_add_file(void *baton,
                                         NULL,
                                         FALSE /* FIXME: use_commit_times? */,
                                         TRUE  /* record_file_info */,
-                                        scratch_pool, b->result_pool));
+                                        scratch_pool, scratch_pool));
 
   SVN_ERR(svn_wc__db_wq_add(b->db, b->wcroot->abspath, work_item,
                             scratch_pool));
 
-  if (b->notify_func)
-    SVN_ERR(update_move_list_add(b->wcroot, relpath,
-                                 svn_wc_notify_update_add,
-                                 svn_node_file,
-                                 svn_wc_notify_state_inapplicable,
-                                 svn_wc_notify_state_inapplicable));
+  SVN_ERR(update_move_list_add(b->wcroot, relpath,
+                               svn_wc_notify_update_add,
+                               svn_node_file,
+                               svn_wc_notify_state_inapplicable,
+                               svn_wc_notify_state_inapplicable));
   return SVN_NO_ERROR;
 }
 
@@ -635,7 +643,7 @@ tc_editor_add_symlink(void *baton,
 static svn_error_t *
 tc_editor_add_absent(void *baton,
                      const char *relpath,
-                     svn_kind_t kind,
+                     svn_node_kind_t kind,
                      svn_revnum_t replaces_rev,
                      apr_pool_t *scratch_pool)
 {
@@ -650,6 +658,7 @@ typedef struct working_node_version_t
   const svn_checksum_t *checksum; /* for files only */
 } working_node_version_t;
 
+/* Return *WORK_ITEMS to create a conflict on LOCAL_ABSPATH. */
 static svn_error_t *
 create_conflict_markers(svn_skel_t **work_items,
                         const char *local_abspath,
@@ -659,21 +668,26 @@ create_conflict_markers(svn_skel_t **wor
                         svn_wc_operation_t operation,
                         const working_node_version_t *old_version,
                         const working_node_version_t *new_version,
-                        svn_kind_t local_kind,
+                        svn_node_kind_t kind,
                         apr_pool_t *result_pool,
                         apr_pool_t *scratch_pool)
 {
-  svn_skel_t *work_item;
   svn_wc_conflict_version_t *original_version;
   svn_wc_conflict_version_t *conflicted_version;
+  const char *part;
 
   original_version = svn_wc_conflict_version_dup(
                        old_version->location_and_kind, scratch_pool);
-  original_version->path_in_repos = repos_relpath;
-
+  original_version->node_kind = kind;
   conflicted_version = svn_wc_conflict_version_dup(
                          new_version->location_and_kind, scratch_pool);
-  conflicted_version->node_kind = svn__node_kind_from_kind(local_kind);
+  conflicted_version->node_kind = kind;
+
+  part = svn_relpath_skip_ancestor(original_version->path_in_repos,
+                                   repos_relpath);
+  conflicted_version->path_in_repos
+    = svn_relpath_join(conflicted_version->path_in_repos, part, scratch_pool);
+  original_version->path_in_repos = repos_relpath;
 
   if (operation == svn_wc_operation_update)
     {
@@ -692,12 +706,11 @@ create_conflict_markers(svn_skel_t **wor
 
   /* According to this func's doc string, it is "Currently only used for
    * property conflicts as text conflict markers are just in-wc files." */
-  SVN_ERR(svn_wc__conflict_create_markers(&work_item, db,
+  SVN_ERR(svn_wc__conflict_create_markers(work_items, db,
                                           local_abspath,
                                           conflict_skel,
                                           result_pool,
                                           scratch_pool));
-  *work_items = svn_wc__wq_merge(*work_items, work_item, result_pool);
 
   return SVN_NO_ERROR;
 }
@@ -768,7 +781,7 @@ tc_editor_alter_directory(void *baton,
   struct tc_editor_baton *b = baton;
   const char *move_dst_repos_relpath;
   svn_revnum_t move_dst_revision;
-  svn_kind_t move_dst_kind;
+  svn_node_kind_t move_dst_kind;
   working_node_version_t old_version, new_version;
   svn_wc__db_status_t status;
   svn_boolean_t is_conflicted;
@@ -782,11 +795,23 @@ tc_editor_alter_directory(void *baton,
                                     b->wcroot, dst_relpath,
                                     relpath_depth(b->move_root_dst_relpath),
                                     scratch_pool, scratch_pool));
-  SVN_ERR_ASSERT(move_dst_revision == expected_move_dst_revision);
-  SVN_ERR_ASSERT(move_dst_kind == svn_kind_dir);
+
+  /* If the node would be recorded as svn_wc__db_status_base_deleted it
+     wouldn't have a repos_relpath */
+  /* ### Can svn_wc__db_depth_get_info() do this for us without this hint? */
+  if (status == svn_wc__db_status_deleted && move_dst_repos_relpath)
+    status = svn_wc__db_status_not_present;
+
+  /* There might be not-present nodes of a different revision as the same
+     depth as a copy. This is commonly caused by copying/moving mixed revision
+     directories */
+  SVN_ERR_ASSERT(move_dst_revision == expected_move_dst_revision
+                 || status == svn_wc__db_status_not_present);
+  SVN_ERR_ASSERT(move_dst_kind == svn_node_dir);
 
   SVN_ERR(check_tree_conflict(&is_conflicted, b, dst_relpath,
-                              move_dst_kind, svn_node_dir,
+                              move_dst_kind,
+                              svn_node_dir,
                               move_dst_repos_relpath,
                               svn_wc_conflict_action_edit,
                               scratch_pool));
@@ -813,27 +838,30 @@ tc_editor_alter_directory(void *baton,
                                    &propchanges, &actual_props,
                                    b->db, dst_abspath,
                                    &old_version, &new_version,
-                                   b->result_pool, scratch_pool));
+                                   scratch_pool, scratch_pool));
 
       if (conflict_skel)
         {
-          SVN_ERR(create_conflict_markers(b->work_items, dst_abspath,
+          svn_skel_t *work_items;
+
+          SVN_ERR(create_conflict_markers(&work_items, dst_abspath,
                                           b->db, move_dst_repos_relpath,
                                           conflict_skel, b->operation,
                                           &old_version, &new_version,
-                                          move_dst_kind,
-                                          b->result_pool, scratch_pool));
+                                          svn_node_dir,
+                                          scratch_pool, scratch_pool));
           SVN_ERR(svn_wc__db_mark_conflict_internal(b->wcroot, dst_relpath,
                                                     conflict_skel,
                                                     scratch_pool));
+          SVN_ERR(svn_wc__db_wq_add(b->db, b->wcroot->abspath, work_items,
+                                    scratch_pool));
         }
 
-      if (b->notify_func)
-        SVN_ERR(update_move_list_add(b->wcroot, dst_relpath,
-                                     svn_wc_notify_update_update,
-                                     svn_node_dir,
-                                     svn_wc_notify_state_inapplicable,
-                                     prop_state));
+    SVN_ERR(update_move_list_add(b->wcroot, dst_relpath,
+                                 svn_wc_notify_update_update,
+                                 svn_node_dir,
+                                 svn_wc_notify_state_inapplicable,
+                                 prop_state));
     }
 
   return SVN_NO_ERROR;
@@ -855,17 +883,13 @@ tc_editor_alter_directory(void *baton,
  * Set *WORK_ITEMS to any required work items, allocated in RESULT_POOL.
  * Use SCRATCH_POOL for temporary allocations. */
 static svn_error_t *
-update_working_file(svn_skel_t **work_items,
-                    const char *local_relpath,
+update_working_file(const char *local_relpath,
                     const char *repos_relpath,
                     svn_wc_operation_t operation,
                     const working_node_version_t *old_version,
                     const working_node_version_t *new_version,
                     svn_wc__db_wcroot_t *wcroot,
                     svn_wc__db_t *db,
-                    svn_wc_notify_func2_t notify_func,
-                    void *notify_baton,
-                    apr_pool_t *result_pool,
                     apr_pool_t *scratch_pool)
 {
   const char *local_abspath = svn_dirent_join(wcroot->abspath,
@@ -878,84 +902,100 @@ update_working_file(svn_skel_t **work_it
   apr_array_header_t *propchanges;
   enum svn_wc_merge_outcome_t merge_outcome;
   svn_wc_notify_state_t prop_state, content_state;
-  svn_skel_t *work_item;
-
-  *work_items = NULL;
+  svn_skel_t *work_item, *work_items = NULL;
 
   SVN_ERR(update_working_props(&prop_state, &conflict_skel, &propchanges,
                                &actual_props, db, local_abspath,
                                old_version, new_version,
-                               result_pool, scratch_pool));
+                               scratch_pool, scratch_pool));
 
-  /*
-   * Run a 3-way merge to update the file, using the pre-update
-   * pristine text as the merge base, the post-update pristine
-   * text as the merge-left version, and the current content of the
-   * moved-here working file as the merge-right version.
-   */
-  SVN_ERR(svn_wc__db_pristine_get_path(&old_pristine_abspath,
-                                       db, wcroot->abspath,
-                                       old_version->checksum,
-                                       scratch_pool, scratch_pool));
-  SVN_ERR(svn_wc__db_pristine_get_path(&new_pristine_abspath,
-                                       db, wcroot->abspath,
-                                       new_version->checksum,
-                                       scratch_pool, scratch_pool));
-  SVN_ERR(svn_wc__internal_merge(&work_item, &conflict_skel,
-                                 &merge_outcome, db,
-                                 old_pristine_abspath,
-                                 new_pristine_abspath,
-                                 local_abspath,
-                                 local_abspath,
-                                 NULL, NULL, NULL, /* diff labels */
-                                 actual_props,
-                                 FALSE, /* dry-run */
-                                 NULL, /* diff3-cmd */
-                                 NULL, /* merge options */
-                                 propchanges,
-                                 NULL, NULL, /* cancel_func + baton */
-                                 result_pool, scratch_pool));
+  if (!svn_checksum_match(new_version->checksum, old_version->checksum))
+    {
+      svn_boolean_t is_locally_modified;
 
-  *work_items = svn_wc__wq_merge(*work_items, work_item, result_pool);
+      SVN_ERR(svn_wc__internal_file_modified_p(&is_locally_modified,
+                                               db, local_abspath,
+                                               FALSE /* exact_comparison */,
+                                               scratch_pool));
+      if (!is_locally_modified)
+        {
+          SVN_ERR(svn_wc__wq_build_file_install(&work_item, db,
+                                                local_abspath,
+                                                NULL,
+                                                FALSE /* FIXME: use_commit_times? */,
+                                                TRUE  /* record_file_info */,
+                                                scratch_pool, scratch_pool));
+
+          work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+
+          content_state = svn_wc_notify_state_changed;
+        }
+      else
+        {
+          /*
+           * Run a 3-way merge to update the file, using the pre-update
+           * pristine text as the merge base, the post-update pristine
+           * text as the merge-left version, and the current content of the
+           * moved-here working file as the merge-right version.
+           */
+          SVN_ERR(svn_wc__db_pristine_get_path(&old_pristine_abspath,
+                                               db, wcroot->abspath,
+                                               old_version->checksum,
+                                               scratch_pool, scratch_pool));
+          SVN_ERR(svn_wc__db_pristine_get_path(&new_pristine_abspath,
+                                               db, wcroot->abspath,
+                                               new_version->checksum,
+                                               scratch_pool, scratch_pool));
+          SVN_ERR(svn_wc__internal_merge(&work_item, &conflict_skel,
+                                         &merge_outcome, db,
+                                         old_pristine_abspath,
+                                         new_pristine_abspath,
+                                         local_abspath,
+                                         local_abspath,
+                                         NULL, NULL, NULL, /* diff labels */
+                                         actual_props,
+                                         FALSE, /* dry-run */
+                                         NULL, /* diff3-cmd */
+                                         NULL, /* merge options */
+                                         propchanges,
+                                         NULL, NULL, /* cancel_func + baton */
+                                         scratch_pool, scratch_pool));
+
+          work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+
+          if (merge_outcome == svn_wc_merge_conflict)
+            content_state = svn_wc_notify_state_conflicted;
+          else
+            content_state = svn_wc_notify_state_merged;
+        }
+    }
+  else
+    content_state = svn_wc_notify_state_unchanged;
 
   /* If there are any conflicts to be stored, convert them into work items
    * too. */
   if (conflict_skel)
     {
-      SVN_ERR(create_conflict_markers(work_items, local_abspath, db,
+      SVN_ERR(create_conflict_markers(&work_item, local_abspath, db,
                                       repos_relpath, conflict_skel,
                                       operation, old_version, new_version,
-                                      svn_kind_file,
-                                      result_pool, scratch_pool));
+                                      svn_node_file,
+                                      scratch_pool, scratch_pool));
+
       SVN_ERR(svn_wc__db_mark_conflict_internal(wcroot, local_relpath,
                                                 conflict_skel,
                                                 scratch_pool));
-    }
 
-  if (merge_outcome == svn_wc_merge_conflict)
-    {
-      content_state = svn_wc_notify_state_conflicted;
+      work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
     }
-  else
-    {
-      svn_boolean_t is_locally_modified;
 
-      SVN_ERR(svn_wc__internal_file_modified_p(&is_locally_modified,
-                                               db, local_abspath,
-                                               FALSE /* exact_comparison */,
-                                               scratch_pool));
-      if (is_locally_modified)
-        content_state = svn_wc_notify_state_merged;
-      else
-        content_state = svn_wc_notify_state_changed;
-    }
+  SVN_ERR(svn_wc__db_wq_add(db, wcroot->abspath, work_items, scratch_pool));
 
-  if (notify_func)
-    SVN_ERR(update_move_list_add(wcroot, local_relpath,
-                                 svn_wc_notify_update_update,
-                                 svn_node_file,
-                                 content_state,
-                                 prop_state));
+  SVN_ERR(update_move_list_add(wcroot, local_relpath,
+                               svn_wc_notify_update_update,
+                               svn_node_file,
+                               content_state,
+                               prop_state));
 
   return SVN_NO_ERROR;
 }
@@ -976,22 +1016,32 @@ tc_editor_alter_file(void *baton,
   struct tc_editor_baton *b = baton;
   const char *move_dst_repos_relpath;
   svn_revnum_t move_dst_revision;
-  svn_kind_t move_dst_kind;
+  svn_node_kind_t move_dst_kind;
   working_node_version_t old_version, new_version;
   svn_boolean_t is_conflicted;
+  svn_wc__db_status_t status;
 
-  SVN_ERR(svn_wc__db_depth_get_info(NULL, &move_dst_kind, &move_dst_revision,
+  SVN_ERR(svn_wc__db_depth_get_info(&status, &move_dst_kind, &move_dst_revision,
                                     &move_dst_repos_relpath, NULL, NULL, NULL,
                                     NULL, NULL, &old_version.checksum, NULL,
                                     NULL, &old_version.props,
                                     b->wcroot, dst_relpath,
                                     relpath_depth(b->move_root_dst_relpath),
                                     scratch_pool, scratch_pool));
-  SVN_ERR_ASSERT(move_dst_revision == expected_move_dst_revision);
-  SVN_ERR_ASSERT(move_dst_kind == svn_kind_file);
+
+  /* If the node would be recorded as svn_wc__db_status_base_deleted it
+     wouldn't have a repos_relpath */
+  /* ### Can svn_wc__db_depth_get_info() do this for us without this hint? */
+  if (status == svn_wc__db_status_deleted && move_dst_repos_relpath)
+    status = svn_wc__db_status_not_present;
+
+  SVN_ERR_ASSERT(move_dst_revision == expected_move_dst_revision
+                 || status == svn_wc__db_status_not_present);
+  SVN_ERR_ASSERT(move_dst_kind == svn_node_file);
 
   SVN_ERR(check_tree_conflict(&is_conflicted, b, dst_relpath,
-                              move_dst_kind, svn_node_file,
+                              move_dst_kind,
+                              svn_node_file,
                               move_dst_repos_relpath,
                               svn_wc_conflict_action_edit,
                               scratch_pool));
@@ -1008,16 +1058,10 @@ tc_editor_alter_file(void *baton,
   /* Update file and prop contents if the update has changed them. */
   if (!svn_checksum_match(new_checksum, old_version.checksum) || new_props)
     {
-      svn_skel_t *work_items;
-
-      SVN_ERR(update_working_file(&work_items, dst_relpath,
-                                  move_dst_repos_relpath,
+      SVN_ERR(update_working_file(dst_relpath, move_dst_repos_relpath,
                                   b->operation, &old_version, &new_version,
                                   b->wcroot, b->db,
-                                  b->notify_func, b->notify_baton,
-                                  b->result_pool, scratch_pool));
-      *b->work_items = svn_wc__wq_merge(*b->work_items, work_items,
-                                        b->result_pool);
+                                  scratch_pool));
     }
 
   return SVN_NO_ERROR;
@@ -1044,11 +1088,14 @@ tc_editor_delete(void *baton,
   svn_sqlite__stmt_t *stmt;
   int op_depth = relpath_depth(b->move_root_dst_relpath);
   const char *move_dst_repos_relpath;
-  svn_kind_t move_dst_kind;
+  svn_node_kind_t move_dst_kind;
   svn_boolean_t is_conflicted;
   svn_boolean_t must_delete_working_nodes = FALSE;
   const char *local_abspath = svn_dirent_join(b->wcroot->abspath, relpath,
                                               scratch_pool);
+  const char *parent_relpath = svn_relpath_dirname(relpath, scratch_pool);
+  int op_depth_below;
+  svn_boolean_t have_row;
 
   SVN_ERR(svn_wc__db_depth_get_info(NULL, &move_dst_kind, NULL,
                                     &move_dst_repos_relpath, NULL, NULL, NULL,
@@ -1061,7 +1108,8 @@ tc_editor_delete(void *baton,
      conflicts. This catches conflicts on the node itself; deleted
      children are caught as local modifications below.*/
   SVN_ERR(check_tree_conflict(&is_conflicted, b, relpath,
-                              move_dst_kind, svn_node_unknown,
+                              move_dst_kind,
+                              svn_node_unknown,
                               move_dst_repos_relpath,
                               svn_wc_conflict_action_delete,
                               scratch_pool));
@@ -1102,19 +1150,23 @@ tc_editor_delete(void *baton,
               must_delete_working_nodes = TRUE;
             }
           is_conflicted = TRUE;
-          SVN_ERR(mark_tree_conflict(b, relpath, move_dst_kind, svn_node_none,
+          SVN_ERR(mark_tree_conflict(relpath, b->wcroot, b->db, b->old_version,
+                                     b->new_version, b->move_root_dst_relpath,
+                                     b->operation,
+                                     move_dst_kind,
+                                     svn_node_none,
                                      move_dst_repos_relpath, reason,
                                      svn_wc_conflict_action_delete, NULL,
                                      scratch_pool));
+          b->conflict_root_relpath = apr_pstrdup(b->result_pool, relpath);
         }
     }
 
   if (!is_conflicted || must_delete_working_nodes)
     {
-      svn_boolean_t have_row;
       apr_pool_t *iterpool = svn_pool_create(scratch_pool);
       svn_skel_t *work_item;
-      svn_kind_t del_kind;
+      svn_node_kind_t del_kind;
       const char *del_abspath;
 
       SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
@@ -1132,7 +1184,7 @@ tc_editor_delete(void *baton,
           del_abspath = svn_dirent_join(b->wcroot->abspath,
                                         svn_sqlite__column_text(stmt, 0, NULL),
                                         iterpool);
-          if (del_kind == svn_kind_dir)
+          if (del_kind == svn_node_dir)
             err = svn_wc__wq_build_dir_remove(&work_item, b->db,
                                               b->wcroot->abspath, del_abspath,
                                               FALSE /* recursive */,
@@ -1156,7 +1208,7 @@ tc_editor_delete(void *baton,
                                         NULL, NULL,
                                         b->wcroot, relpath, op_depth,
                                         iterpool, iterpool));
-      if (del_kind == svn_kind_dir)
+      if (del_kind == svn_node_dir)
         SVN_ERR(svn_wc__wq_build_dir_remove(&work_item, b->db,
                                             b->wcroot->abspath, local_abspath,
                                             FALSE /* recursive */,
@@ -1168,21 +1220,51 @@ tc_editor_delete(void *baton,
       SVN_ERR(svn_wc__db_wq_add(b->db, b->wcroot->abspath, work_item,
                                 iterpool));
 
-      if (b->notify_func && !is_conflicted)
+      if (!is_conflicted)
         SVN_ERR(update_move_list_add(b->wcroot, relpath,
                                      svn_wc_notify_update_delete,
-                                     svn__node_kind_from_kind(del_kind),
+                                     del_kind,
                                      svn_wc_notify_state_inapplicable,
                                      svn_wc_notify_state_inapplicable));
       svn_pool_destroy(iterpool);
     }
 
   /* Deleting the ROWS is valid so long as we update the parent before
-     committing the transaction. */
+     committing the transaction.  The removed rows could have been
+     replacing a lower layer in which case we need to add base-deleted
+     rows. */
   SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
-                                    STMT_DELETE_WORKING_OP_DEPTH));
-  SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, relpath, op_depth));
-  SVN_ERR(svn_sqlite__step_done(stmt));
+                                    STMT_SELECT_HIGHEST_WORKING_NODE));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, parent_relpath,
+                            op_depth));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  if (have_row)
+    op_depth_below = svn_sqlite__column_int(stmt, 0);
+  SVN_ERR(svn_sqlite__reset(stmt));
+  if (have_row)
+    {
+      /* Remove non-shadowing nodes. */
+      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
+                                        STMT_DELETE_NO_LOWER_LAYER));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isdd", b->wcroot->wc_id, relpath,
+                                op_depth, op_depth_below));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+
+      /* Convert remaining shadowing nodes to presence='base-deleted'. */
+      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
+                                        STMT_REPLACE_WITH_BASE_DELETED));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, relpath,
+                                op_depth));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+    }
+  else
+    {
+      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
+                                        STMT_DELETE_WORKING_OP_DEPTH));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isd", b->wcroot->wc_id, relpath,
+                                op_depth));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+    }
 
   /* Retract any base-delete. */
   SVN_ERR(svn_wc__db_retract_parent_delete(b->wcroot, relpath, op_depth,
@@ -1226,34 +1308,6 @@ static svn_error_t *
 tc_editor_complete(void *baton,
                    apr_pool_t *scratch_pool)
 {
-  struct tc_editor_baton *b = baton;
-
-  /* Send all queued up notifications.
-
-     ### This is notifying too early.  One reason for using the
-     ### update_move_list is to do the notifications after the
-     ### transaction has completeted. */
-  SVN_ERR(update_move_list_notify(b->wcroot,
-                                  b->old_version->peg_rev,
-                                  b->new_version->peg_rev,
-                                  b->notify_func, b->notify_baton,
-                                  scratch_pool));
-  if (b->notify_func)
-    {
-      svn_wc_notify_t *notify;
-
-      notify = svn_wc_create_notify(svn_dirent_join(b->wcroot->abspath,
-                                                    b->move_root_dst_relpath,
-                                                    scratch_pool),
-                                    svn_wc_notify_update_completed,
-                                    scratch_pool);
-      notify->kind = svn_node_none;
-      notify->content_state = svn_wc_notify_state_inapplicable;
-      notify->prop_state = svn_wc_notify_state_inapplicable;
-      notify->revision = b->new_version->peg_rev;
-      b->notify_func(b->notify_baton, notify, scratch_pool);
-    }
-
   return SVN_NO_ERROR;
 }
 
@@ -1363,7 +1417,7 @@ get_tc_info(svn_wc_operation_t *operatio
 }
 
 /* Return *PROPS, *CHECKSUM, *CHILDREN and *KIND for LOCAL_RELPATH at
-   OP_DEPTH provided the row exists.  Return *KIND of svn_kind_none if
+   OP_DEPTH provided the row exists.  Return *KIND of svn_node_none if
    the row does not exist. *CHILDREN is a sorted array of basenames of
    type 'const char *', rather than a hash, to allow the driver to
    process children in a defined order. */
@@ -1371,7 +1425,7 @@ static svn_error_t *
 get_info(apr_hash_t **props,
          const svn_checksum_t **checksum,
          apr_array_header_t **children,
-         svn_kind_t *kind,
+         svn_node_kind_t *kind,
          const char *local_relpath,
          int op_depth,
          svn_wc__db_wcroot_t *wcroot,
@@ -1390,7 +1444,7 @@ get_info(apr_hash_t **props,
   if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
     {
       svn_error_clear(err);
-      *kind = svn_kind_none;
+      *kind = svn_node_none;
     }
   else
     SVN_ERR(err);
@@ -1474,7 +1528,7 @@ update_moved_away_node(svn_editor_t *tc_
                        svn_wc__db_wcroot_t *wcroot,
                        apr_pool_t *scratch_pool)
 {
-  svn_kind_t src_kind, dst_kind;
+  svn_node_kind_t src_kind, dst_kind;
   const svn_checksum_t *src_checksum, *dst_checksum;
   apr_hash_t *src_props, *dst_props;
   apr_array_header_t *src_children, *dst_children;
@@ -1488,16 +1542,16 @@ update_moved_away_node(svn_editor_t *tc_
                    dst_relpath, dst_op_depth,
                    wcroot, scratch_pool, scratch_pool));
 
-  if (src_kind == svn_kind_none
-      || (dst_kind != svn_kind_none && src_kind != dst_kind))
+  if (src_kind == svn_node_none
+      || (dst_kind != svn_node_none && src_kind != dst_kind))
     {
       SVN_ERR(svn_editor_delete(tc_editor, dst_relpath,
                                 move_root_dst_revision));
     }
  
-  if (src_kind != svn_kind_none && src_kind != dst_kind)
+  if (src_kind != svn_node_none && src_kind != dst_kind)
     {
-      if (src_kind == svn_kind_file || src_kind == svn_kind_symlink)
+      if (src_kind == svn_node_file || src_kind == svn_node_symlink)
         {
           svn_stream_t *contents;
 
@@ -1508,14 +1562,14 @@ update_moved_away_node(svn_editor_t *tc_
                                       src_checksum, contents, src_props,
                                       move_root_dst_revision));
         }
-      else if (src_kind == svn_kind_dir)
+      else if (src_kind == svn_node_dir)
         {
           SVN_ERR(svn_editor_add_directory(tc_editor, dst_relpath,
                                            src_children, src_props,
                                            move_root_dst_revision));
         }
     }
-  else if (src_kind != svn_kind_none)
+  else if (src_kind != svn_node_none)
     {
       svn_boolean_t match;
       apr_hash_t *props;
@@ -1524,7 +1578,7 @@ update_moved_away_node(svn_editor_t *tc_
       props = match ? NULL: src_props;
 
       
-      if (src_kind == svn_kind_file || src_kind == svn_kind_symlink)
+      if (src_kind == svn_node_file || src_kind == svn_node_symlink)
         {
           svn_stream_t *contents;
 
@@ -1543,7 +1597,7 @@ update_moved_away_node(svn_editor_t *tc_
                                           move_root_dst_revision,
                                           props, src_checksum, contents));
         }
-      else if (src_kind == svn_kind_dir)
+      else if (src_kind == svn_node_dir)
         {
           apr_array_header_t *children
             = children_match(src_children, dst_children) ? NULL : src_children;
@@ -1555,7 +1609,7 @@ update_moved_away_node(svn_editor_t *tc_
         }
     }
 
-  if (src_kind == svn_kind_dir)
+  if (src_kind == svn_node_dir)
     {
       apr_pool_t *iterpool = svn_pool_create(scratch_pool);
       int i = 0, j = 0;
@@ -1759,15 +1813,28 @@ suitable_for_move(svn_wc__db_wcroot_t *w
       relpath = svn_relpath_skip_ancestor(local_relpath, relpath);
       relpath = svn_relpath_join(repos_relpath, relpath, iterpool);
 
-      if (revision != node_revision
-          || strcmp(relpath, svn_sqlite__column_text(stmt, 1, NULL)))
+      if (revision != node_revision)
         return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE,
                                  svn_sqlite__reset(stmt),
-                      _("The tree '%s' is not single-revision and unswitched"),
-                        svn_dirent_local_style(svn_dirent_join(wcroot->abspath,
-                                                               local_relpath,
-                                                               scratch_pool),
-                                               scratch_pool));
+                                 _("Cannot apply update because move source "
+                                   "%s' is a mixed-revision working copy"), 
+                                 svn_dirent_local_style(svn_dirent_join(
+                                                          wcroot->abspath,
+                                                          local_relpath,
+                                                          scratch_pool),
+                                 scratch_pool));
+
+      if (strcmp(relpath, svn_sqlite__column_text(stmt, 1, NULL)))
+        return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE,
+                                 svn_sqlite__reset(stmt),
+                                 _("Cannot apply update because move source "
+                                   "'%s' is a switched subtree"), 
+                                 svn_dirent_local_style(svn_dirent_join(
+                                                          wcroot->abspath,
+                                                          local_relpath,
+                                                          scratch_pool),
+                                 scratch_pool));
+
       SVN_ERR(svn_sqlite__step(&have_row, stmt));
     }
   SVN_ERR(svn_sqlite__reset(stmt));
@@ -1780,8 +1847,7 @@ suitable_for_move(svn_wc__db_wcroot_t *w
 /* The body of svn_wc__db_update_moved_away_conflict_victim(), which see.
  */
 static svn_error_t *
-update_moved_away_conflict_victim(svn_skel_t **work_items,
-                                  svn_wc__db_t *db,
+update_moved_away_conflict_victim(svn_wc__db_t *db,
                                   svn_wc__db_wcroot_t *wcroot,
                                   const char *victim_relpath,
                                   svn_wc_operation_t operation,
@@ -1790,11 +1856,8 @@ update_moved_away_conflict_victim(svn_sk
                                   const char *move_src_op_root_relpath,
                                   svn_wc_conflict_version_t *old_version,
                                   svn_wc_conflict_version_t *new_version,
-                                  svn_wc_notify_func2_t notify_func,
-                                  void *notify_baton,
                                   svn_cancel_func_t cancel_func,
                                   void *cancel_baton,
-                                  apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool)
 {
   svn_editor_t *tc_editor;
@@ -1803,6 +1866,7 @@ update_moved_away_conflict_victim(svn_sk
   svn_boolean_t have_row;
   const char *dummy1, *dummy2, *dummy3;
   int src_op_depth;
+  const char *move_root_dst_abspath;
 
   /* ### assumes wc write lock already held */
 
@@ -1819,15 +1883,18 @@ update_moved_away_conflict_victim(svn_sk
                                svn_dirent_join(wcroot->abspath, victim_relpath,
                                                scratch_pool),
                                scratch_pool));
+
+  move_root_dst_abspath
+    = svn_dirent_join(wcroot->abspath, tc_editor_baton->move_root_dst_relpath,
+                      scratch_pool);
+  SVN_ERR(svn_wc__write_check(db, move_root_dst_abspath, scratch_pool));
+
   tc_editor_baton->operation = operation;
   tc_editor_baton->old_version= old_version;
   tc_editor_baton->new_version= new_version;
   tc_editor_baton->db = db;
   tc_editor_baton->wcroot = wcroot;
-  tc_editor_baton->work_items = work_items;
-  tc_editor_baton->notify_func = notify_func;
-  tc_editor_baton->notify_baton = notify_baton;
-  tc_editor_baton->result_pool = result_pool;
+  tc_editor_baton->result_pool = scratch_pool;
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_SELECT_HIGHEST_WORKING_NODE));
@@ -1876,14 +1943,12 @@ update_moved_away_conflict_victim(svn_sk
 
 
 svn_error_t *
-svn_wc__db_update_moved_away_conflict_victim(svn_skel_t **work_items,
-                                             svn_wc__db_t *db,
+svn_wc__db_update_moved_away_conflict_victim(svn_wc__db_t *db,
                                              const char *victim_abspath,
                                              svn_wc_notify_func2_t notify_func,
                                              void *notify_baton,
                                              svn_cancel_func_t cancel_func,
                                              void *cancel_baton,
-                                             apr_pool_t *result_pool,
                                              apr_pool_t *scratch_pool)
 {
   svn_wc__db_wcroot_t *wcroot;
@@ -1901,6 +1966,8 @@ svn_wc__db_update_moved_away_conflict_vi
                       db, victim_abspath,
                       scratch_pool, scratch_pool));
 
+  SVN_ERR(svn_wc__write_check(db, move_src_op_root_abspath, scratch_pool));
+
   SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath,
                                                 db, victim_abspath,
                                                 scratch_pool, scratch_pool));
@@ -1911,15 +1978,157 @@ svn_wc__db_update_moved_away_conflict_vi
 
   SVN_WC__DB_WITH_TXN(
     update_moved_away_conflict_victim(
-      work_items, db, wcroot, local_relpath,
+      db, wcroot, local_relpath,
       operation, local_change, incoming_change,
       move_src_op_root_relpath,
       old_version, new_version,
-      notify_func, notify_baton,
       cancel_func, cancel_baton,
-      result_pool, scratch_pool),
+      scratch_pool),
     wcroot);
 
+  /* Send all queued up notifications. */
+  SVN_ERR(svn_wc__db_update_move_list_notify(wcroot,
+                                             old_version->peg_rev,
+                                             new_version->peg_rev,
+                                             notify_func, notify_baton,
+                                             scratch_pool));
+  if (notify_func)
+    {
+      svn_wc_notify_t *notify;
+
+      notify = svn_wc_create_notify(svn_dirent_join(wcroot->abspath,
+                                                    local_relpath,
+                                                    scratch_pool),
+                                    svn_wc_notify_update_completed,
+                                    scratch_pool);
+      notify->kind = svn_node_none;
+      notify->content_state = svn_wc_notify_state_inapplicable;
+      notify->prop_state = svn_wc_notify_state_inapplicable;
+      notify->revision = new_version->peg_rev;
+      notify_func(notify_baton, notify, scratch_pool);
+    }
+
+
+  return SVN_NO_ERROR;
+}
+
+/* Set *CAN_BUMP to TRUE if DEPTH is sufficient to cover the entire
+   BASE tree at LOCAL_RELPATH, to FALSE otherwise. */
+static svn_error_t *
+depth_sufficient_to_bump(svn_boolean_t *can_bump,
+                         const char *local_relpath,
+                         svn_wc__db_wcroot_t *wcroot,
+                         svn_depth_t depth,
+                         apr_pool_t *scratch_pool)
+{
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+          
+  switch (depth)
+    {
+    case svn_depth_infinity:
+      *can_bump = TRUE;
+      return SVN_NO_ERROR;
+
+    case svn_depth_empty:
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                        STMT_SELECT_OP_DEPTH_CHILDREN));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id,
+                                local_relpath, 0));
+      break;
+
+    case svn_depth_files:
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                        STMT_SELECT_HAS_NON_FILE_CHILDREN));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id,
+                                local_relpath));
+      break;
+
+    case svn_depth_immediates:
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                        STMT_SELECT_HAS_GRANDCHILDREN));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id,
+                                local_relpath));
+      break;
+    default:
+      SVN_ERR_MALFUNCTION();
+    }
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  SVN_ERR(svn_sqlite__reset(stmt));
+
+  *can_bump = !have_row;
+  return SVN_NO_ERROR;
+}
+
+/* Mark a move-edit conflict on MOVE_SRC_ROOT_RELPATH. */
+static svn_error_t *
+bump_mark_tree_conflict(svn_wc__db_wcroot_t *wcroot,
+                        const char *move_src_root_relpath,
+                        const char *move_src_op_root_relpath,
+                        const char *move_dst_op_root_relpath,
+                        svn_wc__db_t *db,
+                        apr_pool_t *scratch_pool)
+{
+  apr_int64_t repos_id;
+  const char *repos_root_url;
+  const char *repos_uuid;
+  const char *old_repos_relpath;
+  const char *new_repos_relpath;
+  svn_revnum_t old_rev;
+  svn_revnum_t new_rev;
+  const char *old_repos_url;
+  const char *new_repos_url;
+  svn_node_kind_t old_kind;
+  svn_node_kind_t new_kind;
+  svn_wc_conflict_version_t *old_version;
+  svn_wc_conflict_version_t *new_version;
+
+  /* Read new (post-update) information from the new move source BASE node. */
+  SVN_ERR(svn_wc__db_base_get_info_internal(NULL, &new_kind, &new_rev,
+                                            &new_repos_relpath, &repos_id,
+                                            NULL, NULL, NULL, NULL, NULL,
+                                            NULL, NULL, NULL, NULL, NULL,
+                                            wcroot, move_src_op_root_relpath,
+                                            scratch_pool, scratch_pool));
+  SVN_ERR(svn_wc__db_fetch_repos_info(&repos_root_url, &repos_uuid,
+                                      wcroot->sdb, repos_id, scratch_pool));
+  new_repos_url = svn_uri_canonicalize(apr_pstrcat(scratch_pool,
+                                                   repos_root_url, "/",
+                                                   new_repos_relpath,
+                                                   (const char *)NULL),
+                                       scratch_pool);
+
+  /* Read old (pre-update) information from the move destination node. */
+  SVN_ERR(svn_wc__db_depth_get_info(NULL, &old_kind, &old_rev,
+                                    &old_repos_relpath, NULL, NULL, NULL,
+                                    NULL, NULL, NULL, NULL, NULL, NULL,
+                                    wcroot, move_dst_op_root_relpath,
+                                    relpath_depth(move_dst_op_root_relpath),
+                                    scratch_pool, scratch_pool));
+  old_repos_url = svn_uri_canonicalize(apr_pstrcat(scratch_pool,
+                                                   repos_root_url, "/",
+                                                   old_repos_relpath,
+                                                   (const char *)NULL),
+                                       scratch_pool);
+
+  old_version = svn_wc_conflict_version_create2(
+                  old_repos_url, repos_uuid, old_repos_relpath, old_rev,
+                  old_kind, scratch_pool);
+  new_version = svn_wc_conflict_version_create2(
+                  new_repos_url, repos_uuid, new_repos_relpath, new_rev,
+                  new_kind, scratch_pool);
+
+  SVN_ERR(mark_tree_conflict(move_src_root_relpath,
+                             wcroot, db, old_version, new_version,
+                             move_dst_op_root_relpath,
+                             svn_wc_operation_update,
+                             old_kind, new_kind,
+                             old_repos_relpath,
+                             svn_wc_conflict_reason_moved_away,
+                             svn_wc_conflict_action_edit,
+                             move_src_op_root_relpath,
+                             scratch_pool));
+
   return SVN_NO_ERROR;
 }
 
@@ -1932,6 +2141,8 @@ bump_moved_away(svn_wc__db_wcroot_t *wcr
                 const char *local_relpath,
                 int op_depth,
                 apr_hash_t *src_done,
+                svn_depth_t depth,
+                svn_wc__db_t *db,
                 apr_pool_t *result_pool,
                 apr_pool_t *scratch_pool)
 {
@@ -1953,12 +2164,51 @@ bump_moved_away(svn_wc__db_wcroot_t *wcr
       int src_op_depth = svn_sqlite__column_int(stmt, 2);
       svn_error_t *err;
       svn_skel_t *conflict;
+      svn_depth_t src_depth = depth;
 
       svn_pool_clear(iterpool);
 
       src_relpath = svn_sqlite__column_text(stmt, 0, iterpool);
       dst_relpath = svn_sqlite__column_text(stmt, 1, iterpool);
 
+      if (depth != svn_depth_infinity)
+        {
+          svn_boolean_t skip_this_src = FALSE;
+          svn_node_kind_t src_kind;
+
+          if (strcmp(src_relpath, local_relpath))
+            {
+              switch (depth)
+                {
+                case svn_depth_empty:
+                  skip_this_src = TRUE;
+                  break;
+                case svn_depth_files:
+                  src_kind = svn_sqlite__column_token(stmt, 3, kind_map);
+                  if (src_kind != svn_node_file)
+                    {
+                      skip_this_src = TRUE;
+                      break;
+                    }
+                  /* Fallthrough */
+                case svn_depth_immediates:
+                  if (strcmp(svn_relpath_dirname(src_relpath, scratch_pool),
+                             local_relpath))
+                    skip_this_src = TRUE;
+                  src_depth = svn_depth_empty;
+                  break;
+                default:
+                  SVN_ERR_MALFUNCTION();
+                }
+            }
+
+          if (skip_this_src)
+            {
+              SVN_ERR(svn_sqlite__step(&have_row, stmt));
+              continue;
+            }
+        }
+
       err = svn_sqlite__get_statement(&stmt2, wcroot->sdb,
                                       STMT_HAS_LAYER_BETWEEN);
       if (!err)
@@ -1970,29 +2220,55 @@ bump_moved_away(svn_wc__db_wcroot_t *wcr
         err = svn_sqlite__reset(stmt2);
       if (!err && !have_row)
         {
+          svn_boolean_t can_bump;
           const char *src_root_relpath = src_relpath;
 
-          while (relpath_depth(src_root_relpath) > src_op_depth)
-            src_root_relpath = svn_relpath_dirname(src_root_relpath, iterpool);
+          if (op_depth == 0)
+            err = depth_sufficient_to_bump(&can_bump, src_relpath, wcroot,
+                                           src_depth, scratch_pool);
+          else
+            /* Having chosen to bump an entire BASE tree move we
+               always have sufficient depth to bump subtree moves. */
+            can_bump = TRUE;
 
-          if (!apr_hash_get(src_done, src_relpath, APR_HASH_KEY_STRING))
+          if (!err)
             {
-              apr_hash_set(src_done, apr_pstrdup(result_pool, src_relpath),
-                           APR_HASH_KEY_STRING, "");
-              err = svn_wc__db_read_conflict_internal(&conflict, wcroot,
-                                                      src_root_relpath,
-                                                      iterpool, iterpool);
-              /* ### TODO: check this is the right sort of tree-conflict? */
-              if (!err && !conflict)
+              if (!can_bump)
                 {
-                  /* ### TODO: verify moved_here? */
-                  err = replace_moved_layer(src_relpath, dst_relpath, op_depth,
-                                            wcroot, iterpool);
-
-                  if (!err)
-                    err = bump_moved_away(wcroot, dst_relpath,
-                                          relpath_depth(dst_relpath), src_done,
-                                          result_pool, iterpool);
+                  err = bump_mark_tree_conflict(wcroot, src_relpath,
+                                                src_root_relpath, dst_relpath,
+                                                db, scratch_pool);
+                  if (err)
+                    return svn_error_compose_create(err,
+                                                    svn_sqlite__reset(stmt));
+                  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+                  continue;
+                }
+
+              while (relpath_depth(src_root_relpath) > src_op_depth)
+                src_root_relpath = svn_relpath_dirname(src_root_relpath,
+                                                       iterpool);
+
+              if (!apr_hash_get(src_done, src_relpath, APR_HASH_KEY_STRING))
+                {
+                  apr_hash_set(src_done, apr_pstrdup(result_pool, src_relpath),
+                               APR_HASH_KEY_STRING, "");
+                  err = svn_wc__db_read_conflict_internal(&conflict, wcroot,
+                                                          src_root_relpath,
+                                                          iterpool, iterpool);
+                  /* ### TODO: check this is the right sort of tree-conflict? */
+                  if (!err && !conflict)
+                    {
+                      /* ### TODO: verify moved_here? */
+                      err = replace_moved_layer(src_relpath, dst_relpath,
+                                                op_depth, wcroot, iterpool);
+
+                      if (!err)
+                        err = bump_moved_away(wcroot, dst_relpath,
+                                              relpath_depth(dst_relpath),
+                                              src_done, depth, db,
+                                              result_pool, iterpool);
+                    }
                 }
             }
         }
@@ -2013,16 +2289,37 @@ svn_error_t *
 svn_wc__db_bump_moved_away(svn_wc__db_wcroot_t *wcroot,
                            const char *local_relpath,
                            svn_depth_t depth,
+                           svn_wc__db_t *db,
                            apr_pool_t *scratch_pool)
 {
+  const char *dummy1, *move_dst_op_root_relpath;
+  const char *move_src_root_relpath, *move_src_op_root_relpath;
   apr_hash_t *src_done;
 
-  /* ### TODO: raise tree-conflicts? */
-  if (depth != svn_depth_infinity)
-    return SVN_NO_ERROR;
+  SVN_ERR(svn_sqlite__exec_statements(wcroot->sdb,
+                                      STMT_CREATE_UPDATE_MOVE_LIST));
+
+  SVN_ERR(svn_wc__db_op_depth_moved_to(&dummy1, &move_dst_op_root_relpath,
+                                       &move_src_root_relpath,
+                                       &move_src_op_root_relpath, 0,
+                                       wcroot, local_relpath,
+                                       scratch_pool, scratch_pool));
+
+  if (move_src_root_relpath)
+    {
+      if (strcmp(move_src_root_relpath, local_relpath))
+        {
+          SVN_ERR(bump_mark_tree_conflict(wcroot, move_src_root_relpath,
+                                          move_src_op_root_relpath,
+                                          move_dst_op_root_relpath,
+                                          db, scratch_pool));
+          return SVN_NO_ERROR;
+        }
+
+    }
 
   src_done = apr_hash_make(scratch_pool);
-  SVN_ERR(bump_moved_away(wcroot, local_relpath, 0, src_done,
+  SVN_ERR(bump_moved_away(wcroot, local_relpath, 0, src_done, depth, db,
                           scratch_pool, scratch_pool));
 
   return SVN_NO_ERROR;
@@ -2036,8 +2333,6 @@ resolve_delete_raise_moved_away(svn_wc__
                                 svn_wc_conflict_action_t action,
                                 svn_wc_conflict_version_t *old_version,
                                 svn_wc_conflict_version_t *new_version,
-                                svn_wc_notify_func2_t notify_func,
-                                void *notify_baton,
                                 apr_pool_t *scratch_pool)
 {
   svn_sqlite__stmt_t *stmt;
@@ -2055,30 +2350,22 @@ resolve_delete_raise_moved_away(svn_wc__
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   while(have_row)
     {
-      struct tc_editor_baton b;
-
       const char *moved_relpath = svn_sqlite__column_text(stmt, 0, NULL);
+      const char *move_root_dst_relpath = svn_sqlite__column_text(stmt, 1,
+                                                                  NULL);
       const char *moved_dst_repos_relpath = svn_sqlite__column_text(stmt, 2,
                                                                     NULL);
-
       svn_pool_clear(iterpool);
 
-      b.wcroot = wcroot;
-      b.db = db;
-      b.operation = operation;
-      b.old_version = old_version;
-      b.new_version = new_version;
-      b.move_root_dst_relpath = svn_sqlite__column_text(stmt, 1, NULL);
-      b.result_pool = scratch_pool;
-      b.notify_func = notify_func;
-      b.notify_baton = notify_baton;
-      
-      SVN_ERR(mark_tree_conflict(&b, moved_relpath,
+      SVN_ERR(mark_tree_conflict(moved_relpath,
+                                 wcroot, db, old_version, new_version,
+                                 move_root_dst_relpath, operation,
                                  svn_node_dir /* ### ? */,
                                  svn_node_dir /* ### ? */,
                                  moved_dst_repos_relpath,
                                  svn_wc_conflict_reason_moved_away,
-                                 action, local_relpath, iterpool));
+                                 action, local_relpath,
+                                 iterpool));
 
       SVN_ERR(svn_sqlite__step(&have_row, stmt));
     }
@@ -2116,17 +2403,42 @@ svn_wc__db_resolve_delete_raise_moved_aw
     resolve_delete_raise_moved_away(wcroot, local_relpath,
                                     db, operation, action,
                                     old_version, new_version,
-                                    notify_func, notify_baton,
                                     scratch_pool),
     wcroot);
 
-  SVN_ERR(update_move_list_notify(wcroot,
-                                  old_version->peg_rev,
-                                  (new_version 
-                                   ? new_version->peg_rev
-                                   : SVN_INVALID_REVNUM),
-                                  notify_func, notify_baton,
-                                  scratch_pool));
+  SVN_ERR(svn_wc__db_update_move_list_notify(wcroot,
+                                             old_version->peg_rev,
+                                             (new_version 
+                                              ? new_version->peg_rev
+                                              : SVN_INVALID_REVNUM),
+                                             notify_func, notify_baton,
+                                             scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+break_move(svn_wc__db_wcroot_t *wcroot,
+           const char *src_relpath,
+           int src_op_depth,
+           const char *dst_relpath,
+           int dst_op_depth,
+           apr_pool_t *scratch_pool)
+{
+  svn_sqlite__stmt_t *stmt;
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_CLEAR_MOVED_TO_RELPATH));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, src_relpath,
+                            src_op_depth));
+  SVN_ERR(svn_sqlite__step_done(stmt));
+
+  /* This statement clears moved_here. */
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_UPDATE_OP_DEPTH_RECURSIVE));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isdd", wcroot->wc_id,
+                            dst_relpath, dst_op_depth, dst_op_depth));
+  SVN_ERR(svn_sqlite__step_done(stmt));
 
   return SVN_NO_ERROR;
 }
@@ -2138,8 +2450,6 @@ svn_wc__db_resolve_break_moved_away_inte
 {
   const char *dummy1, *move_dst_op_root_relpath;
   const char *dummy2, *move_src_op_root_relpath;
-  svn_sqlite__stmt_t *stmt;
-  int dst_op_depth;
 
   SVN_ERR(svn_wc__db_op_depth_moved_to(&dummy1, &move_dst_op_root_relpath,
                                        &dummy2,
@@ -2147,21 +2457,53 @@ svn_wc__db_resolve_break_moved_away_inte
                                        relpath_depth(local_relpath) - 1,
                                        wcroot, local_relpath,
                                        scratch_pool, scratch_pool));
-  dst_op_depth = relpath_depth(move_dst_op_root_relpath);
+  SVN_ERR(break_move(wcroot, local_relpath,
+                     relpath_depth(move_src_op_root_relpath),
+                     move_dst_op_root_relpath,
+                     relpath_depth(move_dst_op_root_relpath),
+                     scratch_pool));
 
-  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                    STMT_CLEAR_MOVED_TO_RELPATH));
-  SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, local_relpath,
-                            relpath_depth(move_src_op_root_relpath)));
-  SVN_ERR(svn_sqlite__step_done(stmt));
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+break_moved_away_children_internal(svn_wc__db_wcroot_t *wcroot,
+                                   const char *local_relpath,
+                                   apr_pool_t *scratch_pool)
+{
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+  apr_pool_t *iterpool;
+
+  SVN_ERR(svn_sqlite__exec_statements(wcroot->sdb,
+                                      STMT_CREATE_UPDATE_MOVE_LIST));
 
-  /* This statement clears moved_here. */
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                    STMT_UPDATE_OP_DEPTH_RECURSIVE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "isdd", wcroot->wc_id,
-                            move_dst_op_root_relpath,
-                            dst_op_depth, dst_op_depth));
-  SVN_ERR(svn_sqlite__step_done(stmt));
+                                    STMT_SELECT_MOVED_PAIR2));
+  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+  iterpool = svn_pool_create(scratch_pool);
+  while (have_row)
+    {
+      const char *src_relpath = svn_sqlite__column_text(stmt, 0, iterpool);
+      const char *dst_relpath = svn_sqlite__column_text(stmt, 1, iterpool);
+      int src_op_depth = svn_sqlite__column_int(stmt, 2);
+      
+      svn_pool_clear(iterpool);
+
+      SVN_ERR(break_move(wcroot, src_relpath, src_op_depth, dst_relpath,
+                         relpath_depth(dst_relpath), iterpool));
+      SVN_ERR(update_move_list_add(wcroot, src_relpath,
+                                   svn_wc_notify_move_broken,
+                                   svn_node_unknown,
+                                   svn_wc_notify_state_inapplicable,
+                                   svn_wc_notify_state_inapplicable));
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+    }
+  svn_pool_destroy(iterpool);
+
+  SVN_ERR(svn_sqlite__reset(stmt));
 
   return SVN_NO_ERROR;
 }
@@ -2169,6 +2511,8 @@ svn_wc__db_resolve_break_moved_away_inte
 svn_error_t *
 svn_wc__db_resolve_break_moved_away(svn_wc__db_t *db,
                                     const char *local_abspath,
+                                    svn_wc_notify_func2_t notify_func,
+                                    void *notify_baton,
                                     apr_pool_t *scratch_pool)
 {
   svn_wc__db_wcroot_t *wcroot;
@@ -2184,5 +2528,116 @@ svn_wc__db_resolve_break_moved_away(svn_
                                                  scratch_pool),
     wcroot);
 
+  if (notify_func)
+    {
+      svn_wc_notify_t *notify;
+
+      notify = svn_wc_create_notify(svn_dirent_join(wcroot->abspath,
+                                                    local_relpath,
+                                                    scratch_pool),
+                                    svn_wc_notify_move_broken,
+                                    scratch_pool);
+      notify->kind = svn_node_unknown;
+      notify->content_state = svn_wc_notify_state_inapplicable;
+      notify->prop_state = svn_wc_notify_state_inapplicable;
+      notify->revision = SVN_INVALID_REVNUM;
+      notify_func(notify_baton, notify, scratch_pool);
+    }
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__db_resolve_break_moved_away_children(svn_wc__db_t *db,
+                                             const char *local_abspath,
+                                             svn_wc_notify_func2_t notify_func,
+                                             void *notify_baton,
+                                             apr_pool_t *scratch_pool)
+{
+  svn_wc__db_wcroot_t *wcroot;
+  const char *local_relpath;
+
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath,
+                                                db, local_abspath,
+                                                scratch_pool, scratch_pool));
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  SVN_WC__DB_WITH_TXN(
+    break_moved_away_children_internal(wcroot, local_relpath, scratch_pool),
+    wcroot);
+
+  SVN_ERR(svn_wc__db_update_move_list_notify(wcroot,
+                                             SVN_INVALID_REVNUM,
+                                             SVN_INVALID_REVNUM,
+                                             notify_func, notify_baton,
+                                             scratch_pool));
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+required_lock_for_resolve(const char **required_relpath,
+                          svn_wc__db_wcroot_t *wcroot,
+                          const char *local_relpath,
+                          apr_pool_t *result_pool,
+                          apr_pool_t *scratch_pool)
+{
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+
+  *required_relpath = local_relpath;
+
+  /* This simply looks for all moves out of the LOCAL_RELPATH tree. We
+     could attempt to limit it to only those moves that are going to
+     be resolved but that would require second guessing the resolver.
+     This simple algorithm is sufficient although it may give a
+     strictly larger/deeper lock than necessary. */
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_SELECT_MOVED_OUTSIDE));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, local_relpath, 0));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  
+  while (have_row)
+    {
+      const char *move_dst_relpath = svn_sqlite__column_text(stmt, 1,
+                                                             NULL);
+      
+      *required_relpath
+        = svn_relpath_get_longest_ancestor(*required_relpath,
+                                           move_dst_relpath,
+                                           scratch_pool);
+
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+    }
+  SVN_ERR(svn_sqlite__reset(stmt));
+
+  *required_relpath = apr_pstrdup(result_pool, *required_relpath);
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__required_lock_for_resolve(const char **required_abspath,
+                                  svn_wc__db_t *db,
+                                  const char *local_abspath,
+                                  apr_pool_t *result_pool,
+                                  apr_pool_t *scratch_pool)
+{
+  svn_wc__db_wcroot_t *wcroot;
+  const char *local_relpath;
+  const char *required_relpath;
+
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath,
+                                                db, local_abspath,
+                                                scratch_pool, scratch_pool));
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  SVN_WC__DB_WITH_TXN(
+    required_lock_for_resolve(&required_relpath, wcroot, local_relpath,
+                              scratch_pool, scratch_pool),
+    wcroot);
+
+  *required_abspath = svn_dirent_join(wcroot->abspath, required_relpath,
+                                      result_pool);
+
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/verify-keep-going/subversion/libsvn_wc/wc_db_wcroot.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_wc/wc_db_wcroot.c?rev=1457684&r1=1457683&r2=1457684&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_wc/wc_db_wcroot.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_wc/wc_db_wcroot.c Mon Mar 18 09:35:24 2013
@@ -104,7 +104,7 @@ get_old_version(int *version,
    This function may do strange things, but at long as it comes up with the
    Right Answer, we should be happy. */
 static svn_error_t *
-get_path_kind(svn_kind_t *kind,
+get_path_kind(svn_node_kind_t *kind,
               svn_wc__db_t *db,
               const char *local_abspath,
               apr_pool_t *scratch_pool)
@@ -137,7 +137,7 @@ get_path_kind(svn_kind_t *kind,
   SVN_ERR(svn_io_check_special_path(local_abspath, &node_kind,
                                     &special, scratch_pool));
 
-  db->parse_cache.kind = svn__kind_from_node_kind(node_kind, special);
+  db->parse_cache.kind = (special ? svn_node_symlink : node_kind);
   *kind = db->parse_cache.kind;
 
   return SVN_NO_ERROR;
@@ -423,7 +423,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
 {
   const char *local_dir_abspath;
   const char *original_abspath = local_abspath;
-  svn_kind_t kind;
+  svn_node_kind_t kind;
   const char *build_relpath;
   svn_wc__db_wcroot_t *probe_wcroot;
   svn_wc__db_wcroot_t *found_wcroot = NULL;
@@ -460,7 +460,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
      ### into wc_db which references a file. calls for directories could
      ### get an early-exit in the hash lookup just above.  */
   SVN_ERR(get_path_kind(&kind, db, local_abspath, scratch_pool));
-  if (kind != svn_kind_dir)
+  if (kind != svn_node_dir)
     {
       /* If the node specified by the path is NOT present, then it cannot
          possibly be a directory containing ".svn/wc.db".
@@ -495,7 +495,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
          many ancestors need to be scanned until we start hitting content
          on the disk. Set ALWAYS_CHECK to keep looking for .svn/entries
          rather than bailing out after the first check.  */
-      if (kind == svn_kind_none)
+      if (kind == svn_node_none)
         always_check = TRUE;
 
       /* Start the scanning at LOCAL_DIR_ABSPATH.  */
@@ -587,7 +587,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
            * (Issue #2557, #3987). If so, try again, this time scanning
            * for a db within the directory the symlink points to,
            * rather than within the symlink's parent directory. */
-          if (kind == svn_kind_symlink)
+          if (kind == svn_node_symlink)
             {
               svn_node_kind_t resolved_kind;
 
@@ -607,7 +607,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
                   SVN_ERR(read_link_target(&local_abspath, local_abspath,
                                            scratch_pool));
 try_symlink_as_dir:
-                  kind = svn_kind_dir;
+                  kind = svn_node_dir;
                   moved_upwards = FALSE;
                   local_dir_abspath = local_abspath;
                   build_relpath = "";
@@ -669,7 +669,7 @@ try_symlink_as_dir:
                             db->state_pool, scratch_pool);
       if (err && (err->apr_err == SVN_ERR_WC_UNSUPPORTED_FORMAT ||
                   err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED) &&
-          kind == svn_kind_symlink)
+          kind == svn_node_symlink)
         {
           /* We found an unsupported WC after traversing upwards from a
            * symlink. Fall through to code below to check if the symlink
@@ -749,7 +749,7 @@ try_symlink_as_dir:
       *local_relpath = svn_relpath_join(dir_relpath, build_relpath, result_pool);
     }
 
-  if (kind == svn_kind_symlink)
+  if (kind == svn_node_symlink)
     {
       svn_boolean_t retry_if_dir = FALSE;
       svn_wc__db_status_t status;

Modified: subversion/branches/verify-keep-going/subversion/libsvn_wc/wcroot_anchor.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_wc/wcroot_anchor.c?rev=1457684&r1=1457683&r2=1457684&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_wc/wcroot_anchor.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_wc/wcroot_anchor.c Mon Mar 18 09:35:24 2013
@@ -145,7 +145,7 @@
 svn_error_t *
 svn_wc_check_root(svn_boolean_t *is_wcroot,
                   svn_boolean_t *is_switched,
-                  svn_kind_t *kind,
+                  svn_node_kind_t *kind,
                   svn_wc_context_t *wc_ctx,
                   const char *local_abspath,
                   apr_pool_t *scratch_pool)
@@ -191,7 +191,7 @@ svn_wc_get_actual_target2(const char **a
                           apr_pool_t *scratch_pool)
 {
   svn_boolean_t is_wc_root, is_switched;
-  svn_kind_t kind;
+  svn_node_kind_t kind;
   const char *local_abspath;
   svn_error_t *err;
 
@@ -213,7 +213,7 @@ svn_wc_get_actual_target2(const char **a
     }
 
   /* If PATH is not a WC root, or if it is a file, lop off a basename. */
-  if (!(is_wc_root || is_switched) || (kind != svn_kind_dir))
+  if (!(is_wc_root || is_switched) || (kind != svn_node_dir))
     {
       svn_dirent_split(anchor, target, path, result_pool);
     }