Index: subversion/clients/cmdline/notify.c
===================================================================
--- subversion/clients/cmdline/notify.c	(revision 11937)
+++ subversion/clients/cmdline/notify.c	(working copy)
@@ -47,6 +47,7 @@
                                     when we've already had one print error. */
   apr_pool_t *pool; /* this pool is cleared after every notification,
                        so don't keep anything here! */
+  svn_string_t* deleted_path; /* What was the path that was deleted? */
 };
 
 
@@ -69,6 +70,20 @@
 
   path_local = svn_path_local_style (path, nb->pool);
 
+  /* If the last action was a delete (deleted_path is set) 
+   * and this action is not an add or if the paths don't match, then
+   * this isn't a replacement and print out the delete notification */
+  if (nb->deleted_path != NULL && (action != svn_wc_notify_update_add ||
+       ! svn_string_compare(nb->deleted_path, 
+         svn_string_create(path_local, nb->pool))))
+    {
+      const char *p = nb->deleted_path->data;
+      nb->deleted_path = NULL;
+      nb->received_some_change = TRUE;
+      if ((err = svn_cmdline_printf (nb->pool, "D  %s\n", p)))
+        goto print_error;
+    }
+  
   switch (action)
     {
     case svn_wc_notify_skip:
@@ -87,16 +102,35 @@
         }
       break;
 
+    /* Save the path for later.  The code above prints out the delete
+     * notification if the next action isn't an addition of the same
+     * path.
+     *
+     * It is safe to defer this since svn_wc_notify_update_completed
+     * is guaranteed to be the last action and therefore there will be
+     * at least on more call to notify after this one. */
     case svn_wc_notify_update_delete:
-      nb->received_some_change = TRUE;
-      if ((err = svn_cmdline_printf (nb->pool, "D  %s\n", path_local)))
-        goto print_error;
+      nb->deleted_path = svn_string_create(path_local, nb->pool);
       break;
 
     case svn_wc_notify_update_add:
       nb->received_some_change = TRUE;
-      if ((err = svn_cmdline_printf (nb->pool, "A  %s\n", path_local)))
-        goto print_error;
+      /* If the last action was a deletion of the path that we're
+       * adding right now, then print out "R" instead to indicate that
+       * we're replacing the file. */
+      if (nb->deleted_path != NULL && svn_string_compare(nb->deleted_path,
+            svn_string_create(path_local, nb->pool)))
+        {
+          nb->deleted_path = NULL;
+          if ((err = svn_cmdline_printf (nb->pool, "R  %s\n", path_local)))
+            goto print_error;
+        }
+      /* Otherwise print out "A" as usual. */
+      else
+        {
+          if ((err = svn_cmdline_printf (nb->pool, "A  %s\n", path_local)))
+            goto print_error;
+        }
       break;
 
     case svn_wc_notify_restore:
@@ -358,7 +392,10 @@
       break;
     }
 
-  svn_pool_clear (nb->pool);
+  /* If we're not keeping track of the deleted_path, then we can
+   * clear the pool. */
+  if (nb->deleted_path == NULL)
+    svn_pool_clear (nb->pool);
   return;
 
  print_error:
@@ -372,7 +409,10 @@
       svn_error_clear (err);
     }
 
-  svn_pool_clear(nb->pool);
+  /* If we're not keeping track of the deleted_path, then we can
+   * clear the pool. */
+  if (nb->deleted_path == NULL)
+    svn_pool_clear(nb->pool);
 }
 
 
@@ -394,6 +434,7 @@
   nb->in_external = FALSE;
   nb->had_print_error = FALSE;
   nb->pool = svn_pool_create (pool);
+  nb->deleted_path = NULL;
 
   *notify_func_p = notify;
   *notify_baton_p = nb;


