Index: subversion/include/private/svn_wc_private.h
==================================================================--- subversion/include/private/svn_wc_private.h	(revision 38834)
+++ subversion/include/private/svn_wc_private.h	(arbetskopia)
@@ -61,7 +61,21 @@
                             apr_pool_t *result_pool,
                             apr_pool_t *scratch_pool);

+/** Similar to svn_wc__get_entry_versioned().
+ *
+ * It's errors and return semantics are the same as svn_wc_entry().
+ */
+svn_error_t *
+svn_wc__maybe_get_entry(const svn_wc_entry_t **entry,
+                            svn_wc_context_t *wc_ctx,
+                            const char *local_abspath,
+                            svn_node_kind_t kind,
+                            svn_boolean_t show_hidden,
+                            svn_boolean_t need_parent_stub,
+                            apr_pool_t *result_pool,
+                            apr_pool_t *scratch_pool);

+
 /** Given a @a local_abspath with a @a wc_ctx, set @a *switched to
  * TRUE if @a local_abspath is switched, otherwise set @a *switched to FALSE.
  * If neither @a local_abspath or its parent have valid URLs, return
Index: subversion/libsvn_wc/entries.c
==================================================================--- subversion/libsvn_wc/entries.c	(revision 38834)
+++ subversion/libsvn_wc/entries.c	(arbetskopia)
@@ -1421,7 +1421,34 @@
   return SVN_NO_ERROR;
 }

+svn_error_t *
+svn_wc__maybe_get_entry(const svn_wc_entry_t **entry,
+                            svn_wc_context_t *wc_ctx,
+                            const char *local_abspath,
+                            svn_node_kind_t kind,
+                            svn_boolean_t show_hidden,
+                            svn_boolean_t need_parent_stub,
+                            apr_pool_t *result_pool,
+                            apr_pool_t *scratch_pool)
+{
+  svn_error_t *err;

+  err = svn_wc__get_entry_versioned(entry, wc_ctx, local_abspath,
+                                      kind, show_hidden, need_parent_stub,
+                                      result_pool, scratch_pool);
+
+  if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+    {
+      svn_error_clear(err);
+      entry = NULL;
+    }
+  else if (err)
+    return svn_error_return(err);
+
+  return SVN_NO_ERROR;
+}
+
+
 svn_error_t *
 svn_wc__node_is_deleted(svn_boolean_t *deleted,
                         svn_wc__db_t *db,
Index: subversion/libsvn_client/patch.c
==================================================================--- subversion/libsvn_client/patch.c	(revision 38834)
+++ subversion/libsvn_client/patch.c	(arbetskopia)
@@ -45,6 +45,7 @@

 #include "svn_private_config.h"
 #include "private/svn_diff_private.h"
+#include "private/svn_wc_private.h"

 
 /*** Code. ***/
@@ -205,7 +206,11 @@
     const svn_wc_entry_t *entry;
     svn_node_kind_t kind;

-    SVN_ERR(svn_wc_entry(&entry, mine, adm_access, FALSE, subpool));
+    SVN_ERR(svn_wc__maybe_get_entry(&entry, patch_b->ctx->wc_ctx,
+                                    mine_abspath, svn_node_unknown,
+                                    FALSE, FALSE,
+                                    subpool, subpool));
+
     SVN_ERR(svn_io_check_path(mine, &kind, subpool));

     /* ### a future thought:  if the file is under version control,
@@ -325,7 +330,10 @@
   int i;
   apr_hash_t *new_props;
   const char *path_basename = svn_dirent_basename(mine, subpool);
+  const char *mine_abspath;

+  SVN_ERR(svn_dirent_get_absolute(&mine_abspath, mine, subpool));
+
   /* This new file can't have any original prop in this offline context. */
   original_props = apr_hash_make(subpool);

@@ -369,7 +377,13 @@
     case svn_node_none:
       {
         const svn_wc_entry_t *entry;
-        SVN_ERR(svn_wc_entry(&entry, mine, adm_access, FALSE, subpool));
+        svn_error_t *err;
+
+        SVN_ERR(svn_wc__maybe_get_entry(&entry, patch_b->ctx->wc_ctx,
+                                        mine_abspath, svn_node_none,
+                                        FALSE, FALSE,
+                                        subpool, subpool));
+
         if (entry && entry->schedule != svn_wc_schedule_delete)
           {
             /* It's versioned but missing. */
@@ -383,7 +397,6 @@
           {
             if (copyfrom_path) /* schedule-add-with-history */
               {
-                svn_error_t *err;
                 err = svn_wc_copy2(copyfrom_path, adm_access,
                                    path_basename,
                                    patch_b->ctx->cancel_func,
@@ -454,8 +467,12 @@
         {
           /* directory already exists, is it under version control? */
           const svn_wc_entry_t *entry;
-          SVN_ERR(svn_wc_entry(&entry, mine, adm_access, FALSE, subpool));

+          SVN_ERR(svn_wc__maybe_get_entry(&entry, patch_b->ctx->wc_ctx,
+                                          mine_abspath, svn_node_dir,
+                                          FALSE, FALSE,
+                                          subpool, subpool));
+
           if (entry && dry_run_deleted_p(patch_b, mine))
             *content_state = svn_wc_notify_state_changed;
           else
@@ -467,8 +484,12 @@
       {
         /* file already exists, is it under version control? */
         const svn_wc_entry_t *entry;
-        SVN_ERR(svn_wc_entry(&entry, mine, adm_access, FALSE, subpool));

+        SVN_ERR(svn_wc__maybe_get_entry(&entry, patch_b->ctx->wc_ctx,
+                                        mine_abspath, svn_node_file,
+                                        FALSE, FALSE,
+                                        subpool, subpool));
+
         /* If it's an unversioned file, don't touch it.  If it's scheduled
            for deletion, then rm removed it from the working copy and the
            user must have recreated it, don't touch it */
@@ -606,6 +627,7 @@
   svn_node_kind_t kind;
   const svn_wc_entry_t *entry;
   const char *child;
+  const char *local_abspath;

   /* Easy out:  if we have no adm_access for the parent directory,
      then this portion of the tree-delta "patch" must be inapplicable.
@@ -628,11 +650,19 @@
   child = svn_dirent_is_child(patch_b->target, path, subpool);
   assert(child != NULL);

+  /* libsvn_wc wants absolute paths. */
+  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, subpool));
+
   SVN_ERR(svn_io_check_path(path, &kind, subpool));
   switch (kind)
     {
     case svn_node_none:
-      SVN_ERR(svn_wc_entry(&entry, path, adm_access, FALSE, subpool));
+      SVN_ERR(svn_wc__maybe_get_entry(&entry, patch_b->ctx->wc_ctx,
+                                      local_abspath,
+                                      svn_node_none,
+                                      FALSE, FALSE,
+                                      subpool, subpool));
+
       if (entry && entry->schedule != svn_wc_schedule_delete)
         {
           /* Versioned but missing */
@@ -659,7 +689,13 @@
       break;
     case svn_node_dir:
       /* Adding an unversioned directory doesn't destroy data */
-      SVN_ERR(svn_wc_entry(&entry, path, adm_access, TRUE, subpool));
+      SVN_ERR(svn_wc__maybe_get_entry(&entry, patch_b->ctx->wc_ctx,
+                                      local_abspath,
+                                      svn_node_dir,
+                                      TRUE,
+                                      FALSE,
+                                      subpool, subpool));
+
       if (! entry || entry->schedule == svn_wc_schedule_delete)
         {
           if (!patch_b->dry_run)
@@ -688,7 +724,11 @@

       if (state)
         {
-          SVN_ERR(svn_wc_entry(&entry, path, adm_access, FALSE, subpool));
+          SVN_ERR(svn_wc__maybe_get_entry(&entry, patch_b->ctx->wc_ctx,
+                                          local_abspath,
+                                          svn_node_file,
+                                          FALSE, FALSE,
+                                          subpool, subpool));

           if (entry && dry_run_deleted_p(patch_b, path))
             /* ### TODO: Retain record of this dir being added to
@@ -2018,8 +2058,13 @@
       const svn_wc_entry_t *entry;

       /* If the target is versioned, we should be able to get an entry. */
-      SVN_ERR(svn_wc_entry(&entry, new_target->abs_path, adm_access,
-                           TRUE /* show_hidden */, scratch_pool));
+      SVN_ERR(svn_wc__maybe_get_entry(&entry, ctx->wc_ctx,
+                                      new_target->abs_path,
+                                      svn_node_unknown,
+                                      TRUE, FALSE,
+                                      result_pool,
+                                      scratch_pool));
+
       if (entry && entry->schedule == svn_wc_schedule_delete)
         {
           /* The target is versioned and scheduled for deletion, so skip it. */

