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

svn commit: r1425415 [7/13] - in /subversion/branches/javahl-ra: ./ build/generator/templates/ notes/ notes/directory-index/ subversion/bindings/swig/python/svn/ subversion/bindings/swig/ruby/test/ subversion/include/ subversion/include/private/ subver...

Modified: subversion/branches/javahl-ra/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_wc/update_editor.c?rev=1425415&r1=1425414&r2=1425415&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_wc/update_editor.c Sun Dec 23 06:03:14 2012
@@ -286,13 +286,6 @@ struct dir_baton
   /* Absolute path of this directory */
   const char *local_abspath;
 
-  /* Absolute path to the new location of the directory if it was moved away,
-   * and the op-root of the move operation.
-   * This is set on the root of a move operation and all children.
-   * If the directory was not moved away, this is NULL. */
-  const char *moved_to_abspath;
-  const char *moved_to_op_root_abspath;
-
   /* The repository relative path this directory will correspond to. */
   const char *new_relpath;
 
@@ -630,8 +623,6 @@ make_dir_baton(struct dir_baton **d_p,
   d->adding_dir   = adding;
   d->changed_rev  = SVN_INVALID_REVNUM;
   d->not_present_files = apr_hash_make(dir_pool);
-  d->moved_to_abspath = NULL;
-  d->moved_to_op_root_abspath = NULL;
 
   /* Copy some flags from the parent baton */
   if (pb)
@@ -714,10 +705,6 @@ struct file_baton
   /* Absolute path to this file */
   const char *local_abspath;
 
-  /* Absolute path to the new location of the file if it was moved away.
-   * If the file was not moved away, this is NULL. */
-  const char *moved_to_abspath;
-
   /* The repository relative path this file will correspond to. */
   const char *new_relpath;
 
@@ -857,6 +844,56 @@ make_file_baton(struct file_baton **f_p,
   return SVN_NO_ERROR;
 }
 
+/* Complete a conflict skel by describing the update.
+ *
+ * All temporary allocations are be made in SCRATCH_POOL, while allocations
+ * needed for the returned conflict struct are made in RESULT_POOL.
+ */
+static svn_error_t *
+complete_conflict(svn_skel_t *conflict,
+                  const struct dir_baton *pb,
+                  const char *local_abspath,
+                  const char *old_repos_relpath,
+                  svn_revnum_t old_revision,
+                  svn_node_kind_t kind,
+                  apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+{
+  const struct edit_baton *eb = pb->edit_baton;
+  svn_wc_conflict_version_t *src_left_version;
+  svn_boolean_t is_complete;
+
+  if (!conflict)
+    return SVN_NO_ERROR; /* Not conflicted */
+
+  SVN_ERR(svn_wc__conflict_skel_is_complete(&is_complete, conflict));
+
+  if (is_complete)
+    return SVN_NO_ERROR; /* Already competed */
+
+  if (old_repos_relpath)
+    src_left_version = svn_wc_conflict_version_create2(eb->repos_root,
+                                                       eb->repos_uuid,
+                                                       old_repos_relpath,
+                                                       old_revision,
+                                                       kind,
+                                                       result_pool);
+  else
+    src_left_version = NULL;
+
+
+  if (eb->switch_relpath)
+    SVN_ERR(svn_wc__conflict_skel_set_op_switch(conflict,
+                                                src_left_version,
+                                                result_pool, scratch_pool));
+  else
+    SVN_ERR(svn_wc__conflict_skel_set_op_update(conflict,
+                                                src_left_version,
+                                                result_pool, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+
 /* Called when a directory is really edited, to avoid marking a
    tree conflict on a node for a no-change edit */
 static svn_error_t *
@@ -873,6 +910,11 @@ mark_directory_edited(struct dir_baton *
   if (db->edit_conflict)
     {
       /* We have a (delayed) tree conflict to install */
+
+      SVN_ERR(complete_conflict(db->edit_conflict, db->parent_baton,
+                                db->local_abspath, db->old_repos_relpath,
+                                db->old_revision, svn_node_dir,
+                                db->pool, scratch_pool));
       SVN_ERR(svn_wc__db_op_mark_conflict(db->edit_baton->db,
                                           db->local_abspath,
                                           db->edit_conflict, NULL,
@@ -901,6 +943,12 @@ mark_file_edited(struct file_baton *fb, 
   if (fb->edit_conflict)
     {
       /* We have a (delayed) tree conflict to install */
+
+      SVN_ERR(complete_conflict(fb->edit_conflict, fb->dir_baton,
+                                fb->local_abspath, fb->old_repos_relpath,
+                                fb->old_revision, svn_node_file,
+                                fb->pool, scratch_pool));
+
       SVN_ERR(svn_wc__db_op_mark_conflict(fb->edit_baton->db,
                                           fb->local_abspath,
                                           fb->edit_conflict, NULL,
@@ -1154,25 +1202,6 @@ open_root(void *edit_baton,
                                                         pool));
     }
 
-  /* Check if this directory was moved away. */
-  err = svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL,
-                             eb->db, db->local_abspath, pool, pool);
-  if (err)
-    {
-      if (err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-        svn_error_clear(err);
-      else
-        return svn_error_trace(err);
-    }
-  else if (status == svn_wc__db_status_deleted)
-    SVN_ERR(svn_wc__db_scan_deletion(NULL, &db->moved_to_abspath, NULL,
-                                     &db->moved_to_op_root_abspath,
-                                     eb->db, db->local_abspath, db->pool, pool));
-
   return SVN_NO_ERROR;
 }
 
@@ -1186,6 +1215,7 @@ typedef struct modcheck_baton_t {
   svn_boolean_t found_mod;  /* whether a modification has been found */
   svn_boolean_t found_not_delete;  /* Found a not-delete modification */
   svn_boolean_t is_copy; /* check for post-copy modifications only */
+  const char *modcheck_root_abspath;
 } modcheck_baton_t;
 
 /* An implementation of svn_wc_status_func4_t. */
@@ -1215,10 +1245,19 @@ modcheck_callback(void *baton,
       case svn_wc_status_obstructed:
         if (status->prop_status != svn_wc_status_modified)
           break;
-        /* Fall through in the found modification case */
+
+        mb->found_mod = TRUE;
+        mb->found_not_delete = TRUE;
+        /* Exit from the status walker: We know what we want to know */
+        return svn_error_create(SVN_ERR_CEASE_INVOCATION, NULL, NULL);
 
       case svn_wc_status_added:
-        if (!mb->is_copy)
+        /* Ignore the copy status if we expect a copy, but don't ignore
+           other changes */
+        if (!mb->is_copy
+            || status->text_status == svn_wc_status_modified
+            || status->prop_status == svn_wc_status_modified
+            || strcmp(mb->modcheck_root_abspath, local_abspath) != 0)
           {
             mb->found_mod = TRUE;
             mb->found_not_delete = TRUE;
@@ -1262,6 +1301,7 @@ node_has_local_mods(svn_boolean_t *modif
 
   modcheck_baton.db = db;
   modcheck_baton.is_copy = is_copy;
+  modcheck_baton.modcheck_root_abspath = local_abspath;
 
   /* Walk the WC tree for status with depth infinity, looking for any local
    * modifications. If it's a "sparse" directory, that's OK: there can be
@@ -1285,136 +1325,9 @@ node_has_local_mods(svn_boolean_t *modif
   return SVN_NO_ERROR;
 }
 
-
 /* Indicates an unset svn_wc_conflict_reason_t. */
 #define SVN_WC_CONFLICT_REASON_NONE (svn_wc_conflict_reason_t)(-1)
 
-/* Create a tree conflict struct.
- *
- * The REASON is stored directly in the tree conflict info.
- *
- * All temporary allocations are be made in SCRATCH_POOL, while allocations
- * needed for the returned conflict struct are made in RESULT_POOL.
- *
- * All other parameters are identical to and described by
- * check_tree_conflict(), with the slight modification that this function
- * relies on the reason passed in REASON instead of actively looking for one. */
-static svn_error_t *
-create_tree_conflict(svn_skel_t **pconflict,
-                     struct edit_baton *eb,
-                     const char *local_abspath,
-                     svn_wc_conflict_reason_t reason,
-                     svn_wc_conflict_action_t action,
-                     apr_pool_t *result_pool, apr_pool_t *scratch_pool)
-{
-  const char *left_repos_relpath;
-  svn_revnum_t left_revision;
-  svn_node_kind_t left_kind;
-  svn_wc_conflict_version_t *src_left_version;
-
-  *pconflict = NULL;
-
-  SVN_ERR_ASSERT(reason != SVN_WC_CONFLICT_REASON_NONE);
-
-  /* Get the source-left information, i.e. the local state of the node
-   * before any changes were made to the working copy, i.e. the state the
-   * node would have if it was reverted. */
-  if (reason == svn_wc_conflict_reason_added ||
-      reason == svn_wc_conflict_reason_moved_here)
-    {
-      /* ###TODO: It would be nice to tell the user at which URL and
-       * ### revision source-left was empty, which could be quite difficult
-       * ### to code, and is a slight theoretical leap of the svn mind.
-       * ### Update should show
-       * ###   URL: svn_wc__db_scan_addition( &repos_relpath )
-       * ###   REV: The base revision of the parent of before this update
-       * ###        started
-       * ###        ### BUT what if parent was updated/switched away with
-       * ###        ### depth=empty after this node was added?
-       * ### Switch should show
-       * ###   URL: scan_addition URL of before this switch started
-       * ###   REV: same as above */
-
-      /* In case of a local addition, source-left is non-existent / empty. */
-      left_kind = svn_node_none;
-      left_revision = SVN_INVALID_REVNUM;
-      left_repos_relpath = NULL;
-    }
-  else if (reason == svn_wc_conflict_reason_unversioned)
-    {
-      /* Obstructed by an unversioned node. Source-left is
-       * non-existent/empty. */
-      left_kind = svn_node_none;
-      left_revision = SVN_INVALID_REVNUM;
-      left_repos_relpath = NULL;
-    }
-  else
-    {
-      /* A BASE node should exist. */
-      svn_kind_t base_kind;
-
-      /* If anything else shows up, then this assertion is probably naive
-       * and that other case should also be handled. */
-      SVN_ERR_ASSERT(reason == svn_wc_conflict_reason_edited
-                     || reason == svn_wc_conflict_reason_deleted
-                     || reason == svn_wc_conflict_reason_moved_away
-                     || reason == svn_wc_conflict_reason_moved_away_and_edited
-                     || reason == svn_wc_conflict_reason_replaced
-                     || reason == svn_wc_conflict_reason_obstructed);
-
-      SVN_ERR(svn_wc__db_base_get_info(NULL, &base_kind,
-                                       &left_revision,
-                                       &left_repos_relpath,
-                                       NULL, NULL,
-                                       NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL,
-                                       eb->db, local_abspath,
-                                       result_pool, scratch_pool));
-      /* Translate the node kind. */
-      if (base_kind == svn_kind_file
-          || base_kind == svn_kind_symlink)
-        left_kind = svn_node_file;
-      else if (base_kind == svn_kind_dir)
-        left_kind = svn_node_dir;
-      else
-        SVN_ERR_MALFUNCTION();
-    }
-
-  /* Construct the tree conflict info structs. */
-
-  if (left_repos_relpath == NULL)
-    /* A locally added or unversioned path in conflict with an incoming add.
-     * Send an 'empty' left revision. */
-    src_left_version = NULL;
-  else
-    src_left_version = svn_wc_conflict_version_create2(eb->repos_root,
-                                                       eb->repos_uuid,
-                                                       left_repos_relpath,
-                                                       left_revision,
-                                                       left_kind,
-                                                       result_pool);
-
-  *pconflict = svn_wc__conflict_skel_create(result_pool);
-
-  SVN_ERR(svn_wc__conflict_skel_add_tree_conflict(*pconflict,
-                                                  eb->db, local_abspath,
-                                                  reason,
-                                                  action,
-                                                  result_pool, scratch_pool));
-
-  if (eb->switch_relpath)
-    SVN_ERR(svn_wc__conflict_skel_set_op_switch(*pconflict,
-                                                src_left_version,
-                                                result_pool, scratch_pool));
-  else
-    SVN_ERR(svn_wc__conflict_skel_set_op_update(*pconflict,
-                                                src_left_version,
-                                                result_pool, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-
 /* Check whether the incoming change ACTION on FULL_PATH would conflict with
  * LOCAL_ABSPATH's scheduled change. If so, then raise a tree conflict with
  * LOCAL_ABSPATH as the victim.
@@ -1431,7 +1344,7 @@ create_tree_conflict(svn_skel_t **pconfl
  * while *PCONFLICT is always overwritten.
  *
  * The tree conflict is allocated in RESULT_POOL. Temporary allocations use
- * SCRACTH_POOl.
+ * SCRATCH_POOL.
  */
 static svn_error_t *
 check_tree_conflict(svn_skel_t **pconflict,
@@ -1441,12 +1354,10 @@ check_tree_conflict(svn_skel_t **pconfli
                     svn_kind_t working_kind,
                     svn_boolean_t exists_in_repos,
                     svn_wc_conflict_action_t action,
-                    const char *moved_to_abspath,
                     apr_pool_t *result_pool,
                     apr_pool_t *scratch_pool)
 {
   svn_wc_conflict_reason_t reason = SVN_WC_CONFLICT_REASON_NONE;
-  svn_boolean_t locally_replaced = FALSE;
   svn_boolean_t modified = FALSE;
   svn_boolean_t all_mods_are_deletes = FALSE;
 
@@ -1459,21 +1370,7 @@ check_tree_conflict(svn_skel_t **pconfli
       case svn_wc__db_status_added:
       case svn_wc__db_status_moved_here:
       case svn_wc__db_status_copied:
-        /* Is it a replace? */
-        if (exists_in_repos)
-          {
-            svn_wc__db_status_t base_status;
-            SVN_ERR(svn_wc__db_base_get_info(&base_status, NULL, NULL,
-                                             NULL, NULL, NULL, NULL, NULL,
-                                             NULL, NULL, NULL, NULL, NULL,
-                                             NULL, NULL,
-                                             eb->db, local_abspath,
-                                             scratch_pool, scratch_pool));
-            if (base_status != svn_wc__db_status_not_present)
-              locally_replaced = TRUE;
-          }
-
-        if (!locally_replaced)
+        if (!exists_in_repos)
           {
             /* The node is locally added, and it did not exist before.  This
              * is an 'update', so the local add can only conflict with an
@@ -1507,28 +1404,7 @@ check_tree_conflict(svn_skel_t **pconfli
 
 
       case svn_wc__db_status_deleted:
-        if (!moved_to_abspath)
-          reason = svn_wc_conflict_reason_deleted;
-        else if (action == svn_wc_conflict_action_delete)
-          {
-            svn_boolean_t all_edits_are_deletes = FALSE;
-
-            /* The update wants to delete a node which was locally moved
-             * away. We allow this only if the node wasn't modified post-move.
-             * If the only post-move changes within a subtree are deletions,
-             * allow the update to delete the entire subtree. */
-            if (working_kind == svn_kind_dir)
-              SVN_ERR(node_has_local_mods(&modified, &all_edits_are_deletes,
-                                          TRUE, eb->db, moved_to_abspath,
-                                          eb->cancel_func, eb->cancel_baton,
-                                          scratch_pool));
-            else
-              SVN_ERR(svn_wc__internal_file_modified_p(&modified, eb->db,
-                                                       moved_to_abspath,
-                                                       FALSE, scratch_pool));
-            if (modified && !all_edits_are_deletes)
-              reason = svn_wc_conflict_reason_moved_away_and_edited;
-          }
+        reason = svn_wc_conflict_reason_deleted;
         break;
 
       case svn_wc__db_status_incomplete:
@@ -1545,6 +1421,10 @@ check_tree_conflict(svn_skel_t **pconfli
            * but we don't handle those here.) */
           return SVN_NO_ERROR;
 
+        /* Replace is handled as delete and then specifically in
+           add_directory() and add_file(), so we only expect deletes here */
+        SVN_ERR_ASSERT(action == svn_wc_conflict_action_delete);
+
         /* Check if the update wants to delete or replace a locally
          * modified node. */
 
@@ -1609,11 +1489,16 @@ check_tree_conflict(svn_skel_t **pconfli
     SVN_ERR_ASSERT(action == svn_wc_conflict_action_add);
 
 
-  /* A conflict was detected. Append log commands to the log accumulator
-   * to record it. */
-  return svn_error_trace(create_tree_conflict(pconflict, eb, local_abspath,
-                                              reason, action,
-                                              result_pool, scratch_pool));
+  /* A conflict was detected. Create a conflict skel to record it. */
+  *pconflict = svn_wc__conflict_skel_create(result_pool);
+
+  SVN_ERR(svn_wc__conflict_skel_add_tree_conflict(*pconflict,
+                                                  eb->db, local_abspath,
+                                                  reason,
+                                                  action,
+                                                  result_pool, scratch_pool));
+
+  return SVN_NO_ERROR;
 }
 
 
@@ -1636,30 +1521,17 @@ already_in_a_tree_conflict(svn_boolean_t
 
   while (TRUE)
     {
-      svn_boolean_t is_wc_root, has_conflict;
+      svn_boolean_t is_wc_root, tree_conflicted;
 
       svn_pool_clear(iterpool);
 
-      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL, NULL, NULL,
-                                   &has_conflict, NULL, NULL, NULL,
-                                   NULL, NULL, NULL,
-                                   db, ancestor_abspath, iterpool, iterpool));
+      SVN_ERR(svn_wc__internal_conflicted_p(NULL, NULL, &tree_conflicted,
+                                            db, ancestor_abspath, iterpool));
 
-      if (has_conflict)
+      if (tree_conflicted)
         {
-          const svn_wc_conflict_description2_t *conflict;
-
-          SVN_ERR(svn_wc__db_op_read_tree_conflict(&conflict, db,
-                                                   ancestor_abspath,
-                                                   iterpool, iterpool));
-
-          if (conflict != NULL)
-            {
-              *conflicted = TRUE;
-              break;
-            }
+          *conflicted = TRUE;
+          break;
         }
 
       SVN_ERR(svn_wc__db_is_wcroot(&is_wc_root, db, ancestor_abspath,
@@ -1708,17 +1580,16 @@ delete_entry(const char *path,
   const char *base = svn_relpath_basename(path, NULL);
   const char *local_abspath;
   const char *repos_relpath;
-  const char *moved_to_abspath = NULL;
   svn_kind_t kind, base_kind;
+  svn_revnum_t old_revision;
   svn_boolean_t conflicted;
-  svn_boolean_t have_base;
   svn_boolean_t have_work;
   svn_skel_t *tree_conflict = NULL;
-  svn_skel_t *work_item = NULL;
   svn_wc__db_status_t status;
   svn_wc__db_status_t base_status;
   apr_pool_t *scratch_pool;
   svn_boolean_t deleting_target;
+  svn_boolean_t keep_as_working = FALSE;
 
   if (pb->skip_this)
     return SVN_NO_ERROR;
@@ -1752,11 +1623,11 @@ delete_entry(const char *path,
       }
   }
 
-  SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, &repos_relpath, NULL, NULL,
+  SVN_ERR(svn_wc__db_read_info(&status, &kind, &old_revision, &repos_relpath,
                                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, &conflicted,
-                               NULL, NULL, NULL,
-                               &have_base, NULL, &have_work,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               &conflicted, NULL, NULL, NULL,
+                               NULL, NULL, &have_work,
                                eb->db, local_abspath,
                                scratch_pool, scratch_pool));
 
@@ -1766,7 +1637,7 @@ delete_entry(const char *path,
       base_kind = kind;
     }
   else
-    SVN_ERR(svn_wc__db_base_get_info(&base_status, &base_kind, NULL,
+    SVN_ERR(svn_wc__db_base_get_info(&base_status, &base_kind, &old_revision,
                                      &repos_relpath,
                                      NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                      NULL, NULL, NULL, NULL,
@@ -1798,7 +1669,10 @@ delete_entry(const char *path,
       || base_status == svn_wc__db_status_excluded
       || base_status == svn_wc__db_status_server_excluded)
     {
-      SVN_ERR(svn_wc__db_base_remove(eb->db, local_abspath, scratch_pool));
+      SVN_ERR(svn_wc__db_base_remove(eb->db, local_abspath,
+                                     FALSE, SVN_INVALID_REVNUM,
+                                     NULL, NULL,
+                                     scratch_pool));
 
       if (deleting_target)
         eb->target_deleted = TRUE;
@@ -1808,13 +1682,6 @@ delete_entry(const char *path,
       return SVN_NO_ERROR;
     }
 
-  /* Has the to-be-deleted node been moved away? */
-  if (status == svn_wc__db_status_deleted)
-    SVN_ERR(svn_wc__db_scan_deletion(NULL, &moved_to_abspath, NULL,
-                                     NULL, eb->db, local_abspath,
-                                     pool, pool));
-
-
   /* Is this path the victim of a newly-discovered tree conflict?  If so,
    * remember it and notify the client. Then (if it was existing and
    * modified), re-schedule the node to be added back again, as a (modified)
@@ -1827,7 +1694,7 @@ delete_entry(const char *path,
       SVN_ERR(check_tree_conflict(&tree_conflict, eb, local_abspath,
                                   status, kind, TRUE,
                                   svn_wc_conflict_action_delete,
-                                  moved_to_abspath, pb->pool, scratch_pool));
+                                  pb->pool, scratch_pool));
     }
 
   if (tree_conflict != NULL)
@@ -1856,8 +1723,7 @@ delete_entry(const char *path,
            * To prepare the "accept mine" resolution for the tree conflict,
            * we must schedule the existing content for re-addition as a copy
            * of what it was, but with its local modifications preserved. */
-          SVN_ERR(svn_wc__db_temp_op_make_copy(eb->db, local_abspath,
-                                               scratch_pool));
+          keep_as_working = TRUE;
 
           /* Fall through to remove the BASE_NODEs properly, with potentially
              keeping a not-present marker */
@@ -1876,23 +1742,13 @@ delete_entry(const char *path,
       else
         SVN_ERR_MALFUNCTION();  /* other reasons are not expected here */
     }
-  else if (moved_to_abspath)
-    {
-      /* No tree conflict was flagged, and the node was moved-away.
-       * Automatically merge the incoming deletion with the local move
-       * by deleting the node from the moved-away subtree. */
-      /* ### This should probably use a work queue. */
-      SVN_ERR(svn_wc__db_op_delete(eb->db, moved_to_abspath, NULL,
-                                   NULL, NULL, /* notify below */
-                                   eb->cancel_func, eb->cancel_baton,
-                                   scratch_pool));
-      if (kind == svn_kind_dir)
-        SVN_ERR(svn_io_remove_dir2(moved_to_abspath, TRUE,
-                                   eb->cancel_func, eb->cancel_baton,
-                                   scratch_pool));
-      else
-        SVN_ERR(svn_io_remove_file2(moved_to_abspath, TRUE, scratch_pool));
-    }
+
+  SVN_ERR(complete_conflict(tree_conflict, pb, local_abspath, repos_relpath,
+                            old_revision,
+                            (kind == svn_kind_dir)
+                                ? svn_node_dir
+                                : svn_node_file,
+                            pb->pool, scratch_pool));
 
   /* Issue a wq operation to delete the BASE_NODE data and to delete actual
      nodes based on that from disk, but leave any WORKING_NODEs on disk.
@@ -1905,33 +1761,21 @@ delete_entry(const char *path,
   if (! deleting_target)
     {
       /* Delete, and do not leave a not-present node.  */
-      SVN_ERR(svn_wc__wq_build_base_remove(&work_item,
-                                           eb->db, local_abspath,
-                                           SVN_INVALID_REVNUM,
-                                           svn_kind_unknown,
-                                           scratch_pool, scratch_pool));
+      SVN_ERR(svn_wc__db_base_remove(eb->db, local_abspath,
+                                     keep_as_working, SVN_INVALID_REVNUM,
+                                     tree_conflict, NULL,
+                                     scratch_pool));
     }
   else
     {
       /* Delete, leaving a not-present node.  */
-      SVN_ERR(svn_wc__wq_build_base_remove(&work_item,
-                                           eb->db, local_abspath,
-                                           *eb->target_revision,
-                                           base_kind,
-                                           scratch_pool, scratch_pool));
+      SVN_ERR(svn_wc__db_base_remove(eb->db, local_abspath,
+                                     keep_as_working, *eb->target_revision,
+                                     tree_conflict, NULL,
+                                     scratch_pool));
       eb->target_deleted = TRUE;
     }
 
-  if (tree_conflict)
-  {
-    SVN_ERR(svn_wc__db_op_mark_conflict(eb->db, local_abspath,
-                                        tree_conflict, work_item,
-                                        scratch_pool));
-  }
-  else
-    SVN_ERR(svn_wc__db_wq_add(eb->db, pb->local_abspath, work_item,
-                              scratch_pool));
-
   SVN_ERR(svn_wc__wq_run(eb->db, pb->local_abspath,
                          eb->cancel_func, eb->cancel_baton,
                          scratch_pool));
@@ -1953,8 +1797,7 @@ delete_entry(const char *path,
       else
         node_kind = svn_node_file;
 
-      do_notification(eb, moved_to_abspath ? moved_to_abspath : local_abspath,
-                      node_kind, action, scratch_pool);
+      do_notification(eb, local_abspath, node_kind, action, scratch_pool);
     }
 
   svn_pool_destroy(scratch_pool);
@@ -2128,19 +1971,9 @@ add_directory(const char *path,
                                         reason, svn_wc_conflict_action_replace,
                                         db->pool, db->pool));
 
-          /* Node does not pre-exist so no original location */
-          if (eb->switch_relpath)
-            SVN_ERR(svn_wc__conflict_skel_set_op_switch(tree_conflict, NULL,
-                                                        db->pool, db->pool));
-          else
-            SVN_ERR(svn_wc__conflict_skel_set_op_update(tree_conflict, NULL,
-                                                        db->pool, db->pool));
-
-          SVN_ERR(svn_wc__db_op_mark_conflict(eb->db, db->local_abspath,
-                                              tree_conflict, NULL, db->pool));
-
           /* And now stop checking for conflicts here and just perform
              a shadowed update */
+          db->edit_conflict = tree_conflict; /* Cache for close_directory */
           tree_conflict = NULL; /* No direct notification */
           db->shadowed = TRUE; /* Just continue */
           conflicted = FALSE; /* No skip */
@@ -2233,7 +2066,7 @@ add_directory(const char *path,
                                       db->local_abspath,
                                       status, wc_kind, FALSE,
                                       svn_wc_conflict_action_add,
-                                      NULL, pool, pool));
+                                      pool, pool));
         }
 
       if (tree_conflict == NULL)
@@ -2254,66 +2087,46 @@ add_directory(const char *path,
           db->shadowed = TRUE;
 
           /* Mark a conflict */
-          SVN_ERR(create_tree_conflict(&tree_conflict, eb,
-                                       db->local_abspath,
-                                       svn_wc_conflict_reason_unversioned,
-                                       svn_wc_conflict_action_add,
-                                       pool, pool));
-          SVN_ERR_ASSERT(tree_conflict != NULL);
+          tree_conflict = svn_wc__conflict_skel_create(db->pool);
+
+          SVN_ERR(svn_wc__conflict_skel_add_tree_conflict(
+                                        tree_conflict,
+                                        eb->db, db->local_abspath,
+                                        svn_wc_conflict_reason_unversioned,
+                                        svn_wc_conflict_action_add,
+                                        db->pool, pool));
+          db->edit_conflict = tree_conflict;
         }
     }
 
-  SVN_ERR(svn_wc__db_temp_op_set_new_dir_to_incomplete(eb->db,
-                                                       db->local_abspath,
-                                                       db->new_relpath,
-                                                       eb->repos_root,
-                                                       eb->repos_uuid,
-                                                       *eb->target_revision,
-                                                       db->ambient_depth,
-                                                       pool));
+  SVN_ERR(complete_conflict(tree_conflict, pb, db->local_abspath,
+                            db->old_repos_relpath, db->old_revision,
+                            svn_node_dir, db->pool, pool));
+
+  SVN_ERR(svn_wc__db_base_add_incomplete_directory(
+                                     eb->db, db->local_abspath,
+                                     db->new_relpath,
+                                     eb->repos_root,
+                                     eb->repos_uuid,
+                                     *eb->target_revision,
+                                     db->ambient_depth,
+                                     (db->shadowed && db->obstruction_found),
+                                     (! db->shadowed
+                                      && status == svn_wc__db_status_added),
+                                     tree_conflict, NULL,
+                                     pool));
 
   /* Make sure there is a real directory at LOCAL_ABSPATH, unless we are just
-     updating the DB or the parent was moved away. */
-  if (!db->shadowed && !pb->moved_to_abspath)
+     updating the DB */
+  if (!db->shadowed)
     SVN_ERR(svn_wc__ensure_directory(db->local_abspath, pool));
 
-  if (!db->shadowed && status == svn_wc__db_status_added)
-    /* If there is no conflict we take over any added directory */
-    SVN_ERR(svn_wc__db_temp_op_remove_working(eb->db, db->local_abspath, pool));
-
-  /* ### We can't record an unversioned obstruction yet, so
-     ### we record a delete instead, which will allow resolving the conflict
-     ### to theirs with 'svn revert'. */
-  if (db->shadowed && db->obstruction_found)
-    {
-      SVN_ERR(svn_wc__db_op_delete(eb->db, db->local_abspath, NULL,
-                                   NULL, NULL /* notification */,
-                                   eb->cancel_func, eb->cancel_baton,
-                                   pool));
-    }
-
   if (tree_conflict != NULL)
     {
-      SVN_ERR(svn_wc__db_op_mark_conflict(eb->db, db->local_abspath,
-                                          tree_conflict, NULL,
-                                          db->pool));
-
       db->already_notified = TRUE;
-
       do_notification(eb, db->local_abspath, svn_node_dir,
                       svn_wc_notify_tree_conflict, pool);
     }
-  else if (wc_kind == svn_kind_unknown &&
-           versioned_locally_and_present == FALSE &&
-           pb->moved_to_abspath)
-    {
-      /* The parent directory of the directory we're adding was moved.
-       * Add the new directory at the new location. */
-      db->moved_to_abspath = svn_dirent_join(pb->moved_to_abspath,
-                                             db->name, db->pool);
-      db->moved_to_op_root_abspath = pb->moved_to_op_root_abspath;
-    }
-
 
 
   /* If this add was obstructed by dir scheduled for addition without
@@ -2334,9 +2147,7 @@ add_directory(const char *path,
 
       db->already_notified = TRUE;
 
-      do_notification(eb, db->moved_to_abspath ? db->moved_to_abspath
-                                               : db->local_abspath,
-                      svn_node_dir, action, pool);
+      do_notification(eb, db->local_abspath, svn_node_dir, action, pool);
     }
 
   return SVN_NO_ERROR;
@@ -2357,7 +2168,6 @@ open_directory(const char *path,
   svn_skel_t *tree_conflict = NULL;
   svn_wc__db_status_t status, base_status;
   svn_kind_t wc_kind;
-  svn_error_t *err;
 
   SVN_ERR(make_dir_baton(&db, path, eb, pb, FALSE, pool));
   *child_baton = db;
@@ -2433,33 +2243,13 @@ open_directory(const char *path,
   /* Is this path a fresh tree conflict victim?  If so, skip the tree
      with one notification. */
 
-  /* Check if this directory was moved away. */
-  err = svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL,
-                             eb->db, db->local_abspath, pool, pool);
-  if (err)
-    {
-      if (err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-        svn_error_clear(err);
-      else
-        return svn_error_trace(err);
-    }
-  else if (status == svn_wc__db_status_deleted)
-    SVN_ERR(svn_wc__db_scan_deletion(NULL, &db->moved_to_abspath, NULL,
-                                     &db->moved_to_op_root_abspath,
-                                     eb->db, db->local_abspath,
-                                     db->pool, pool));
-
   /* Check for conflicts only when we haven't already recorded
    * a tree-conflict on a parent node. */
   if (!db->shadowed)
     SVN_ERR(check_tree_conflict(&tree_conflict, eb, db->local_abspath,
                                 status, wc_kind, TRUE,
                                 svn_wc_conflict_action_edit,
-                                db->moved_to_abspath, db->pool, pool));
+                                db->pool, pool));
 
   /* Remember the roots of any locally deleted trees. */
   if (tree_conflict != NULL)
@@ -2881,41 +2671,14 @@ close_directory(void *dir_baton,
       if (conflict_skel)
         {
           svn_skel_t *work_item;
-          svn_boolean_t completed;
-
-          SVN_ERR(svn_wc__conflict_skel_is_complete(&completed,
-                                                    conflict_skel));
 
-          if (completed)
-            {
-              /* Avoid assertion */
-            }
-          else if (eb->switch_relpath)
-            SVN_ERR(svn_wc__conflict_skel_set_op_switch(
-                        conflict_skel,
-                        db->adding_dir
-                            ? NULL
-                            : svn_wc_conflict_version_create2(
-                                            eb->repos_root,
-                                            eb->repos_uuid,
-                                            db->old_repos_relpath,
-                                            db->old_revision,
-                                            svn_node_dir,
-                                            scratch_pool),
-                        db->pool, db->pool));
-          else
-            SVN_ERR(svn_wc__conflict_skel_set_op_update(
-                        conflict_skel,
-                        db->adding_dir
-                            ? NULL
-                            : svn_wc_conflict_version_create2(
-                                            eb->repos_root,
-                                            eb->repos_uuid,
-                                            db->old_repos_relpath,
-                                            db->old_revision,
-                                            svn_node_dir,
-                                            scratch_pool),
-                        db->pool, db->pool));
+          SVN_ERR(complete_conflict(conflict_skel,
+                                    db->parent_baton,
+                                    db->local_abspath,
+                                    db->old_repos_relpath,
+                                    db->old_revision,
+                                    svn_node_dir,
+                                    db->pool, scratch_pool));
 
           SVN_ERR(svn_wc__conflict_create_markers(&work_item,
                                                   eb->db, db->local_abspath,
@@ -2946,41 +2709,6 @@ close_directory(void *dir_baton,
                 new_actual_props,
                 all_work_items,
                 scratch_pool));
-
-      if (db->moved_to_abspath)
-        {
-          /* Perform another in-DB move of the directory to sync meta-data
-           * of the moved-away node with the new BASE node. */
-          apr_array_header_t *children = NULL;
-          apr_hash_t *children_hash = apr_hash_get(eb->dir_dirents,
-                                                   db->new_relpath,
-                                                   APR_HASH_KEY_STRING);
-          /* The op-root of the move needs to retain its moved-here flag.
-           * Its children are normal copied children. */
-          svn_boolean_t is_move = (strcmp(db->moved_to_op_root_abspath,
-                                          db->moved_to_abspath) == 0);
-
-          /* Add the new directory as a copy and create it on disk. */
-          if (children_hash)
-            SVN_ERR(svn_hash_keys(&children, children_hash, scratch_pool));
-          SVN_ERR(svn_wc__db_op_copy_dir(eb->db, db->moved_to_abspath,
-                                         new_actual_props ? new_actual_props
-                                                          : actual_props,
-                                         db->changed_rev,
-                                         db->changed_date,
-                                         db->changed_author,
-                                         db->new_relpath,
-                                         eb->repos_root,
-                                         eb->repos_uuid,
-                                         *eb->target_revision,
-                                         children,
-                                         is_move,
-                                         db->ambient_depth,
-                                         NULL /* conflict */,
-                                         NULL, /* no work, just modify DB */
-                                         scratch_pool));
-          SVN_ERR(svn_wc__ensure_directory(db->moved_to_abspath, pool));
-        }
     }
 
   /* Process all of the queued work items for this directory.  */
@@ -3306,19 +3034,9 @@ add_file(const char *path,
                                         reason, svn_wc_conflict_action_replace,
                                         fb->pool, fb->pool));
 
-          /* Node does not pre-exist so no original location */
-          if (eb->switch_relpath)
-            SVN_ERR(svn_wc__conflict_skel_set_op_switch(tree_conflict, NULL,
-                                                        fb->pool, fb->pool));
-          else
-            SVN_ERR(svn_wc__conflict_skel_set_op_update(tree_conflict, NULL,
-                                                        fb->pool, fb->pool));
-
-          SVN_ERR(svn_wc__db_op_mark_conflict(eb->db, fb->local_abspath,
-                                              tree_conflict, NULL, fb->pool));
-
           /* And now stop checking for conflicts here and just perform
              a shadowed update */
+          fb->edit_conflict = tree_conflict; /* Cache for close_file */
           tree_conflict = NULL; /* No direct notification */
           fb->shadowed = TRUE; /* Just continue */
           conflicted = FALSE; /* No skip */
@@ -3406,7 +3124,7 @@ add_file(const char *path,
           SVN_ERR(check_tree_conflict(&tree_conflict, eb,
                                       fb->local_abspath,
                                       status, wc_kind, FALSE,
-                                      svn_wc_conflict_action_add, NULL,
+                                      svn_wc_conflict_action_add,
                                       scratch_pool, scratch_pool));
         }
 
@@ -3429,12 +3147,14 @@ add_file(const char *path,
           fb->shadowed = TRUE;
 
           /* Mark a conflict */
-          SVN_ERR(create_tree_conflict(&tree_conflict, eb,
-                                       fb->local_abspath,
-                                       svn_wc_conflict_reason_unversioned,
-                                       svn_wc_conflict_action_add,
-                                       scratch_pool, scratch_pool));
-          SVN_ERR_ASSERT(tree_conflict != NULL);
+          tree_conflict = svn_wc__conflict_skel_create(fb->pool);
+
+          SVN_ERR(svn_wc__conflict_skel_add_tree_conflict(
+                                        tree_conflict,
+                                        eb->db, fb->local_abspath,
+                                        svn_wc_conflict_reason_unversioned,
+                                        svn_wc_conflict_action_add,
+                                        fb->pool, scratch_pool));
         }
     }
 
@@ -3451,6 +3171,14 @@ add_file(const char *path,
 
   if (tree_conflict != NULL)
     {
+      SVN_ERR(complete_conflict(tree_conflict,
+                                fb->dir_baton,
+                                fb->local_abspath,
+                                fb->old_repos_relpath,
+                                fb->old_revision,
+                                svn_node_file,
+                                fb->pool, scratch_pool));
+
       SVN_ERR(svn_wc__db_op_mark_conflict(eb->db,
                                           fb->local_abspath,
                                           tree_conflict, NULL,
@@ -3460,15 +3188,6 @@ add_file(const char *path,
       do_notification(eb, fb->local_abspath, svn_node_file,
                       svn_wc_notify_tree_conflict, scratch_pool);
     }
-  else if (wc_kind == svn_kind_unknown &&
-           versioned_locally_and_present == FALSE &&
-           pb->moved_to_abspath)
-    {
-      /* The parent directory of the file we're adding was moved.
-       * Add the new file at the new location. */
-      fb->moved_to_abspath = svn_dirent_join(pb->moved_to_abspath,
-                                             fb->name, fb->pool);
-    }
 
   svn_pool_destroy(scratch_pool);
 
@@ -3548,12 +3267,6 @@ open_file(const char *path,
                                      eb->db, fb->local_abspath,
                                      fb->pool, scratch_pool));
 
-  /* If the file has moved locally look up its new location. */
-  if (status == svn_wc__db_status_deleted)
-    SVN_ERR(svn_wc__db_scan_deletion(NULL, &fb->moved_to_abspath, NULL, NULL,
-                                     eb->db, fb->local_abspath,
-                                     fb->pool, scratch_pool));
-
   /* Is this path a conflict victim? */
   if (conflicted)
     SVN_ERR(node_already_conflicted(&conflicted, eb->db,
@@ -3581,7 +3294,7 @@ open_file(const char *path,
     SVN_ERR(check_tree_conflict(&tree_conflict, eb, fb->local_abspath,
                                 status, wc_kind, TRUE,
                                 svn_wc_conflict_action_edit,
-                                fb->moved_to_abspath, fb->pool, scratch_pool));
+                                fb->pool, scratch_pool));
 
   /* Is this path the victim of a newly-discovered tree conflict? */
   if (tree_conflict != NULL)
@@ -3862,7 +3575,6 @@ svn_wc__perform_file_merge(svn_skel_t **
   /* Merge the changes from the old textbase to the new
      textbase into the file we're updating.
      Remember that this function wants full paths! */
-  /* ### TODO: Pass version info here. */
   SVN_ERR(svn_wc__internal_merge(&work_item,
                                  conflict_skel,
                                  merge_outcome,
@@ -3883,7 +3595,8 @@ svn_wc__perform_file_merge(svn_skel_t **
   /* If we created a temporary left merge file, get rid of it. */
   if (delete_left)
     {
-      SVN_ERR(svn_wc__wq_build_file_remove(&work_item, db, merge_left,
+      SVN_ERR(svn_wc__wq_build_file_remove(&work_item, db, wri_abspath,
+                                           merge_left,
                                            result_pool, scratch_pool));
       *work_items = svn_wc__wq_merge(*work_items, work_item, result_pool);
     }
@@ -3930,8 +3643,6 @@ merge_file(svn_skel_t **work_items,
   struct dir_baton *pb = fb->dir_baton;
   svn_boolean_t is_locally_modified;
   enum svn_wc_merge_outcome_t merge_outcome = svn_wc_merge_unchanged;
-  const char *working_abspath = fb->moved_to_abspath ? fb->moved_to_abspath
-                                                     : fb->local_abspath;
 
   SVN_ERR_ASSERT(! fb->shadowed && !fb->obstruction_found);
 
@@ -3976,7 +3687,7 @@ merge_file(svn_skel_t **work_items,
          files that do not exist and for directories. */
 
       SVN_ERR(svn_wc__internal_file_modified_p(&is_locally_modified,
-                                               eb->db, working_abspath,
+                                               eb->db, fb->local_abspath,
                                                FALSE /* exact_comparison */,
                                                scratch_pool));
     }
@@ -4021,7 +3732,7 @@ merge_file(svn_skel_t **work_items,
                                          conflict_skel,
                                          &merge_outcome,
                                          eb->db,
-                                         working_abspath,
+                                         fb->local_abspath,
                                          pb->local_abspath,
                                          fb->new_text_base_sha1_checksum,
                                          fb->add_existed
@@ -4052,7 +3763,7 @@ merge_file(svn_skel_t **work_items,
       SVN_ERR(svn_wc__get_translate_info(NULL, NULL,
                                          &keywords,
                                          NULL,
-                                         eb->db, working_abspath,
+                                         eb->db, fb->local_abspath,
                                          actual_props, TRUE,
                                          scratch_pool, scratch_pool));
       if (magic_props_changed || keywords)
@@ -4072,7 +3783,7 @@ merge_file(svn_skel_t **work_items,
               /* Copy and DEtranslate the working file to a temp text-base.
                  Note that detranslation is done according to the old props. */
               SVN_ERR(svn_wc__internal_translated_file(
-                        &tmptext, working_abspath, eb->db, working_abspath,
+                        &tmptext, fb->local_abspath, eb->db, fb->local_abspath,
                         SVN_WC_TRANSLATE_TO_NF
                           | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
                         eb->cancel_func, eb->cancel_baton,
@@ -4151,8 +3862,6 @@ close_file(void *file_baton,
   apr_pool_t *scratch_pool = fb->pool; /* Destroyed at function exit */
   svn_boolean_t keep_recorded_info = FALSE;
   const svn_checksum_t *new_checksum;
-  const char *working_abspath = fb->moved_to_abspath ? fb->moved_to_abspath
-                                                     : fb->local_abspath;
 
   if (fb->skip_this)
     {
@@ -4246,7 +3955,7 @@ close_file(void *file_baton,
   if ((!fb->adding_file || fb->add_existed)
       && !fb->shadowed)
     SVN_ERR(svn_wc__get_actual_props(&local_actual_props,
-                                     eb->db, working_abspath,
+                                     eb->db, fb->local_abspath,
                                      scratch_pool, scratch_pool));
   if (local_actual_props == NULL)
     local_actual_props = apr_hash_make(scratch_pool);
@@ -4312,25 +4021,26 @@ close_file(void *file_baton,
 
       if (local_is_link != incoming_is_link)
         {
-          svn_skel_t *tree_conflict = NULL;
-
           fb->shadowed = TRUE;
           fb->obstruction_found = TRUE;
           fb->add_existed = FALSE;
 
-          SVN_ERR(create_tree_conflict(&tree_conflict, eb,
-                                       fb->local_abspath,
+          if (!conflict_skel)
+            conflict_skel = svn_wc__conflict_skel_create(fb->pool);
+
+          SVN_ERR(svn_wc__conflict_skel_add_tree_conflict(
+                                       conflict_skel,
+                                       eb->db, fb->local_abspath,
                                        svn_wc_conflict_reason_added,
                                        svn_wc_conflict_action_add,
                                        scratch_pool, scratch_pool));
-          SVN_ERR(svn_wc__db_op_mark_conflict(eb->db,
-                                              fb->local_abspath,
-                                              tree_conflict, NULL,
-                                              scratch_pool));
 
           fb->already_notified = TRUE;
           do_notification(eb, fb->local_abspath, svn_node_unknown,
                           svn_wc_notify_tree_conflict, scratch_pool);
+
+          /* The update will be applied to PRISTINE, but not to
+             the in-working copy node */
         }
     }
 
@@ -4350,7 +4060,7 @@ close_file(void *file_baton,
                                   &new_base_props,
                                   &new_actual_props,
                                   eb->db,
-                                  working_abspath,
+                                  fb->local_abspath,
                                   svn_kind_file,
                                   NULL /* server_baseprops (update, not merge)  */,
                                   current_base_props,
@@ -4378,7 +4088,7 @@ close_file(void *file_baton,
               if (eb->notify_func)
                 {
                   svn_wc_notify_t *notify =svn_wc_create_notify(
-                                working_abspath,
+                                fb->local_abspath,
                                 svn_wc_notify_update_skip_access_denied,
                                 scratch_pool);
 
@@ -4425,7 +4135,7 @@ close_file(void *file_baton,
 
           SVN_ERR(svn_wc__wq_build_file_install(&work_item,
                                                 eb->db,
-                                                working_abspath,
+                                                fb->local_abspath,
                                                 install_from,
                                                 eb->use_commit_times,
                                                 record_fileinfo,
@@ -4441,7 +4151,7 @@ close_file(void *file_baton,
 
              Note: this will also update the executable flag, but ... meh.  */
           SVN_ERR(svn_wc__wq_build_sync_file_flags(&work_item, eb->db,
-                                                   working_abspath,
+                                                   fb->local_abspath,
                                                    scratch_pool, scratch_pool));
           all_work_items = svn_wc__wq_merge(all_work_items, work_item,
                                             scratch_pool);
@@ -4459,10 +4169,10 @@ close_file(void *file_baton,
       /* Remove the INSTALL_FROM file, as long as it doesn't refer to the
          working file.  */
       if (install_from != NULL
-          && strcmp(install_from, working_abspath) != 0)
+          && strcmp(install_from, fb->local_abspath) != 0)
         {
           SVN_ERR(svn_wc__wq_build_file_remove(&work_item, eb->db,
-                                               install_from,
+                                               fb->local_abspath, install_from,
                                                scratch_pool, scratch_pool));
           all_work_items = svn_wc__wq_merge(all_work_items, work_item,
                                             scratch_pool);
@@ -4517,40 +4227,13 @@ close_file(void *file_baton,
 
   if (conflict_skel)
     {
-      svn_skel_t *work_item;
-      svn_boolean_t completed;
-
-      SVN_ERR(svn_wc__conflict_skel_is_complete(&completed,
-                                                    conflict_skel));
-
-      if (completed)
-        {
-          /* Avoid assertion */
-        }
-      else if (eb->switch_relpath)
-        SVN_ERR(svn_wc__conflict_skel_set_op_switch(
-                    conflict_skel,
-                    fb->adding_file
-                      ? NULL
-                      : svn_wc_conflict_version_create2(eb->repos_root,
-                                                        eb->repos_uuid,
-                                                        fb->old_repos_relpath,
-                                                        fb->old_revision,
-                                                        svn_node_file,
-                                                        fb->pool),
-                    fb->pool, fb->pool));
-      else
-        SVN_ERR(svn_wc__conflict_skel_set_op_update(
-                    conflict_skel,
-                    fb->adding_file
-                      ? NULL
-                      : svn_wc_conflict_version_create2(eb->repos_root,
-                                                        eb->repos_uuid,
-                                                        fb->old_repos_relpath,
-                                                        fb->old_revision,
-                                                        svn_node_file,
-                                                        fb->pool),
-                    fb->pool, fb->pool));
+      SVN_ERR(complete_conflict(conflict_skel,
+                                fb->dir_baton,
+                                fb->local_abspath,
+                                fb->old_repos_relpath,
+                                fb->old_revision,
+                                svn_node_file,
+                                fb->pool, scratch_pool));
 
       SVN_ERR(svn_wc__conflict_create_markers(&work_item,
                                               eb->db, fb->local_abspath,
@@ -4576,44 +4259,24 @@ close_file(void *file_baton,
                                                       dav_prop_changes,
                                                       scratch_pool)
                                      : NULL,
-                                   conflict_skel,
+                                   (fb->add_existed && fb->adding_file),
                                    (! fb->shadowed) && new_base_props,
                                    new_actual_props,
                                    keep_recorded_info,
                                    (fb->shadowed && fb->obstruction_found),
+                                   conflict_skel,
                                    all_work_items,
                                    scratch_pool));
 
-  /* Deal with the WORKING tree, based on updates to the BASE tree.  */
-
-  if (fb->moved_to_abspath)
-    {
-      /* Perform another in-DB move of the file to sync meta-data
-       * of the moved-away node with the new BASE node. */
-      SVN_ERR(svn_wc__db_op_copy_file(eb->db, fb->moved_to_abspath,
-                                      new_actual_props,
-                                      fb->changed_rev,
-                                      fb->changed_date,
-                                      fb->changed_author,
-                                      fb->new_relpath,
-                                      eb->repos_root,
-                                      eb->repos_uuid,
-                                      *eb->target_revision,
-                                      new_checksum,
-                                      TRUE /* is_move */,
-                                      NULL /* conflict */,
-                                      NULL, /* no work, just modify DB */
-                                      scratch_pool));
-    }
+  if (conflict_skel && eb->conflict_func)
+    SVN_ERR(svn_wc__conflict_invoke_resolver(eb->db, fb->local_abspath,
+                                             conflict_skel,
+                                             NULL /* merge_options */,
+                                             eb->conflict_func,
+                                             eb->conflict_baton,
+                                             scratch_pool));
 
-  /* If this file was locally-added and is now being added by the update, we
-     can toss the local-add, turning this into a local-edit.
-     If the local file is replaced, we don't want to touch ACTUAL. */
-  if (fb->add_existed && fb->adding_file)
-    {
-      SVN_ERR(svn_wc__db_temp_op_remove_working(eb->db, fb->local_abspath,
-                                                scratch_pool));
-    }
+  /* Deal with the WORKING tree, based on updates to the BASE tree.  */
 
   apr_hash_set(fb->dir_baton->not_present_files, fb->name,
                APR_HASH_KEY_STRING, NULL);
@@ -4651,7 +4314,7 @@ close_file(void *file_baton,
       /* If the file was moved-away, notify for the moved-away node.
        * The original location only had its BASE info changed and
        * we don't usually notify about such changes. */
-      notify = svn_wc_create_notify(working_abspath, action, scratch_pool);
+      notify = svn_wc_create_notify(fb->local_abspath, action, scratch_pool);
       notify->kind = svn_node_file;
       notify->content_state = content_state;
       notify->prop_state = prop_state;
@@ -4758,7 +4421,8 @@ close_edit(void *edit_baton,
                  If so, we should get rid of this excluded node now. */
 
               SVN_ERR(svn_wc__db_base_remove(eb->db, eb->target_abspath,
-                                             scratch_pool));
+                                             FALSE, SVN_INVALID_REVNUM,
+                                             NULL, NULL, scratch_pool));
             }
         }
     }
@@ -5725,8 +5389,8 @@ svn_wc_add_repos_file4(svn_wc_context_t 
        it is a temporary file, which needs to be removed.  */
     if (source_abspath != NULL)
       {
-        SVN_ERR(svn_wc__wq_build_file_remove(&work_item,
-                                             db, source_abspath,
+        SVN_ERR(svn_wc__wq_build_file_remove(&work_item, db, local_abspath,
+                                             source_abspath,
                                              pool, pool));
         all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
       }
@@ -5745,16 +5409,10 @@ svn_wc_add_repos_file4(svn_wc_context_t 
                                   original_uuid,
                                   copyfrom_rev,
                                   new_text_base_sha1_checksum,
+                                  TRUE,
+                                  new_props,
                                   FALSE /* is_move */,
                                   NULL /* conflict */,
-                                  NULL /* work_items */,
-                                  pool));
-
-  /* ### if below fails, then the above db change would remain :-(  */
-
-  SVN_ERR(svn_wc__db_op_set_props(db, local_abspath,
-                                  new_props, FALSE,
-                                  NULL /* conflict */,
                                   all_work_items,
                                   pool));
 

Modified: subversion/branches/javahl-ra/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_wc/upgrade.c?rev=1425415&r1=1425414&r2=1425415&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_wc/upgrade.c Sun Dec 23 06:03:14 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"
@@ -1364,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;
@@ -1637,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/javahl-ra/subversion/libsvn_wc/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_wc/util.c?rev=1425415&r1=1425414&r2=1425415&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_wc/util.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_wc/util.c Sun Dec 23 06:03:14 2012
@@ -448,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);
     }
 

Modified: subversion/branches/javahl-ra/subversion/libsvn_wc/wc-metadata.sql
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_wc/wc-metadata.sql?rev=1425415&r1=1425414&r2=1425415&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_wc/wc-metadata.sql (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_wc/wc-metadata.sql Sun Dec 23 06:03:14 2012
@@ -785,6 +785,25 @@ CREATE INDEX IF NOT EXISTS I_PRISTINE_MD
    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.  */