Index: subversion/libsvn_client/patch.c
==================================================================--- subversion/libsvn_client/patch.c	(revision 38794)
+++ 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. ***/
@@ -204,8 +205,26 @@
   {
     const svn_wc_entry_t *entry;
     svn_node_kind_t kind;
+    svn_error_t *err;

-    SVN_ERR(svn_wc_entry(&entry, mine, adm_access, FALSE, subpool));
+    err = svn_wc__get_entry_versioned(&entry, patch_b->ctx->wc_ctx,
+                                    mine_abspath, svn_node_unknown,
+                                    FALSE, FALSE,
+                                    subpool, subpool);
+
+    /* We catch the error since a NULL value is expected when the entry
+       is hidden. */
+    if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+      {
+        svn_error_clear(err);
+        entry = NULL;
+      }
+    else if (err)
+      {
+        svn_pool_clear(subpool);
+        return svn_error_return(err);
+      }
+
     SVN_ERR(svn_io_check_path(mine, &kind, subpool));

     /* ### a future thought:  if the file is under version control,
@@ -325,7 +344,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 +391,26 @@
     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;
+
+        err = svn_wc__get_entry_versioned(&entry, patch_b->ctx->wc_ctx,
+                                          mine_abspath, svn_node_none,
+                                          FALSE, FALSE,
+                                          subpool, subpool);
+
+          /* We catch the error since a NULL value is expected when the entry
+             is hidden. */
+          if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+            {
+              svn_error_clear(err);
+              entry = NULL;
+            }
+          else if (err)
+            {
+              svn_pool_destroy(subpool);
+              return svn_error_return(err);
+            }
+
         if (entry && entry->schedule != svn_wc_schedule_delete)
           {
             /* It's versioned but missing. */
@@ -383,7 +424,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 +494,26 @@
         {
           /* 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_error_t *err;

+          err = svn_wc__get_entry_versioned(&entry, patch_b->ctx->wc_ctx,
+                                            mine_abspath, svn_node_dir,
+                                            FALSE, FALSE,
+                                            subpool, subpool);
+
+          /* We catch the error since a NULL value is expected when the entry
+             is hidden. */
+          if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+            {
+              svn_error_clear(err);
+              entry = NULL;
+            }
+          else if (err)
+            {
+              svn_pool_destroy(subpool);
+              return svn_error_return(err);
+            }
+
           if (entry && dry_run_deleted_p(patch_b, mine))
             *content_state = svn_wc_notify_state_changed;
           else
@@ -467,8 +525,26 @@
       {
         /* 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_error_t *err;

+        err = svn_wc__get_entry_versioned(&entry, patch_b->ctx->wc_ctx,
+                                          mine_abspath, svn_node_file,
+                                          FALSE, FALSE,
+                                          subpool, subpool);
+
+        /* We catch the error since a NULL value is expected when the entry
+           is hidden. */
+        if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+          {
+            svn_error_clear(err);
+            entry = NULL;
+          }
+        else if (err)
+          {
+            svn_pool_destroy(subpool);
+            return svn_error_return(err);
+          }
+
         /* 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 +682,8 @@
   svn_node_kind_t kind;
   const svn_wc_entry_t *entry;
   const char *child;
+  const char *local_abspath;
+  svn_error_t *err;

   /* 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 +706,32 @@
   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));
+      err = svn_wc__get_entry_versioned(&entry, patch_b->ctx->wc_ctx,
+                                          local_abspath,
+                                          svn_node_unknown,
+                                          FALSE, FALSE,
+                                          subpool, subpool);
+
+      /* We catch the error since a NULL value is expected when the entry
+         was hidden. */
+      if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+        {
+          svn_error_clear(err);
+          entry = NULL;
+        }
+      else if (err)
+        {
+          svn_pool_destroy(subpool);
+          return svn_error_return(err);
+        }
+
       if (entry && entry->schedule != svn_wc_schedule_delete)
         {
           /* Versioned but missing */
@@ -659,7 +758,26 @@
       break;
     case svn_node_dir:
       /* Adding an unversioned directory doesn't destroy data */
-      SVN_ERR(svn_wc_entry(&entry, path, adm_access, TRUE, subpool));
+      err = svn_wc__get_entry_versioned(&entry, patch_b->ctx->wc_ctx,
+                                        local_abspath,
+                                        svn_node_dir,
+                                        TRUE, /*show_hidden */
+                                        FALSE,
+                                        subpool, subpool);
+
+      /* We catch the error since a NULL value is expected when the entry
+         was not versioned. */
+      if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+        {
+          svn_error_clear(err);
+          entry = NULL;
+        }
+      else if (err)
+        {
+          svn_pool_destroy(subpool);
+          return svn_error_return(err);
+        }
+
       if (! entry || entry->schedule == svn_wc_schedule_delete)
         {
           if (!patch_b->dry_run)
@@ -688,8 +806,27 @@

       if (state)
         {
-          SVN_ERR(svn_wc_entry(&entry, path, adm_access, FALSE, subpool));
+          SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, subpool));

+          err = svn_wc__get_entry_versioned(&entry, patch_b->ctx->wc_ctx,
+                                            local_abspath,
+                                            svn_node_file,
+                                            FALSE, FALSE,
+                                            subpool, subpool);
+
+          /* We catch the error since a NULL value is expected when the entry
+             is hidden. */
+          if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+            {
+              svn_error_clear(err);
+              entry = NULL;
+            }
+          else if (err)
+            {
+              svn_pool_destroy(subpool);
+              return svn_error_return(err);
+            }
+
           if (entry && dry_run_deleted_p(patch_b, path))
             /* ### TODO: Retain record of this dir being added to
                ### avoid problems from subsequent edits which try to
@@ -2016,10 +2153,26 @@
   if (! new_target->skipped)
     {
       const svn_wc_entry_t *entry;
+      svn_error_t *err;

       /* 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));
+      err = svn_wc__get_entry_versioned(&entry, ctx->wc_ctx,
+                                        new_target->abs_path,
+                                        svn_node_unknown,
+                                        TRUE, FALSE,
+                                        result_pool,
+                                        scratch_pool);
+
+      /* We catch the error since a NULL value is expected when the entry
+         was not versioned. */
+      if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+        {
+          svn_error_clear(err);
+          entry = NULL;
+        }
+      else if (err)
+        return svn_error_return(err);
+
       if (entry && entry->schedule == svn_wc_schedule_delete)
         {
           /* The target is versioned and scheduled for deletion, so skip it. */

