Fix slow "svn st" where the targets are files by not locking the whole anchor
tree.

* libsvn_client/status.c (svn_client_status): Don't lock the whole directory
  hierarchy if the target is a file or not versioned.
Index: subversion/libsvn_client/status.c
===================================================================
--- subversion/libsvn_client/status.c	(revision 11289)
+++ subversion/libsvn_client/status.c	(arbetskopia)
@@ -97,6 +97,7 @@
   const svn_wc_entry_t *entry;
   struct status_baton sb;
   svn_revnum_t edit_revision = SVN_INVALID_REVNUM;
+  int depth;
 
   sb.real_status_func = status_func;
   sb.real_status_baton = status_baton;
@@ -119,21 +120,38 @@
     return svn_error_createf (SVN_ERR_UNVERSIONED_RESOURCE, NULL,
                               _("'%s' is not under version control"), path);
   
-  /* Close up our ADM area.  We'll be re-opening soon. */
-  SVN_ERR (svn_wc_adm_close (adm_access));
-
-  /* Need to lock the tree.  A recursive status requires us to lock the whole
-     tree.  A non-recursive status requires the target directory and immediate
+  /* Need to lock the tree.  If path refers to a directory, a recursive
+     status requires us to lock the whole tree.
+     A non-recursive status requires the target directory and immediate
      subdirectories to be locked.  However, if the user does "svn status
      --non-recursive dir1/dir2", then we start locking from dir1, so in order
      to lock the children of dir2 we need a depth of 2.
+     If target is a file, we just lock its parent.
+     If target is not versioned, we need to lock its parent.
      ### FIXME: In the non-recursive case this always locks too much.  This
      ###        is a performance bug.  (But this is better than locking too
      ###        little, which would be a correctness bug).
    */
-  SVN_ERR (svn_wc_adm_probe_open2 (&adm_access, NULL, anchor, 
-                                   FALSE, (descend ? -1 : 2), pool));
+  if (entry)
+    {
+      if (entry->kind == svn_node_file)
+        depth = 0;
+      else if (! descend)
+        depth = 2;
+      else
+        depth = -1;
+    }
+  else
+    depth = 0;
 
+  if (depth != 0)
+    {
+      /* Close up our ADM area and reopen it with the depth we want. */
+      SVN_ERR (svn_wc_adm_close (adm_access));
+      SVN_ERR (svn_wc_adm_probe_open2 (&adm_access, NULL, anchor, 
+                                       FALSE, depth, pool));
+    }
+
   /* Get the status edit, and use our wrapping status function/baton
      as the callback pair. */
   SVN_ERR (svn_wc_get_status_editor (&editor, &edit_baton, &edit_revision,
