(This is a log message for changes on ^/branches/1.6.x-r38000@39646, compared
 with the last caught-up revision of its parent, ^/branches/1.6.x@39641. This
 log message was written by Julian Foad from the source code diff, the branch
 log messages and the original trunk log messages.)

Fix errors in tree conflict handling to do with node replacements. Issue #3486.
Reduce the opportunities for hitting the "Attempt to add tree conflict that
already exists" error.

* subversion/libsvn_client/merge.c
  (make_tree_conflict): New function, factored out of tree_conflict().
  (tree_conflict): Factor out a chunk into make_tree_conflict().
  (tree_conflict_on_add): New function, like tree_conflict() but will combine
    an existing action=delete conflict with a new action=add conflict to make
    a single conflict (setting action=delete, the best we can do for lack of
    a "replace" action in v1.6.x). In any other case where a tree conflict
    already exists, leave the existing one in place and ignore the second one.
  (merge_file_added): Use tree_conflict_on_add() instead of tree_conflict() so
    an incoming file replacement results in a single tree conflict instead of
    an (abortive) attempt to add two tree conflicts on the same victim.
    Check for a tree conflict in more cases.
  (merge_dir_added): Use tree_conflict_on_add() instead of tree_conflict() so
    an incoming dir replacement results in a single tree conflict instead of
    an (abortive) attempt to add two tree conflicts on the same victim.
  (merge_dir_deleted): If the attempt to delete an existing directory fails,
    the directory has local modifications, so flag a tree conflict.

* subversion/libsvn_client/repos_diff.c
  Fix duplicate notifications for a merge tree-conflict with an incoming
  replace. Rearrange the notification code for clarity.
  (add_directory, close_file): In each function, ensure only one notification
    is sent. Previously, if an earlier incoming deletion on this path had
    raised a tree conflict, then this code sent one notification for the tree
    conflict and another for the result of the present action. (The file-
    replaced-with-file case was visible on the trunk in merge_tests.py
    merge_replace_causes_tree_conflict2 on file A/mu during the final
    merge: there was an additional "A" notification for A/mu.) Don't bother
    setting NOTIFY's LOCK_STATE in case of a tree-conflict notification.
  (close_directory): Don't notify on paths already notified by add_directory().

* subversion/libsvn_wc/update_editor.c
  (schedule_existing_item_for_re_add): Add an option to leave the item's
    copy-from info alone, in order to handle a node that was scheduled for
    replacement rather than modified.
  (do_entry_deletion): If we raise a tree conflict because the node is locally
    replaced, re-schedule the node for addition (with or without history)
    rather than trying to delete it.

* subversion/tests/cmdline/merge_tests.py
  (delete_file_and_dir): On an incoming delete of a directory with local mods,
    expect a tree conflict instead of a skip.
  (merge_replace_causes_tree_conflict): New test.
  (test_list): Add the new test.

