Fix update/switch to skip all tree conflict victims and their
descendants.

Create only one tree conflict at the root of each conflicted tree, not a
tree conflict in every directory.

Notify the user once about any given tree conflict.

Tweak test expectations to reflect these new features.

Add tests that run update/switch in trees that already contain tree
conflict victims.

Add tests that chdir into conflicted trees and attempt to update/switch.


TODO:

More tests!  As always....

The tree conflict 2_1 and 3 tests show that an incoming tree delete
bumps the revision number inside a victim tree.  I don't know how to
solve this without leaving the parent dirs incomplete.  Maybe I need to
hack something in complete_directory().

If an update targets a single file or dir that has been deleted from the
repo, there's an error (see test 2_1).  Should be a tree conflict.
Fixing it requires moving some functions, so I'll do it in a separate
commit for clarity.


* subversion/libsvn_wc/update_editor.c
  (edit_baton): Add field current_tree_conflict.
  (make_editor): Initialize new field.
  (dir_baton): Remove unused field tree_conflicted.
  (make_dir_baton): Track field removal.
  (open_root): TODO comment, for now.
  (check_tree_conflict): Thin out the comments a bit.  Remove useless
   checks for entry validity.  Remove the redundant (delete:obstructed)
   and (delete:missing) conflicts.
  (already_in_a_tree_conflict): New function.
  (do_entry_deletion
   add_directory,
   open_directory,
   add_file,
   open_file): Skip the operation if there is an existing or new tree
   conflict.  Notify the user once per tree conflict.
  (close_directory): Unset current_tree_conflict when returning to
   the victim dir.  Don't notify about tree conflicts.

* subversion/tests/cmdline/update_tests.py
  (update_deleted_missing_dir,
   another_hudson_problem): Don't treat a missing item as a tree
   conflict.
  (update_delete_modified_files,
   tree_conflicts_on_update_1_2,
   tree_conflicts_on_update_2_1,
   tree_conflicts_on_update_2_2,
   tree_conflicts_on_update_3): Tweak expected output and disk to
   reflect the consistent skipping.
  (tree_conflicts_on_update_2_3): New test function.
  (test_list): Add the new test function, make it XFail().

* subversion/tests/cmdline/svntest/tree.py
  (build_tree_from_checkout): Correct a comment.

* subversion/tests/cmdline/svntest/actions.py
  (deep_trees_run_tests_scheme for update): Allow status check to be
   optional.
  (deep_trees_skipping_on_update): New function.


Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c	(revision 34137)
+++ subversion/libsvn_wc/update_editor.c	(working copy)
@@ -224,6 +224,10 @@ struct edit_baton
      The keys are pathnames and the values unspecified. */
   apr_hash_t *skipped_paths;
 
+  /* The path of the tree conflict victim, if the edit is currently inside
+     a conflicted tree.  NULL if the edit is not inside a conflicted tree. */
+  const char *current_tree_conflict;
+
   apr_pool_t *pool;
 };
 
@@ -271,9 +275,6 @@ struct dir_baton
      scheduled for addition without history. */
   svn_boolean_t add_existed;
 
-  /* Set if the dir is a tree conflict victim. */
-  svn_boolean_t tree_conflicted;
-
   /* An array of svn_prop_t structures, representing all the property
      changes to be applied to this directory. */
   apr_array_header_t *propchanges;
@@ -532,7 +533,6 @@ make_dir_baton(struct dir_baton **d_p,
   d->added        = added;
   d->existed      = FALSE;
   d->add_existed  = FALSE;
-  d->tree_conflicted = FALSE;
   d->bump_info    = bdi;
   d->log_number   = 0;
   d->log_accum    = svn_stringbuf_create("", pool);
@@ -1181,6 +1181,8 @@ open_root(void *edit_baton,
           d->was_incomplete = entry->incomplete;
         }
 
+      /* ### TODO: Skip if inside a conflicted tree. */
+
       /* Mark directory as being at target_revision, but incomplete. */
       tmp_entry.revision = *(eb->target_revision);
       tmp_entry.url = d->new_URL;
@@ -1369,6 +1371,9 @@ tree_has_local_mods(svn_boolean_t *modified,
  *
  * If PCONFLICT is not null, set *PCONFLICT to the conflict description if
  * there is one or else to null.
+ * 
+ * Tree conflict use cases are described in issue #2282 and in
+ * notest/tree-conflicts/detection.txt.
  */
 static svn_error_t *
 check_tree_conflict(svn_wc_conflict_description_t **pconflict,
@@ -1382,87 +1387,61 @@ check_tree_conflict(svn_wc_conflict_description_t
 {
   svn_wc_conflict_reason_t reason = (svn_wc_conflict_reason_t)(-1);
 
-  /* Test whether ACTION conflicts with the state of ENTRY.
-   * If so, set REASON to an appropriate value. */
   switch (action)
     {
     case svn_wc_conflict_action_edit:
-      if (!entry)
-        reason = svn_wc_conflict_reason_missing;
-      else if (entry->schedule == svn_wc_schedule_delete
-               || entry->schedule == svn_wc_schedule_replace)
+      /* Use case 1: Modifying a locally-deleted item. */
+      if (entry->schedule == svn_wc_schedule_delete
+          || entry->schedule == svn_wc_schedule_replace)
         reason = svn_wc_conflict_reason_deleted;
       break;
 
     case svn_wc_conflict_action_add:
-      /* When checking out a file-external, add_file() is called twice:
+      /* Use case "3.5": Adding a locally-added item.
+       *
+       * When checking out a file-external, add_file() is called twice:
        * 1.) In the main update, a minimal entry is created.
        * 2.) In the external update, the file is added properly.
-       * Don't raise a tree conflict the second time!
-       */
-      if (entry && (!entry->file_external_path))
+       * Don't raise a tree conflict the second time! */
+      if (entry && !entry->file_external_path)
         reason = svn_wc_conflict_reason_added;
       break;
 
     case svn_wc_conflict_action_delete:
-      if (!entry)
-        reason = svn_wc_conflict_reason_missing;
-      else if (entry->schedule != svn_wc_schedule_normal)
-        /* If we are about to delete a path that has been scheduled
-         * for deletion, it's a tree conflict.
-         * This _could_ be tree conflict use case 3 as described in the
-         * paper attached to issue #2282
-         *
-         * XXX: Flagging every delete of an already deleted file by the
-         * update as a tree conflict causes false positives.
-         * Use case 3 actually only applies if the file that was locally
-         * deleted and the file deleted by the update have a common ancestor.
-         * Getting at this information is very hard though without proper
-         * rename tracking. So currently, this is the best we can do.
-         * See also notes/tree-conflicts/detection.txt
-         */
-        reason = (entry->schedule == svn_wc_schedule_delete
-                  ? svn_wc_conflict_reason_deleted
-                  : svn_wc_conflict_reason_obstructed);  /* replace, add, etc. */
-      else /* schedule is normal, but item might be modified or missing */
+      /* Use case 3: Deleting a locally-deleted item. */
+      if (entry->schedule == svn_wc_schedule_delete
+          || entry->schedule == svn_wc_schedule_replace)
+        reason = svn_wc_conflict_reason_deleted;
+      else
         {
-          svn_boolean_t modified;
-          svn_node_kind_t kind;
+          svn_boolean_t modified = FALSE;
+          svn_wc_adm_access_t *adm_access;
 
-          SVN_ERR(svn_io_check_path(full_path, &kind, pool));
+          /* Use case 2: Deleting a locally-modified item. */
+          if (entry->kind == svn_node_file)
+            SVN_ERR(entry_has_local_mods(&modified, parent_adm_access, 
+                                         entry->kind, full_path, pool));
 
-          /* If we are about to delete a path that is locally missing,
-           * it's a tree conflict.
-           * This is tree conflict use case 3.
-           * See also notes/tree-conflicts/detection.txt
-           */
-          if (kind == svn_node_none)
-            reason = svn_wc_conflict_reason_missing;
-          else
+          else if (entry->kind == svn_node_dir)
             {
-              svn_wc_adm_access_t *adm_access;
-
-              /* If we are about to delete a path that has local mods,
-               * it's a tree conflict.
-               * This is tree conflict use case 2 as described in the
-               * paper attached to issue #2282
-               * See also notes/tree-conflicts/detection.txt
-               */
+              /* We must detect deep modifications in a directory tree,
+               * but the update editor will not visit the subdirectories
+               * of a directory that it wants to delete.  Therefore, we
+               * need to start a separate crawl here. */
               SVN_ERR(svn_wc_adm_probe_retrieve(&adm_access, parent_adm_access,
                                                 full_path, pool));
 
-              /* Detect deep modifications in a directory tree.
-               * The update editor will not visit subdirectories of a
-               * directory it wants to delete. Therefore, we need to start
-               * a separate crawl here. */
-              SVN_ERR(tree_has_local_mods(&modified, full_path, adm_access,
-                                          eb->cancel_func, eb->cancel_baton,
-                                          pool));
-              if (modified)
-                {
-                  reason = svn_wc_conflict_reason_edited;
-                }
+              /* Ensure that the access baton is specific to FULL_PATH,
+               * otherwise the crawl will start at the parent. */
+              if (strcmp(svn_wc_adm_access_path(adm_access), full_path) == 0)
+                SVN_ERR(tree_has_local_mods(&modified, full_path, adm_access,
+                                            eb->cancel_func, eb->cancel_baton,
+                                            pool));
             }
+
+          if (modified)
+            reason = svn_wc_conflict_reason_edited;
+
         }
       break;
     }
@@ -1476,7 +1455,6 @@ check_tree_conflict(svn_wc_conflict_description_t
     {
       svn_wc_conflict_description_t *conflict;
 
-      /* The entry is a tree conflict victim. */
       conflict = svn_wc_conflict_description_create_tree(
         full_path, parent_adm_access, entry->kind,
         eb->switch_url ? svn_wc_operation_switch : svn_wc_operation_update,
@@ -1494,6 +1472,63 @@ check_tree_conflict(svn_wc_conflict_description_t
   return SVN_NO_ERROR;
 }
 
+/* If PATH is inside a conflicted tree, return the tree conflict's victim
+ * in VICTIM_PATH.  Otherwise set VICTIM_PATH to NULL.
+ *
+ *  The search begins at the working copy root, returning the first
+ * ("highest") tree conflict victim, which may be PATH itself.
+ */
+static svn_error_t *
+already_in_a_tree_conflict(char **victim_path,
+                           const char *path,
+                           svn_wc_adm_access_t *adm_access,
+                           apr_pool_t *pool)
+{
+  svn_boolean_t is_wc_root, tree_conflicted;
+  char *ancestor, *abs_path;
+  const svn_wc_entry_t *entry;
+  apr_array_header_t *ancestors;
+  int i;
+
+  *victim_path = NULL;
+  abs_path = apr_pstrdup(pool, path);
+  ancestors = apr_array_make(pool, 0, sizeof(char *));
+
+  /* Find all of the ancestor-dirs in the working copy. */
+  while (! svn_path_is_empty(abs_path))
+    {
+      SVN_ERR(svn_wc_entry(&entry, abs_path, adm_access, FALSE, pool));
+
+      if (entry == NULL)
+        is_wc_root = FALSE; /* svn_wc_is_root() expects an entry. */
+      else  
+        SVN_ERR(svn_wc_is_wc_root(&is_wc_root, abs_path, adm_access, pool));
+
+      if (is_wc_root)
+        break;
+      else
+        APR_ARRAY_PUSH(ancestors, char *) = abs_path;
+
+      abs_path = svn_path_dirname(abs_path, pool);
+    }
+
+  /* From the root end, check the conflict status of each ancestor. */
+  for (i = ancestors->nelts - 1; i >= 0; i--)
+    {
+      ancestor = APR_ARRAY_IDX(ancestors, i, char *);
+      SVN_ERR(svn_wc_conflicted_p2(NULL, NULL, &tree_conflicted, ancestor,
+                                   adm_access, pool));
+      if (tree_conflicted)
+        {
+          *victim_path = ancestor;
+
+          return SVN_NO_ERROR;
+        }
+    }
+
+  return SVN_NO_ERROR;
+}
+
 /* Delete PATH from its immediate parent PARENT_PATH, in the edit
  * represented by EB.  Name temporary transactional logs based on
  * *LOG_NUMBER, but set *LOG_NUMBER to 0 after running the final log.
@@ -1509,6 +1544,7 @@ do_entry_deletion(struct edit_baton *eb,
   svn_wc_adm_access_t *adm_access;
   const svn_wc_entry_t *entry;
   const char *full_path = svn_path_join(eb->anchor, path, pool);
+  char *victim_path;
   svn_stringbuf_t *log_item = svn_stringbuf_create("", pool);
   svn_wc_conflict_description_t *tree_conflict;
   svn_wc_notify_t *notify;
@@ -1531,31 +1567,73 @@ do_entry_deletion(struct edit_baton *eb,
       return SVN_NO_ERROR;
     }
 
-  SVN_ERR(check_tree_conflict(&tree_conflict, eb, log_item, full_path, entry,
-                              adm_access, svn_wc_conflict_action_delete, pool));
+  /* Is an ancestor-dir (already visited by this edit) a tree conflict
+     victim?  If so, skip without notification. */
+  if (eb->current_tree_conflict)
+    {
+      SVN_ERR_ASSERT(svn_path_is_ancestor(eb->current_tree_conflict,
+                                          full_path));
 
-  /* If this raised a tree-conflict, record.  Continue deleting the entry. */
-  if (tree_conflict)
+      remember_skipped_path(eb, full_path);
+
+      return SVN_NO_ERROR;
+    }
+
+  /* Is this path, or an ancestor-dir NOT visited by this edit, already
+     marked as a tree conflict victim? */
+  SVN_ERR(already_in_a_tree_conflict(&victim_path, full_path, adm_access,
+                                     pool));
+
+  /* Is this path the victim of a newly-discovered tree conflict? */
+  tree_conflict = NULL;
+  if (victim_path == NULL)
+    SVN_ERR(check_tree_conflict(&tree_conflict, eb, log_item, full_path,
+                                entry, adm_access, 
+                                svn_wc_conflict_action_delete, pool));
+
+  if (tree_conflict != NULL)
     {
+      /* Run the log immediately, so that the tree conflict is recorded. */
       SVN_ERR(svn_wc__write_log(adm_access, *log_number, log_item, pool));
+      SVN_ERR(svn_wc__run_log(adm_access, NULL, pool));
+      *log_number = 0;
+    }
 
-      /* If the thing being deleted is the *target* of this update, then
-         we may need to recreate an entry, so that the parent can give
-         accurate reports about itself in future. */
-      if (strcmp(path, eb->target) == 0)
-        {
-          svn_wc_entry_t tmp_entry;
+  if (victim_path != NULL || tree_conflict != NULL)
+    {
+      remember_skipped_path(eb, full_path);
+      
+      /* ### TODO: Also print victim_path in the skip msg. */
+      if (eb->notify_func)
+        (*eb->notify_func)(eb->notify_baton, 
+                           svn_wc_create_notify(full_path,
+                                                (tree_conflict != NULL)
+                                                ? svn_wc_notify_tree_conflict
+                                                : svn_wc_notify_skip,
+                                                pool),
+                           pool);
 
-          tmp_entry.revision = *(eb->target_revision);
-          tmp_entry.kind =
-            (entry->kind == svn_node_file) ? svn_node_file : svn_node_dir;
+      return SVN_NO_ERROR;
+    }
 
-          SVN_ERR(svn_wc__loggy_entry_modify(&log_item, adm_access,
-                                             full_path, &tmp_entry,
-                                             SVN_WC__ENTRY_MODIFY_REVISION
-                                             | SVN_WC__ENTRY_MODIFY_KIND,
-                                             pool));
-        }
+  SVN_ERR(svn_wc__write_log(adm_access, *log_number, log_item, pool));
+
+  /* If the thing being deleted is the *target* of this update, then
+     we may need to recreate an entry, so that the parent can give
+     accurate reports about itself in future. */
+  if (strcmp(path, eb->target) == 0)
+    {
+      svn_wc_entry_t tmp_entry;
+
+      tmp_entry.revision = *(eb->target_revision);
+      tmp_entry.kind =
+        (entry->kind == svn_node_file) ? svn_node_file : svn_node_dir;
+
+      SVN_ERR(svn_wc__loggy_entry_modify(&log_item, adm_access,
+                                         full_path, &tmp_entry,
+                                         SVN_WC__ENTRY_MODIFY_REVISION
+                                         | SVN_WC__ENTRY_MODIFY_KIND,
+                                         pool));
     }
 
   SVN_ERR(svn_wc__loggy_delete_entry(&log_item, adm_access, full_path,
@@ -1676,6 +1754,8 @@ add_directory(const char *path,
   struct edit_baton *eb = pb->edit_baton;
   struct dir_baton *db;
   svn_node_kind_t kind;
+  const char *full_path = svn_path_join(eb->anchor, path, pool);
+  char *victim_path;
 
   SVN_ERR(make_dir_baton(&db, path, eb, pb, TRUE, pool));
   *child_baton = db;
@@ -1715,8 +1795,6 @@ add_directory(const char *path,
   /* The path can exist, but it must be a directory... */
   if (kind == svn_node_file || kind == svn_node_unknown)
     {
-      /* ### TODO: raise a tree conflict */
-
     return svn_error_createf
       (SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
        _("Failed to add directory '%s': a non-directory object of the "
@@ -1724,6 +1802,41 @@ add_directory(const char *path,
        svn_path_local_style(db->path, pool));
     }
 
+  /* Is an ancestor-dir (already visited by this edit) a tree conflict
+     victim?  If so, skip without notification. */
+  if (eb->current_tree_conflict)
+    {
+      SVN_ERR_ASSERT(svn_path_is_ancestor(eb->current_tree_conflict,
+                                          full_path));
+
+      remember_skipped_path(eb, full_path);
+
+      return SVN_NO_ERROR;
+    }
+
+  /* Is this path, or an ancestor-dir NOT visited by this edit, already
+     marked as a tree conflict victim? */
+  SVN_ERR(already_in_a_tree_conflict(&victim_path, full_path, eb->adm_access,
+                                     pool));
+
+  if (victim_path != NULL)
+    {
+      /* Record this conflict so that its descendants are skipped silently. */
+      eb->current_tree_conflict = victim_path;
+
+      remember_skipped_path(eb, full_path);
+      
+      /* ### TODO: Also print victim_path in the skip msg. */
+      if (eb->notify_func)
+        (*eb->notify_func)(eb->notify_baton, 
+                           svn_wc_create_notify(full_path,
+                                                svn_wc_notify_skip,
+                                                pool),
+                           pool);
+
+      return SVN_NO_ERROR;
+    }
+
   if (kind == svn_node_dir)
     {
       /* ...Ok, it's a directory but it can't be versioned or
@@ -1803,7 +1916,26 @@ add_directory(const char *path,
                                           pb->log_accum, db->path, entry,
                                           parent_adm_access,
                                           svn_wc_conflict_action_add, pool));
-              db->tree_conflicted = (tree_conflict != NULL);
+
+              if (tree_conflict != NULL)
+                {
+                  /* Record this conflict so that its descendants are skipped silently. */
+                  eb->current_tree_conflict = apr_pstrdup(pool,
+                                                          tree_conflict->path);
+
+                  remember_skipped_path(eb, full_path);
+
+                  /* ### TODO: Also print victim_path in the skip msg. */
+                  if (eb->notify_func)
+                    (*eb->notify_func)(eb->notify_baton, 
+                                       svn_wc_create_notify
+                                       (full_path,
+                                        svn_wc_notify_tree_conflict,
+                                        pool),
+                                       pool);
+
+                  return SVN_NO_ERROR;
+                }
             }
         }
     }
@@ -1816,6 +1948,7 @@ add_directory(const char *path,
          "administrative directory"),
        svn_path_local_style(db->path, pool));
 
+
   /* Either we got real copyfrom args... */
   if (copyfrom_path || SVN_IS_VALID_REVNUM(copyfrom_revision))
     {
@@ -1923,11 +2056,9 @@ add_directory(const char *path,
     {
       svn_wc_notify_t *notify = svn_wc_create_notify(
         db->path,
-        db->tree_conflicted
-          ? svn_wc_notify_tree_conflict
-          : (db->existed
-               ? svn_wc_notify_exists
-               : svn_wc_notify_update_add),
+        db->existed
+        ? svn_wc_notify_exists
+        : svn_wc_notify_update_add,
         pool);
       notify->kind = svn_node_dir;
       (*eb->notify_func)(eb->notify_baton, notify, pool);
@@ -1936,7 +2067,6 @@ add_directory(const char *path,
   return SVN_NO_ERROR;
 }
 
-
 /* An svn_delta_editor_t function. */
 static svn_error_t *
 open_directory(const char *path,
@@ -1954,7 +2084,9 @@ open_directory(const char *path,
 
   svn_wc_adm_access_t *adm_access;
   svn_wc_adm_access_t *parent_adm_access;
+  char *victim_path = NULL;
   svn_wc_conflict_description_t *tree_conflict;
+  svn_boolean_t prop_conflicted;
 
   SVN_ERR(make_dir_baton(&db, path, eb, pb, FALSE, pool));
   *child_baton = db;
@@ -1975,43 +2107,67 @@ open_directory(const char *path,
       db->ambient_depth = entry->depth;
       db->was_incomplete = entry->incomplete;
     }
+ 
+  /* Is an ancestor-dir (already visited by this edit) a tree conflict
+     victim?  If so, skip the tree without notification. */
+  if (eb->current_tree_conflict)
+    {
+      SVN_ERR_ASSERT(svn_path_is_ancestor(eb->current_tree_conflict,
+                                          db->path));
 
-  /* Skip this directory if it already had (property or tree) conflicts. */
-  if (entry)
+      db->bump_info->skipped = TRUE;
+      remember_skipped_path(eb, db->path);
+
+      return SVN_NO_ERROR;
+    }
+
+  /* Is this path, or an ancestor-dir NOT visited by this edit, already a
+     tree conflict victim?  If so, skip the tree with one notification. */
+  SVN_ERR(already_in_a_tree_conflict(&victim_path, db->path, adm_access, pool));
+
+  if (victim_path != NULL)
     {
-      svn_boolean_t prop_conflicted;
-      svn_boolean_t tree_conflicted;
+      eb->current_tree_conflict = victim_path;
+      tree_conflict = NULL;
+    }
+  else
+    /* Is this path a fresh tree conflict victim?  If so, skip the tree
+       with one notification. */
+    SVN_ERR(check_tree_conflict(&tree_conflict, eb, pb->log_accum,
+                                db->path, entry, parent_adm_access,
+                                svn_wc_conflict_action_edit, pool));
 
-      SVN_ERR(svn_wc_conflicted_p2(NULL, &prop_conflicted, &tree_conflicted,
-                                   db->path, adm_access, pool));
-      if (prop_conflicted || tree_conflicted)
+  if (tree_conflict != NULL)
+    eb->current_tree_conflict = apr_pstrdup(pool, tree_conflict->path);
+
+  /* If property-conflicted, skip the dir itself, with notification, but
+     allow its descendants to be updated. */
+  SVN_ERR(svn_wc_conflicted_p2(NULL, &prop_conflicted, NULL, db->path,
+                               adm_access, pool));
+
+  if (victim_path != NULL || tree_conflict != NULL || prop_conflicted)
+    {  
+      db->bump_info->skipped = TRUE;
+      remember_skipped_path(eb, db->path);
+      
+      if (eb->notify_func)
         {
-          db->bump_info->skipped = TRUE;
-          remember_skipped_path(eb, db->path);
-          if (eb->notify_func)
-            {
-              svn_wc_notify_t *notify
-                = svn_wc_create_notify(db->path,
-                                       tree_conflicted
-                                         ? svn_wc_notify_tree_conflict
-                                         : svn_wc_notify_skip,
-                                       pool);
-              notify->kind = svn_node_dir;
-              notify->prop_state = prop_conflicted
-                  ? svn_wc_notify_state_conflicted
-                  : svn_wc_notify_state_unknown;
-              (*eb->notify_func)(eb->notify_baton, notify, pool);
-            }
-          return SVN_NO_ERROR;
+          svn_wc_notify_t *notify
+            = svn_wc_create_notify(db->path,
+                                   prop_conflicted
+                                   ? svn_wc_notify_skip
+                                   : svn_wc_notify_tree_conflict,
+                                   pool);
+          notify->kind = svn_node_dir;
+
+          if (prop_conflicted)
+            notify->prop_state = svn_wc_notify_state_conflicted;
+
+          (*eb->notify_func)(eb->notify_baton, notify, pool);
         }
+      return SVN_NO_ERROR;
     }
 
-  /* Raise a tree conflict if scheduled for deletion or similar. */
-  SVN_ERR(check_tree_conflict(&tree_conflict, eb, pb->log_accum,
-                              db->path, entry, parent_adm_access,
-                              svn_wc_conflict_action_edit, pool));
-  db->tree_conflicted = (tree_conflict != NULL);
-
   /* Mark directory as being at target_revision and URL, but incomplete. */
   tmp_entry.revision = *(eb->target_revision);
   tmp_entry.url = db->new_URL;
@@ -2110,6 +2266,19 @@ close_directory(void *dir_baton,
   apr_hash_t *base_props = NULL, *working_props = NULL;
   svn_wc_adm_access_t *adm_access;
 
+  /* Skip if we're in a conflicted tree.  Remove the tree-conflict flag if
+     we're closing the victim directory. */
+  if (db->edit_baton->current_tree_conflict)
+    {
+      if (strcmp(db->edit_baton->current_tree_conflict, db->path) == 0)
+        db->edit_baton->current_tree_conflict = NULL;
+
+      /* Allow the parent to complete its update. */
+      SVN_ERR(maybe_bump_dir_info(db->edit_baton, db->bump_info, db->pool));
+
+      return SVN_NO_ERROR;
+    }
+
   SVN_ERR(svn_categorize_props(db->propchanges, &entry_props, &wc_props,
                                &regular_props, pool));
 
@@ -2239,9 +2408,9 @@ close_directory(void *dir_baton,
      maybe_bump_dir_info() for more information.  */
   SVN_ERR(maybe_bump_dir_info(db->edit_baton, db->bump_info, db->pool));
 
-  /* Notify of any prop changes or tree conflict on this directory -- but do
-     nothing if it's an added or skipped directory, because notification has
-     already happened in that case - unless the add was obstructed by a dir
+  /* Notify of any prop changes on this directory -- but do nothing if
+     it's an added or skipped directory, because notification has already
+     happened in that case - unless the add was obstructed by a dir
      scheduled for addition without history, in which case we handle
      notification here). */
   if (! db->bump_info->skipped && (db->add_existed || (! db->added))
@@ -2249,11 +2418,9 @@ close_directory(void *dir_baton,
     {
       svn_wc_notify_t *notify
         = svn_wc_create_notify(db->path,
-                               db->tree_conflicted
-                                 ? svn_wc_notify_tree_conflict
-                                 : (db->existed || db->add_existed
-                                      ? svn_wc_notify_exists
-                                      : svn_wc_notify_update_update),
+                               (db->existed || db->add_existed
+                                ? svn_wc_notify_exists
+                                : svn_wc_notify_update_update),
                                pool);
       notify->kind = svn_node_dir;
       notify->prop_state = prop_state;
@@ -2720,6 +2887,9 @@ add_file(const char *path,
   svn_node_kind_t kind;
   svn_wc_adm_access_t *adm_access;
   apr_pool_t *subpool;
+  const char *full_path = svn_path_join(eb->anchor, path, pool);
+  char *victim_path;
+  svn_wc_conflict_description_t *tree_conflict;
 
   if (copyfrom_path || SVN_IS_VALID_REVNUM(copyfrom_rev))
     {
@@ -2729,78 +2899,66 @@ add_file(const char *path,
                                   _("Bad copyfrom arguments received"));
     }
 
+  SVN_ERR(make_file_baton(&fb, pb, path, TRUE, pool));
+  *file_baton = fb;
+
+  /* Is an ancestor-dir (already visited by this edit) a tree conflict
+     victim?  If so, skip without notification. */
+  if (eb->current_tree_conflict)
+    {
+      SVN_ERR_ASSERT(svn_path_is_ancestor(eb->current_tree_conflict,
+                                          full_path));
+
+      fb->skipped = TRUE;
+      remember_skipped_path(eb, full_path);
+
+      return SVN_NO_ERROR;
+    }
+
   /* The file_pool can stick around for a *long* time, so we want to
      use a subpool for any temporary allocations. */
   subpool = svn_pool_create(pool);
 
-  SVN_ERR(make_file_baton(&fb, pb, path, TRUE, pool));
-  *file_baton = fb;
-
-
   SVN_ERR(check_path_under_root(fb->dir_baton->path, fb->name, subpool));
 
-  /* It is interesting to note: everything below is just validation. We
-     aren't actually doing any "work" or fetching any persistent data. */
-
   SVN_ERR(svn_io_check_path(fb->path, &kind, subpool));
   SVN_ERR(svn_wc_adm_retrieve(&adm_access, eb->adm_access,
                               pb->path, subpool));
   SVN_ERR(svn_wc_entry(&entry, fb->path, adm_access, FALSE, subpool));
 
-  /* Sanity checks. */
+  /* Is this path, or an ancestor-dir NOT visited by this edit, already
+     marked as a tree conflict victim? */
+  SVN_ERR(already_in_a_tree_conflict(&victim_path, full_path, adm_access,
+                                     subpool));
 
-  /* Skip file addition if parent directory is in tree-conflict. */
-  if (pb->tree_conflicted)
+  /* Is this path the victim of a newly-discovered tree conflict? */
+  tree_conflict = NULL;
+  if (victim_path == NULL)
+    SVN_ERR(check_tree_conflict(&tree_conflict, eb, pb->log_accum, full_path,
+                                entry, adm_access, 
+                                svn_wc_conflict_action_add, subpool));
+
+  if (victim_path != NULL || tree_conflict != NULL)
     {
-      /* Trying to add a file into a conflicted directory.
-       * The case where the directory raised a tree-conflict just now
-       * doesn't need to report another tree-conflict. The parent
-       * directory already reported one. */
-
-      /* Skip the this add */
       fb->skipped = TRUE;
-      remember_skipped_path(eb, fb->path);
-
-      /* ### TODO: check whether pb->tree_conflicted also reflects
-       * persisting tree-conflicts (older ones), and decide whether to
-       * raise a new one here if so. This is how we would raise it: */
-      /*
-      svn_wc_conflict_description_t *conflict;
-
-      conflict = svn_wc_conflict_description_create_tree(
-        path, adm_access, svn_node_file,
-        eb->switch_url ? svn_wc_operation_switch : svn_wc_operation_update,
-        pool);
-      conflict->action = svn_wc_conflict_action_add;
-      conflict->reason = svn_wc_conflict_reason_obstructed;
-
-      SVN_ERR(svn_wc__loggy_add_tree_conflict(&pb->log_accum, conflict,
-                                              adm_access, pool));
-
+      remember_skipped_path(eb, full_path);
+      
+      /* ### TODO: Also print victim_path in the skip msg. */
       if (eb->notify_func)
-        {
-          svn_wc_notify_t *notify
-            = svn_wc_create_notify(fb->path,
-                                   svn_wc_notify_update_add,
-                                   pool);
+        (*eb->notify_func)(eb->notify_baton, 
+                           svn_wc_create_notify(full_path,
+                                                (tree_conflict != NULL)
+                                                ? svn_wc_notify_tree_conflict
+                                                : svn_wc_notify_skip,
+                                                subpool),
+                           subpool);
 
-          notify->kind = svn_node_file;
+      svn_pool_destroy(subpool);
 
-          notify->tree_conflicted = TRUE;
-          notify->content_state = svn_wc_notify_state_unknown;
-          notify->prop_state = svn_wc_notify_state_unknown;
-
-          (*eb->notify_func)(eb->notify_baton, notify, pool);
-        }
-      */
-
+      return SVN_NO_ERROR;
     }
-  else
-    /* The parent directory is not in conflict.
-     * Raise a tree conflict if there's already something versioned here. */
-    SVN_ERR(check_tree_conflict(NULL, eb, pb->log_accum, path, entry, adm_access,
-                                svn_wc_conflict_action_add, pool));
 
+  /* Sanity checks. */
 
   /* When adding, there should be nothing with this name unless unversioned
      obstructions are permitted or the obstruction is scheduled for addition
@@ -2889,6 +3047,8 @@ open_file(const char *path,
   svn_wc_adm_access_t *adm_access;
   svn_boolean_t text_conflicted;
   svn_boolean_t prop_conflicted;
+  const char *full_path = svn_path_join(eb->anchor, path, pool);
+  char *victim_path;
   svn_wc_conflict_description_t *tree_conflict;
 
   /* the file_pool can stick around for a *long* time, so we want to use
@@ -2916,46 +3076,52 @@ open_file(const char *path,
                              fb->name,
                              svn_path_local_style(pb->path, pool));
 
-  /* If the file is scheduled for deletion, we have a tree conflict.
-   * This is use case 1 described in the paper attached to issue #2282
-   * See also notes/tree-conflicts/detection.txt
-   */
-  SVN_ERR(check_tree_conflict(&tree_conflict, eb, pb->log_accum, fb->path,
-                              entry, adm_access, svn_wc_conflict_action_edit,
-                              subpool));
+  /* Is an ancestor-dir (already visited by this edit) a tree conflict
+     victim?  If so, skip without notification. */
+  if (eb->current_tree_conflict)
+    {
+      SVN_ERR_ASSERT(svn_path_is_ancestor(eb->current_tree_conflict,
+                                          full_path));
 
-  /* It is interesting to note: everything below is just validation. We
-     aren't actually doing any "work" or fetching any persistent data. */
+      fb->skipped = TRUE;
+      remember_skipped_path(eb, full_path);
 
-  /* If the file was already or is now in conflict, don't mess with it. */
+      return SVN_NO_ERROR;
+    }
+
+  /* Is this path, or an ancestor-dir NOT visited by this edit, already
+     marked as a tree conflict victim? */
+  SVN_ERR(already_in_a_tree_conflict(&victim_path, full_path, adm_access,
+                                     pool));
+
+  /* Is this path the victim of a newly-discovered tree conflict? */
+  tree_conflict = NULL;
+  if (victim_path == NULL)
+    SVN_ERR(check_tree_conflict(&tree_conflict, eb, pb->log_accum, full_path,
+                                entry, adm_access, 
+                                svn_wc_conflict_action_edit, pool));
+
+  /* Does the file already have text or property conflicts? */
   SVN_ERR(svn_wc_conflicted_p2(&text_conflicted, &prop_conflicted, NULL,
-                               fb->path, adm_access, subpool));
+                               full_path, adm_access, pool));
 
-  if (text_conflicted || prop_conflicted || (tree_conflict != NULL))
+  if (victim_path != NULL || tree_conflict != NULL || text_conflicted
+      || prop_conflicted)
     {
       fb->skipped = TRUE;
-      remember_skipped_path(eb, fb->path);
+      remember_skipped_path(eb, full_path);
+      
+      /* ### TODO: Also print victim_path in the t-c skip msg. */
       if (eb->notify_func)
-        {
-          svn_wc_notify_t *notify
-            = svn_wc_create_notify(fb->path,
-                                   (tree_conflict != NULL)
-                                     ? svn_wc_notify_tree_conflict
-                                     : svn_wc_notify_skip,
-                                   pool);
+        (*eb->notify_func)(eb->notify_baton, 
+                           svn_wc_create_notify(full_path,
+                                                (tree_conflict != NULL)
+                                                ? svn_wc_notify_tree_conflict
+                                                : svn_wc_notify_skip,
+                                                pool),
+                           pool);
 
-          notify->kind = svn_node_file;
-
-          notify->content_state = text_conflicted
-            ? svn_wc_notify_state_conflicted
-            : svn_wc_notify_state_unknown;
-
-          notify->prop_state = prop_conflicted
-            ? svn_wc_notify_state_conflicted
-            : svn_wc_notify_state_unknown;
-
-          (*eb->notify_func)(eb->notify_baton, notify, pool);
-        }
+      return SVN_NO_ERROR;
     }
 
   svn_pool_destroy(subpool);
@@ -3928,6 +4094,7 @@ make_editor(svn_revnum_t *target_revision,
   eb->allow_unver_obstructions = allow_unver_obstructions;
   eb->skipped_paths            = apr_hash_make(subpool);
   eb->ext_patterns             = preserved_exts;
+  eb->current_tree_conflict    = NULL;
 
   /* Construct an editor. */
   tree_editor->set_target_revision = set_target_revision;
Index: subversion/tests/cmdline/update_tests.py
===================================================================
--- subversion/tests/cmdline/update_tests.py	(revision 34137)
+++ subversion/tests/cmdline/update_tests.py	(working copy)
@@ -659,7 +659,6 @@ def update_delete_modified_files(sbox):
     'A/D/G'       : Item(status='  ', treeconflict='C'),
     })
   expected_disk = svntest.main.greek_state.copy()
-  expected_disk.remove('A/D/G/rho', 'A/D/G/tau')
   expected_disk.tweak('A/B/E/alpha',
                       contents=\
                       "This is the file 'alpha'.\nappended alpha text\n")
@@ -668,21 +667,16 @@ def update_delete_modified_files(sbox):
                       "This is the file 'pi'.\nappended pi text\n")
 
   expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
-  expected_status.remove('A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau',
-                         'A/B/E/alpha')
+  expected_status.tweak('A/B/E/alpha', status ='M ', wc_rev=1,
+                        treeconflict='C')
+  expected_status.tweak('A/D/G/pi', status='M ')
+  expected_status.tweak('A/D/G', wc_rev=1, treeconflict='C')
+
   svntest.actions.run_and_verify_update(wc_dir,
                                         expected_output,
                                         expected_disk,
                                         expected_status)
 
-  # Check status of tree conflict victims.
-  expected_status.add({
-    'A/B/E/alpha' : Item(status='? ', treeconflict='C'),
-    'A/D/G'       : Item(status='? ', treeconflict='C'),
-    })
-  svntest.actions.run_and_verify_unquiet_status(wc_dir, expected_status)
-
-
 #----------------------------------------------------------------------
 
 # Issue 847.  Doing an add followed by a remove for an item in state
@@ -1023,8 +1017,8 @@ def update_deleted_missing_dir(sbox):
 
   # Create expected output tree for an update of the missing items by name
   expected_output = svntest.wc.State(wc_dir, {
-    'A/B/E' : Item(status='  ', treeconflict='C'),
-    'A/D/H' : Item(status='  ', treeconflict='C'),
+    'A/B/E' : Item(status='D '),
+    'A/D/H' : Item(status='D '),
     })
 
   # Create expected disk tree for the update.
@@ -1045,36 +1039,10 @@ def update_deleted_missing_dir(sbox):
                                         None, None, None, None, None,
                                         0, "-r", "2", E_path, H_path)
 
-  # Check tree conflict status
-  unquiet_status = expected_status.copy()
-  unquiet_status.add({
-    'A/B/E' : Item(status='! ', treeconflict='C'),
-    'A/D/H' : Item(status='! ', treeconflict='C'),
-    })
-  svntest.actions.run_and_verify_unquiet_status(wc_dir, unquiet_status)
-
-  # This update created tree conflicts ("update tried to
-  # delete a directory that was locally deleted"), marking
-  # C  A/B
-  # C  A/D
-  # Just ignore them, i.e. resolve.
-  B_path = os.path.join(wc_dir, 'A', 'B')
-  D_path = os.path.join(wc_dir, 'A', 'D')
-  svntest.main.run_svn(None, 'resolved',  B_path, D_path)
-
   # Update back to the old revision again
   svntest.main.run_svn(None,
                        'up', '-r', '1', wc_dir)
 
-  # Delete the directories from disk
-  svntest.main.safe_rmtree(E_path)
-  svntest.main.safe_rmtree(H_path)
-
-  expected_output = svntest.wc.State(wc_dir, {
-    'A/B/E' : Item(status='D '),
-    'A/D/H' : Item(status='D '),
-    })
-
   # This time we're updating the whole working copy
   expected_status.tweak(wc_rev=2)
 
@@ -1125,21 +1093,11 @@ def another_hudson_problem(sbox):
   # Sigh, I can't get run_and_verify_update to work (but not because
   # of issue 919 as far as I can tell)
   svntest.actions.run_and_verify_svn(None,
-                                     ['   C '+G_path+'\n',
-                                      'At revision 3.\n',
-                                      'Summary of conflicts:\n',
-                                      '  Tree conflicts: 1\n',
+                                     ['D    '+G_path+'\n',
+                                      'Updated to revision 3.\n',
                                       ], [],
                                      'up', G_path)
 
-  # This update created a tree conflict ("update tried to
-  # delete a directory that was locally deleted"), marking
-  #    C A/D. Just ignore it, i.e. resolve it.
-  D_path = os.path.join(wc_dir, 'A', 'D')
-  svntest.actions.run_and_verify_svn(None,
-    ["Resolved conflicted state of '" + D_path + "'\n"], [],
-    'resolved',  D_path)
-
   # Both G and gamma should be 'deleted', update should produce no output
   expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
   expected_status.remove('A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau',
@@ -3961,14 +3919,19 @@ leaf_edit = svntest.actions.deep_trees_leaf_edit
 tree_del = svntest.actions.deep_trees_tree_del
 leaf_del = svntest.actions.deep_trees_leaf_del
 
-state_after_leaf_edit = svntest.actions.deep_trees_after_leaf_edit
-state_after_leaf_del = svntest.actions.deep_trees_after_leaf_del
-state_after_tree_del = svntest.actions.deep_trees_after_tree_del
+disk_after_leaf_edit = svntest.actions.deep_trees_after_leaf_edit
+disk_after_leaf_del = svntest.actions.deep_trees_after_leaf_del
+disk_after_tree_del = svntest.actions.deep_trees_after_tree_del
 
 state_empty_dirs = svntest.actions.deep_trees_empty_dirs
 
 deep_trees_conflict_output = svntest.actions.deep_trees_conflict_output
-deep_trees_conflict_status = svntest.actions.deep_trees_conflict_status
+deep_trees_conflict_output_skipped = \
+    svntest.actions.deep_trees_conflict_output_skipped
+deep_trees_status_local_tree_del = \
+    svntest.actions.deep_trees_status_local_tree_del
+deep_trees_status_local_leaf_edit = \
+    svntest.actions.deep_trees_status_local_leaf_edit
 
 DeepTreesTestCase = svntest.actions.DeepTreesTestCase
 
@@ -3979,52 +3942,17 @@ def tree_conflicts_on_update_1_1(sbox):
   # use case 1, as in notes/tree-conflicts/use-cases.txt
   # 1.1) local tree delete, incoming leaf edit
 
-  expected_output = svntest.wc.State('', {
-    'F/alpha'           : Item(status='  ', treeconflict='C'),
-    'D/D1'              : Item(status='  ', treeconflict='C'),
-    'DF/D1'             : Item(status='  ', treeconflict='C'),
-    'DF/D1/beta'        : Item(status='  ', treeconflict='C'),
-    'DD/D1'             : Item(status='  ', treeconflict='C'),
-    'DD/D1/D2'          : Item(status='  ', treeconflict='C'),
-    'DDF/D1'            : Item(status='  ', treeconflict='C'),
-    'DDF/D1/D2'         : Item(status='  ', treeconflict='C'),
-    'DDF/D1/D2/gamma'   : Item(status='  ', treeconflict='C'),
-    'DDD/D1'            : Item(status='  ', treeconflict='C'),
-    'DDD/D1/D2'         : Item(status='  ', treeconflict='C'),
-    'DDD/D1/D2/D3'      : Item(status='  ', treeconflict='C'),
-    })
+  expected_output = deep_trees_conflict_output
 
-  # The directory structure is scheduled for delete but is still
-  # found on disk, because the way directory deletes are handled by svn.
-  # No files are present because alpha, beta, gamma were locally removed
-  # and delta, epsilon, zeta weren't added due to tree-conflicts in their
-  # respective parent directories.
-  expected_disk = state_after_leaf_edit.copy()
-  expected_disk.remove('F/alpha', 'DF/D1/beta', 'DDF/D1/D2/gamma',
-                       'D/D1/delta', 'DD/D1/D2/epsilon', 'DDD/D1/D2/D3/zeta')
+  expected_disk = state_empty_dirs
 
-  ### Current behavior fails to show a status on files that would
-  ### have been added if there hadn't been a tree-conflict.
-  expected_status = svntest.wc.State('', {
-    ''                  : Item(status='  ', wc_rev='3'),
-    'D'                 : Item(status='  ', wc_rev='3'),
-    'D/D1'              : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DD'                : Item(status='  ', wc_rev='3'),
-    'DD/D1'             : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DD/D1/D2'          : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDD'               : Item(status='  ', wc_rev='3'),
-    'DDD/D1'            : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDD/D1/D2'         : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDD/D1/D2/D3'      : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDF'               : Item(status='  ', wc_rev='3'),
-    'DDF/D1'            : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDF/D1/D2'         : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDF/D1/D2/gamma'   : Item(status='D ', treeconflict='C', wc_rev='2'),
-    'DF'                : Item(status='  ', wc_rev='3'),
-    'DF/D1'             : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DF/D1/beta'        : Item(status='D ', treeconflict='C', wc_rev='2'),
-    'F'                 : Item(status='  ', wc_rev='3'),
-    'F/alpha'           : Item(status='D ', treeconflict='C', wc_rev='2'),
+  # Files delta, epsilon, and zeta are not in the working copy, but
+  # "unquiet" status includes them.
+  expected_status = deep_trees_status_local_tree_del.copy()
+  expected_status.add({
+    'D/D1/delta'        : Item(status='  '),
+    'DD/D1/D2/epsilon'  : Item(status='  '),
+    'DDD/D1/D2/D3/zeta' : Item(status='  '),
     })
 
   svntest.actions.deep_trees_run_tests_scheme_for_update(sbox,
@@ -4035,58 +3963,17 @@ def tree_conflicts_on_update_1_1(sbox):
                         expected_disk,
                         expected_status) ] )
 
-  ### This test (and others like it) will eventually be much simpler:
 
-                     #  ...
-                     #  deep_trees_conflict_output,
-                     #  state_after_leaf_edit,
-                     #  deep_trees_conflict_status(state_after_leaf_edit)) ] )
-
-
 def tree_conflicts_on_update_1_2(sbox):
   "tree conflicts on update 1.2"
 
   # 1.2) local tree delete, incoming leaf delete
 
-  expected_output = svntest.wc.State('', {
-    'F/alpha'           : Item(status='  ', treeconflict='C'),
-    'D/D1'              : Item(status='  ', treeconflict='C'),
-    'DF/D1'             : Item(status='  ', treeconflict='C'),
-    'DF/D1/beta'        : Item(status='  ', treeconflict='C'),
-    'DD/D1'             : Item(status='  ', treeconflict='C'),
-    'DD/D1/D2'          : Item(status='  ', treeconflict='C'),
-    'DDF/D1'            : Item(status='  ', treeconflict='C'),
-    'DDF/D1/D2'         : Item(status='  ', treeconflict='C'),
-    'DDF/D1/D2/gamma'   : Item(status='  ', treeconflict='C'),
-    'DDD/D1'            : Item(status='  ', treeconflict='C'),
-    'DDD/D1/D2'         : Item(status='  ', treeconflict='C'),
-    'DDD/D1/D2/D3'      : Item(status='  ', treeconflict='C'),
-    })
+  expected_output = deep_trees_conflict_output
 
-  expected_disk = state_after_leaf_del
+  expected_disk = state_empty_dirs
 
-  expected_status = svntest.wc.State('', {
-    ''                  : Item(status='  ', wc_rev='3'),
-    'D'                 : Item(status='  ', wc_rev='3'),
-    'DD'                : Item(status='  ', wc_rev='3'),
-    'DD/D1'             : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDD'               : Item(status='  ', wc_rev='3'),
-    'DDD/D1'            : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDD/D1/D2'         : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDF'               : Item(status='  ', wc_rev='3'),
-    'DDF/D1'            : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DDF/D1/D2'         : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'DF'                : Item(status='  ', wc_rev='3'),
-    'DF/D1'             : Item(status='D ', treeconflict='C', wc_rev='3'),
-    'F'                 : Item(status='  ', wc_rev='3'),
-    'F/alpha'           : Item(status='! ', treeconflict='C'),
-    'D/D1'              : Item(status='! ', treeconflict='C'),
-    'DF/D1/beta'        : Item(status='! ', treeconflict='C'),
-    'DD/D1/D2'          : Item(status='! ', treeconflict='C'),
-    'DDF/D1/D2/gamma'   : Item(status='! ', treeconflict='C'),
-    'DDD/D1/D2/D3'      : Item(status='! ', treeconflict='C'),
-    })
-
+  expected_status = deep_trees_status_local_tree_del
   svntest.actions.deep_trees_run_tests_scheme_for_update(sbox,
     [ DeepTreesTestCase("local_tree_del_incoming_leaf_del",
                         tree_del,
@@ -4102,32 +3989,36 @@ def tree_conflicts_on_update_2_1(sbox):
   # use case 2, as in notes/tree-conflicts/use-cases.txt
   # 2.1) local leaf edit, incoming tree delete
 
-  expected_output = svntest.wc.State('', {
-    'D/D1'              : Item(status='  ', treeconflict='C'),
-    'F/alpha'           : Item(status='  ', treeconflict='C'),
-    'DD/D1'             : Item(status='  ', treeconflict='C'),
-    'DF/D1'             : Item(status='  ', treeconflict='C'),
-    'DDD/D1'            : Item(status='  ', treeconflict='C'),
-    'DDF/D1'            : Item(status='  ', treeconflict='C'),
-    })
+  expected_output = deep_trees_conflict_output
 
-  expected_disk = state_after_leaf_edit
+  expected_disk = disk_after_leaf_edit
 
+  ### Descendants of t.c. victims should be at r2!
+#  expected_status = deep_trees_status_local_leaf_edit
   expected_status = svntest.wc.State('', {
-    ''                  : Item(status='  ', wc_rev='3'),
-    'D'                 : Item(status='  ', wc_rev='3'),
-    'DD'                : Item(status='  ', wc_rev='3'),
-    'DDD'               : Item(status='  ', wc_rev='3'),
-    'DDF'               : Item(status='  ', wc_rev='3'),
-    'DF'                : Item(status='  ', wc_rev='3'),
-    'F'                 : Item(status='  ', wc_rev='3'),
-    'D/D1'              : Item(status='? ', treeconflict='C'),
-    'F/alpha'           : Item(status='? ', treeconflict='C'),
-    'DD/D1'             : Item(status='? ', treeconflict='C'),
-    'DF/D1'             : Item(status='? ', treeconflict='C'),
-    'DDD/D1'            : Item(status='? ', treeconflict='C'),
-    'DDF/D1'            : Item(status='? ', treeconflict='C'),
-    })
+  ''                  : Item(status='  ', wc_rev=3),
+  'D'                 : Item(status='  ', wc_rev=3),
+  'D/D1'              : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'D/D1/delta'        : Item(status='A ', wc_rev=0),
+  'DD'                : Item(status='  ', wc_rev=3),
+  'DD/D1'             : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DD/D1/D2'          : Item(status='  ', wc_rev=3),
+  'DD/D1/D2/epsilon'  : Item(status='A ', wc_rev=0),
+  'DDD'               : Item(status='  ', wc_rev=3),
+  'DDD/D1'            : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DDD/D1/D2'         : Item(status='  ', wc_rev=3),
+  'DDD/D1/D2/D3'      : Item(status='  ', wc_rev=3),
+  'DDD/D1/D2/D3/zeta' : Item(status='A ', wc_rev=0),
+  'DDF'               : Item(status='  ', wc_rev=3),
+  'DDF/D1'            : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DDF/D1/D2'         : Item(status='  ', wc_rev=3),
+  'DDF/D1/D2/gamma'   : Item(status='M ', wc_rev=3),
+  'DF'                : Item(status='  ', wc_rev=3),
+  'DF/D1'             : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DF/D1/beta'        : Item(status='M ', wc_rev=3),
+  'F'                 : Item(status='  ', wc_rev=3),
+  'F/alpha'           : Item(status='M ', wc_rev=2, treeconflict='C'),
+  })
 
   svntest.actions.deep_trees_run_tests_scheme_for_update(sbox,
     [ DeepTreesTestCase("local_leaf_edit_incoming_tree_del",
@@ -4156,7 +4047,20 @@ def tree_conflicts_on_update_2_2(sbox):
     'DDF/D1'            : Item(status='D '),
     })
 
-  expected_disk = state_after_tree_del
+  expected_disk = svntest.actions.deep_trees_virginal_state.copy()
+  expected_disk.remove(
+    'F/alpha',
+    'DF/D1',
+    'DF/D1/beta',
+    'DD/D1',
+    'DD/D1/D2',
+    'DDF/D1',
+    'DDF/D1/D2',
+    'DDF/D1/D2/gamma',
+    'DDD/D1',
+    'DDD/D1/D2',
+    'DDD/D1/D2/D3',
+    )
 
   expected_status = svntest.wc.State('', {
     ''                  : Item(status='  ', wc_rev='3'),
@@ -4166,8 +4070,8 @@ def tree_conflicts_on_update_2_2(sbox):
     'DDF'               : Item(status='  ', wc_rev='3'),
     'DF'                : Item(status='  ', wc_rev='3'),
     'F'                 : Item(status='  ', wc_rev='3'),
-    'D/D1'              : Item(status='! ', treeconflict='C'),
-    'F/alpha'           : Item(status='! ', treeconflict='C'),
+    'D/D1'              : Item(status='D ', wc_rev=2, treeconflict='C'),
+    'F/alpha'           : Item(status='D ', wc_rev=2, treeconflict='C'),
     })
 
   svntest.actions.deep_trees_run_tests_scheme_for_update(sbox,
@@ -4179,38 +4083,102 @@ def tree_conflicts_on_update_2_2(sbox):
                         expected_status) ] )
 
 
+def tree_conflicts_on_update_2_3(sbox):
+  "tree conflicts on update 2.3"
+
+  # Test that existing tree conflicts are skipped
+
+  expected_output = deep_trees_conflict_output_skipped
+
+  expected_disk = disk_after_leaf_edit
+
+  ### Descendants of t.c. victims should be at r2!
+#  expected_status = deep_trees_status_local_leaf_edit
+  expected_status = svntest.wc.State('', {
+  ''                  : Item(status='  ', wc_rev=3),
+  'D'                 : Item(status='  ', wc_rev=3),
+  'D/D1'              : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'D/D1/delta'        : Item(status='A ', wc_rev=0),
+  'DD'                : Item(status='  ', wc_rev=3),
+  'DD/D1'             : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DD/D1/D2'          : Item(status='  ', wc_rev=3),
+  'DD/D1/D2/epsilon'  : Item(status='A ', wc_rev=0),
+  'DDD'               : Item(status='  ', wc_rev=3),
+  'DDD/D1'            : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DDD/D1/D2'         : Item(status='  ', wc_rev=3),
+  'DDD/D1/D2/D3'      : Item(status='  ', wc_rev=3),
+  'DDD/D1/D2/D3/zeta' : Item(status='A ', wc_rev=0),
+  'DDF'               : Item(status='  ', wc_rev=3),
+  'DDF/D1'            : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DDF/D1/D2'         : Item(status='  ', wc_rev=3),
+  'DDF/D1/D2/gamma'   : Item(status='M ', wc_rev=3),
+  'DF'                : Item(status='  ', wc_rev=3),
+  'DF/D1'             : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DF/D1/beta'        : Item(status='M ', wc_rev=3),
+  'F'                 : Item(status='  ', wc_rev=3),
+  'F/alpha'           : Item(status='M ', wc_rev=2, treeconflict='C'),
+  })
+
+  # Paths where output should be a single 'Skipped' message.
+  skip_paths = [
+    'D/D1',
+    'F/alpha',
+    'DDD/D1',
+    'DDD/D1/D2/D3',  ### No output!
+    ]
+
+  chdir_skip_paths = [
+    ('D', 'D1'),
+    ('D/D1', ''),  ### 16005: path does not exist (in repo)
+    ('F', 'alpha'),
+    ('DDD', 'D1'),
+    ('DDD/D1/D2/D3', ''), ### ditto
+    ]
+
+  svntest.actions.deep_trees_skipping_on_update(sbox,
+    DeepTreesTestCase("local_leaf_edit_incoming_tree_del",
+                      leaf_edit,
+                      tree_del,
+                      expected_output,
+                      expected_disk,
+                      expected_status),
+                                                skip_paths,
+                                                chdir_skip_paths)
+
+
 def tree_conflicts_on_update_3(sbox):
   "tree conflicts on update 3"
 
   # use case 3, as in notes/tree-conflicts/use-cases.txt
   # local tree delete, incoming tree delete
 
-  expected_output = svntest.wc.State('', {
-    'D/D1'              : Item(status='  ', treeconflict='C'),
-    'F/alpha'           : Item(status='  ', treeconflict='C'),
-    'DD/D1'             : Item(status='  ', treeconflict='C'),
-    'DF/D1'             : Item(status='  ', treeconflict='C'),
-    'DDD/D1'            : Item(status='  ', treeconflict='C'),
-    'DDF/D1'            : Item(status='  ', treeconflict='C'),
-    })
+  expected_output = deep_trees_conflict_output
 
-  expected_disk = state_after_tree_del
+  expected_disk = state_empty_dirs
 
+  ### Descendants of t.c. victims should be at r2!
+#  expected_status = deep_trees_status_local_tree_del
   expected_status = svntest.wc.State('', {
-    ''                  : Item(status='  ', wc_rev='3'),
-    'D'                 : Item(status='  ', wc_rev='3'),
-    'DD'                : Item(status='  ', wc_rev='3'),
-    'DDD'               : Item(status='  ', wc_rev='3'),
-    'DDF'               : Item(status='  ', wc_rev='3'),
-    'DF'                : Item(status='  ', wc_rev='3'),
-    'F'                 : Item(status='  ', wc_rev='3'),
-    'D/D1'              : Item(status='! ', treeconflict='C'),
-    'F/alpha'           : Item(status='! ', treeconflict='C'),
-    'DD/D1'             : Item(status='! ', treeconflict='C'),
-    'DF/D1'             : Item(status='! ', treeconflict='C'),
-    'DDD/D1'            : Item(status='! ', treeconflict='C'),
-    'DDF/D1'            : Item(status='! ', treeconflict='C'),
-    })
+  ''                  : Item(status='  ', wc_rev=3),
+  'D'                 : Item(status='  ', wc_rev=3),
+  'D/D1'              : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DD'                : Item(status='  ', wc_rev=3),
+  'DD/D1'             : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DD/D1/D2'          : Item(status='D ', wc_rev=3),
+  'DDD'               : Item(status='  ', wc_rev=3),
+  'DDD/D1'            : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DDD/D1/D2'         : Item(status='D ', wc_rev=3),
+  'DDD/D1/D2/D3'      : Item(status='D ', wc_rev=3),
+  'DDF'               : Item(status='  ', wc_rev=3),
+  'DDF/D1'            : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DDF/D1/D2'         : Item(status='D ', wc_rev=3),
+  'DDF/D1/D2/gamma'   : Item(status='D ', wc_rev=3),
+  'DF'                : Item(status='  ', wc_rev=3),
+  'DF/D1'             : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DF/D1/beta'        : Item(status='D ', wc_rev=3),
+  'F'                 : Item(status='  ', wc_rev=3),
+  'F/alpha'           : Item(status='D ', wc_rev=2, treeconflict='C'),
+  })
 
   svntest.actions.deep_trees_run_tests_scheme_for_update(sbox,
     [ DeepTreesTestCase("local_tree_del_incoming_tree_del",
@@ -4280,6 +4248,7 @@ test_list = [ None,
               tree_conflicts_on_update_1_2,
               tree_conflicts_on_update_2_1,
               tree_conflicts_on_update_2_2,
+              XFail(tree_conflicts_on_update_2_3),
               tree_conflicts_on_update_3,
              ]
 
Index: subversion/tests/cmdline/svntest/tree.py
===================================================================
--- subversion/tests/cmdline/svntest/tree.py	(revision 34137)
+++ subversion/tests/cmdline/svntest/tree.py	(working copy)
@@ -699,7 +699,7 @@ def build_generic_tree(nodelist):
 # Parse co/up output into a tree.
 #
 #   Tree nodes will contain no contents, a 'status' att, and a
-#   'writelocked' att.
+#   'treeconflict' att.
 
 def build_tree_from_checkout(lines, include_skipped=1):
   "Return a tree derived by parsing the output LINES from 'co' or 'up'."
Index: subversion/tests/cmdline/svntest/actions.py
===================================================================
--- subversion/tests/cmdline/svntest/actions.py	(revision 34137)
+++ subversion/tests/cmdline/svntest/actions.py	(working copy)
@@ -1864,26 +1864,76 @@ deep_trees_empty_dirs = wc.State('', {
   'DDD/D1/D2/D3'    : Item(),
   })
 
-# Expected merge/update/switch output if tree conflict detection really works.
+# Expected merge/update/switch output.
+
 deep_trees_conflict_output = wc.State('', {
-  'F/alpha'           : Item(treeconflict='C'),
-  'D/D1'              : Item(treeconflict='C'),
-  'DF/D1'             : Item(treeconflict='C'),
-  'DD/D1'             : Item(treeconflict='C'),
-  'DDF/D1'            : Item(treeconflict='C'),
-  'DDD/D1'            : Item(treeconflict='C'),
+  'F/alpha'           : Item(status='  ', treeconflict='C'),
+  'D/D1'              : Item(status='  ', treeconflict='C'),
+  'DF/D1'             : Item(status='  ', treeconflict='C'),
+  'DD/D1'             : Item(status='  ', treeconflict='C'),
+  'DDF/D1'            : Item(status='  ', treeconflict='C'),
+  'DDD/D1'            : Item(status='  ', treeconflict='C'),
   })
 
-# Expected status output if tree conflict detection really works.
-def deep_trees_conflict_status(expected_disk):
-  """Add tree conflicts and default status stuff to a disk-state dict."""
-  status = expected_disk.copy()
-  status.tweak('F', 'D', 'DF', 'DD', 'DDF', 'DDD', treeconflict='C ')
-  status.add({ '' : Item(status='  ') })
-  status.tweak(wc_rev=3)
-  return status
+deep_trees_conflict_output_skipped = wc.State('', {
+  'D/D1'              : Item(verb='Skipped'),
+  'F/alpha'           : Item(verb='Skipped'),
+  'DD/D1'             : Item(verb='Skipped'),
+  'DF/D1'             : Item(verb='Skipped'),
+  'DDD/D1'            : Item(verb='Skipped'),
+  'DDF/D1'            : Item(verb='Skipped'),
+  })
 
+# Expected status output after merge/update/switch.
 
+deep_trees_status_local_tree_del = wc.State('', {
+  ''                  : Item(status='  ', wc_rev=3),
+  'D'                 : Item(status='  ', wc_rev=3),
+  'D/D1'              : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DD'                : Item(status='  ', wc_rev=3),
+  'DD/D1'             : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DD/D1/D2'          : Item(status='D ', wc_rev=2),
+  'DDD'               : Item(status='  ', wc_rev=3),
+  'DDD/D1'            : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DDD/D1/D2'         : Item(status='D ', wc_rev=2),
+  'DDD/D1/D2/D3'      : Item(status='D ', wc_rev=2),
+  'DDF'               : Item(status='  ', wc_rev=3),
+  'DDF/D1'            : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DDF/D1/D2'         : Item(status='D ', wc_rev=2),
+  'DDF/D1/D2/gamma'   : Item(status='D ', wc_rev=2),
+  'DF'                : Item(status='  ', wc_rev=3),
+  'DF/D1'             : Item(status='D ', wc_rev=2, treeconflict='C'),
+  'DF/D1/beta'        : Item(status='D ', wc_rev=2),
+  'F'                 : Item(status='  ', wc_rev=3),
+  'F/alpha'           : Item(status='D ', wc_rev=2, treeconflict='C'),
+  })
+
+deep_trees_status_local_leaf_edit = wc.State('', {
+  ''                  : Item(status='  ', wc_rev=3),
+  'D'                 : Item(status='  ', wc_rev=3),
+  'D/D1'              : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'D/D1/delta'        : Item(status='A ', wc_rev=0),
+  'DD'                : Item(status='  ', wc_rev=3),
+  'DD/D1'             : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DD/D1/D2'          : Item(status='  ', wc_rev=2),
+  'DD/D1/D2/epsilon'  : Item(status='A ', wc_rev=0),
+  'DDD'               : Item(status='  ', wc_rev=3),
+  'DDD/D1'            : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DDD/D1/D2'         : Item(status='  ', wc_rev=2),
+  'DDD/D1/D2/D3'      : Item(status='  ', wc_rev=2),
+  'DDD/D1/D2/D3/zeta' : Item(status='A ', wc_rev=0),
+  'DDF'               : Item(status='  ', wc_rev=3),
+  'DDF/D1'            : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DDF/D1/D2'         : Item(status='  ', wc_rev=2),
+  'DDF/D1/D2/gamma'   : Item(status='M ', wc_rev=2),
+  'DF'                : Item(status='  ', wc_rev=3),
+  'DF/D1'             : Item(status='  ', wc_rev=2, treeconflict='C'),
+  'DF/D1/beta'        : Item(status='M ', wc_rev=2),
+  'F'                 : Item(status='  ', wc_rev=3),
+  'F/alpha'           : Item(status='M ', wc_rev=2, treeconflict='C'),
+  })
+
+
 class DeepTreesTestCase:
   """Describes one tree-conflicts test case.
   See deep_trees_run_tests_scheme_for_update(), ..._switch(), ..._merge().
@@ -2036,7 +2086,8 @@ def deep_trees_run_tests_scheme_for_update(sbox, g
 
       run_and_verify_update(base, x_out, x_disk, None,
                             error_re_string = test_case.error_re_string)
-      run_and_verify_unquiet_status(base, x_status)
+      if x_status:
+        run_and_verify_unquiet_status(base, x_status)
     except:
       print("ERROR IN: Tests scheme for update: "
           + "while verifying in '%s'" % test_case.name)
@@ -2044,6 +2095,63 @@ def deep_trees_run_tests_scheme_for_update(sbox, g
 
 
 
+def deep_trees_skipping_on_update(sbox, test_case, skip_paths,
+                                  chdir_skip_paths):
+  """
+  Create tree conflicts, then update again, expecting the existing tree
+  conflicts to be skipped.
+  """
+
+  j = os.path.join
+  wc_dir = sbox.wc_dir
+
+  # Initialize silently.
+  setup_case = DeepTreesTestCase(test_case.name,
+                                 test_case.local_action,
+                                 test_case.incoming_action,
+                                 None,
+                                 None,
+                                 None)
+  deep_trees_run_tests_scheme_for_update(sbox, [setup_case])
+
+  # Update whole working copy again.
+  base = j(wc_dir, test_case.name)
+
+  x_out = test_case.expected_output
+  if x_out != None:
+    x_out = x_out.copy()
+    x_out.wc_dir = base
+
+  x_disk = test_case.expected_disk
+
+  x_status = test_case.expected_status
+  if x_status != None:
+    x_status.copy()
+    x_status.wc_dir = base
+
+  run_and_verify_update(base, x_out, x_disk, None,
+                        error_re_string = test_case.error_re_string)
+
+  # Update subtrees, expecting a single 'Skipped' output for each one.
+  for path in skip_paths:
+    run_and_verify_update(j(base, path),
+                          wc.State(base, {path : Item(verb='Skipped')}),
+                          None, None)
+
+  # Update subtrees, expecting a single 'Skipped' output for each one.
+  # This time, cd to the subdir before .
+  was_cwd = os.getcwd()
+  for path, skipped in chdir_skip_paths:
+    print("CHDIR TO: %s" % j(base, path))
+    os.chdir(j(base, path))
+    run_and_verify_update('',
+                          wc.State('', {skipped : Item(verb='Skipped')}),
+                          None, None)
+    os.chdir(was_cwd)
+
+  run_and_verify_unquiet_status(base, x_status)
+
+
 def deep_trees_run_tests_scheme_for_switch(sbox, greater_scheme):
   """
   Runs a given list of tests for conflicts occuring at a switch operation.


