Factor out duplicated code from deleting a single path and deleting multiple
paths.

### Tests fail (e.g. op-depth-test.c 1), because of inconsistent handling of
    the 'delete_unversioned_target' parameter.  The factored out code just
    picks one of the two options.  What do we want to do?

* subversion/libsvn_wc/adm_ops.c
  (delete_check): New function, factored out ...
  (svn_wc__delete_many, svn_wc__delete_internal): ... from these.
--This line, and those below, will be ignored--

Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c	(revision 1412671)
+++ subversion/libsvn_wc/adm_ops.c	(working copy)
@@ -653,6 +653,103 @@ create_delete_wq_items(svn_skel_t **work
   return SVN_NO_ERROR;
 }
 
+/* Check and prepare a deletion of the node at LOCAL_ABSPATH in DB.
+ *
+ * If the node is unversioned and needs to be deleted from disk, do that.
+ *
+ * If a versioned delete is needed, set *NEED_VERSIONED_DELETE to TRUE,
+ * and set *WORK_ITEMS to any required work queue item(s).  Otherwise,
+ * set *NEED_VERSIONED_DELETE to FALSE and *WORK_ITEMS to NULL.
+ */
+static svn_error_t *
+delete_check(svn_boolean_t *need_versioned_delete,
+             svn_skel_t **work_items,
+             svn_wc__db_t *db,
+             const char *local_abspath,
+             svn_boolean_t delete_unversioned_target,
+             svn_boolean_t keep_local,
+             svn_cancel_func_t cancel_func,
+             void *cancel_baton,
+             apr_pool_t *result_pool,
+             apr_pool_t *scratch_pool)
+{
+  svn_error_t *err;
+  svn_wc__db_status_t status;
+  svn_kind_t kind;
+  svn_boolean_t conflicted;
+
+  *need_versioned_delete = FALSE;
+  *work_items = NULL;
+
+  err = svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL, NULL,
+                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                             NULL, NULL, NULL, NULL, NULL, &conflicted,
+                             NULL, NULL, NULL, NULL, NULL, NULL,
+                             db, local_abspath, scratch_pool, scratch_pool);
+
+  if (delete_unversioned_target &&
+      err != NULL && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+    {
+      svn_error_clear(err);
+
+      if (!keep_local)
+        SVN_ERR(erase_unversioned_from_wc(local_abspath, FALSE,
+                                          cancel_func, cancel_baton,
+                                          scratch_pool));
+      return SVN_NO_ERROR;
+    }
+  else
+    SVN_ERR(err);
+
+  switch (status)
+    {
+      /* svn_wc__db_status_server_excluded handled by
+       * svn_wc__db_op_delete_many */
+      case svn_wc__db_status_excluded:
+      case svn_wc__db_status_not_present:
+        return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                                 _("'%s' cannot be deleted"),
+                                 svn_dirent_local_style(local_abspath,
+                                                        scratch_pool));
+
+      /* Explicitly ignore other statii */
+      default:
+        break;
+    }
+
+  if (status == svn_wc__db_status_normal
+      && kind == svn_kind_dir)
+    {
+      svn_boolean_t is_wcroot;
+      SVN_ERR(svn_wc__db_is_wcroot(&is_wcroot, db, local_abspath,
+                                   scratch_pool));
+
+      if (is_wcroot)
+        return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, NULL,
+                                 _("'%s' is the root of a working copy and "
+                                   "cannot be deleted"),
+                                 svn_dirent_local_style(local_abspath,
+                                                        scratch_pool));
+    }
+
+  /* Verify if we have a write lock on the parent of this node as we might
+     be changing the childlist of that directory. */
+  SVN_ERR(svn_wc__write_check(db, svn_dirent_dirname(local_abspath,
+                                                     scratch_pool),
+                              scratch_pool));
+
+  /* Prepare the on-disk delete */
+  if (!keep_local)
+    {
+      SVN_ERR(create_delete_wq_items(work_items, db, local_abspath, kind,
+                                     conflicted,
+                                     result_pool, scratch_pool));
+
+    }
+  *need_versioned_delete = TRUE;
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_wc__delete_many(svn_wc_context_t *wc_ctx,
                     const apr_array_header_t *targets,
@@ -665,9 +762,6 @@ svn_wc__delete_many(svn_wc_context_t *wc
                     apr_pool_t *scratch_pool)
 {
   svn_wc__db_t *db = wc_ctx->db;
-  svn_error_t *err;
-  svn_wc__db_status_t status;
-  svn_kind_t kind;
   svn_skel_t *work_items = NULL;
   apr_array_header_t *versioned_targets;
   const char *local_abspath;
@@ -679,82 +773,21 @@ svn_wc__delete_many(svn_wc_context_t *wc
                                      sizeof(const char *));
   for (i = 0; i < targets->nelts; i++)
     {
-      svn_boolean_t conflicted = FALSE;
+      svn_boolean_t need_versioned_delete;
+      svn_skel_t *work_item;
 
       svn_pool_clear(iterpool);
 
       local_abspath = APR_ARRAY_IDX(targets, i, const char *);
-      err = svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL, NULL, NULL, &conflicted,
-                                 NULL, NULL, NULL, NULL, NULL, NULL,
-                                 db, local_abspath, iterpool, iterpool);
-
-      if (err)
-        {
-          if (err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-            {
-              svn_error_clear(err);
-              if (delete_unversioned_target && !keep_local)
-                SVN_ERR(erase_unversioned_from_wc(local_abspath, FALSE,
-                                                  cancel_func, cancel_baton,
-                                                  iterpool));
-              continue;
-            }
-         else
-          return svn_error_trace(err);
-        }
-
-      APR_ARRAY_PUSH(versioned_targets, const char *) = local_abspath;
-
-      switch (status)
-        {
-          /* svn_wc__db_status_server_excluded handled by
-           * svn_wc__db_op_delete_many */
-          case svn_wc__db_status_excluded:
-          case svn_wc__db_status_not_present:
-            return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
-                                     _("'%s' cannot be deleted"),
-                                     svn_dirent_local_style(local_abspath,
-                                                            iterpool));
-
-          /* Explicitly ignore other statii */
-          default:
-            break;
-        }
-
-      if (status == svn_wc__db_status_normal
-          && kind == svn_kind_dir)
-        {
-          svn_boolean_t is_wcroot;
-          SVN_ERR(svn_wc__db_is_wcroot(&is_wcroot, db, local_abspath,
-                                       iterpool));
-
-          if (is_wcroot)
-            return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, NULL,
-                                     _("'%s' is the root of a working copy and "
-                                       "cannot be deleted"),
-                                     svn_dirent_local_style(local_abspath,
-                                                            iterpool));
-        }
-
-      /* Verify if we have a write lock on the parent of this node as we might
-         be changing the childlist of that directory. */
-      SVN_ERR(svn_wc__write_check(db, svn_dirent_dirname(local_abspath,
-                                                         iterpool),
-                                  iterpool));
-
-      /* Prepare the on-disk delete */
-      if (!keep_local)
+      SVN_ERR(delete_check(&need_versioned_delete, &work_item,
+                           db, local_abspath,
+                           keep_local, delete_unversioned_target,
+                           cancel_func, cancel_baton,
+                           scratch_pool, iterpool));
+      if (need_versioned_delete)
         {
-          svn_skel_t *work_item;
-
-          SVN_ERR(create_delete_wq_items(&work_item, db, local_abspath, kind,
-                                         conflicted,
-                                         scratch_pool, iterpool));
-
-          work_items = svn_wc__wq_merge(work_items, work_item,
-                                        scratch_pool);
+          APR_ARRAY_PUSH(versioned_targets, const char *) = local_abspath;
+          work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
         }
     }
 
@@ -796,71 +829,18 @@ svn_wc__delete_internal(svn_wc_context_t
 {
   apr_pool_t *pool = scratch_pool;
   svn_wc__db_t *db = wc_ctx->db;
-  svn_error_t *err;
-  svn_wc__db_status_t status;
-  svn_kind_t kind;
-  svn_boolean_t conflicted;
-  svn_skel_t *work_items = NULL;
-
-  err = svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, &conflicted,
-                             NULL, NULL, NULL, NULL, NULL, NULL,
-                             db, local_abspath, pool, pool);
+  svn_boolean_t need_versioned_delete;
+  svn_skel_t *work_items;
 
-  if (delete_unversioned_target &&
-      err != NULL && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+  SVN_ERR(delete_check(&need_versioned_delete, &work_items,
+                       db, local_abspath,
+                       keep_local, delete_unversioned_target,
+                       cancel_func, cancel_baton,
+                       scratch_pool, scratch_pool));
+  if (! need_versioned_delete)
     {
-      svn_error_clear(err);
-
-      if (!keep_local)
-        SVN_ERR(erase_unversioned_from_wc(local_abspath, FALSE,
-                                          cancel_func, cancel_baton,
-                                          pool));
       return SVN_NO_ERROR;
     }
-  else
-    SVN_ERR(err);
-
-  switch (status)
-    {
-      /* svn_wc__db_status_server_excluded handled by svn_wc__db_op_delete */
-      case svn_wc__db_status_excluded:
-      case svn_wc__db_status_not_present:
-        return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
-                                 _("'%s' cannot be deleted"),
-                                 svn_dirent_local_style(local_abspath, pool));
-
-      /* Explicitly ignore other statii */
-      default:
-        break;
-    }
-
-  if (status == svn_wc__db_status_normal
-      && kind == svn_kind_dir)
-    {
-      svn_boolean_t is_wcroot;
-      SVN_ERR(svn_wc__db_is_wcroot(&is_wcroot, db, local_abspath, pool));
-
-      if (is_wcroot)
-        return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, NULL,
-                                 _("'%s' is the root of a working copy and "
-                                   "cannot be deleted"),
-                                 svn_dirent_local_style(local_abspath, pool));
-    }
-
-  /* Verify if we have a write lock on the parent of this node as we might
-     be changing the childlist of that directory. */
-  SVN_ERR(svn_wc__write_check(db, svn_dirent_dirname(local_abspath, pool),
-                              pool));
-
-  /* Prepare the on-disk delete */
-      if (!keep_local)
-        {
-          SVN_ERR(create_delete_wq_items(&work_items, db, local_abspath, kind,
-                                         conflicted,
-                                         scratch_pool, scratch_pool));
-        }
 
   SVN_ERR(svn_wc__db_op_delete(db, local_abspath, moved_to_abspath,
                                !keep_local /* delete_dir_externals */,
