Index: build.conf
===================================================================
--- build.conf	(revision 17490)
+++ build.conf	(working copy)
@@ -284,7 +284,7 @@
 description = Subversion Revision Extractor
 type = exe
 path = subversion/svnversion
-libs = libsvn_client libsvn_subr libsvn_wc aprutil apriconv apr neon
+libs = libsvn_subr libsvn_wc aprutil apriconv apr neon
 install = bin
 manpages = subversion/svnversion/svnversion.1
 
Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h	(revision 17490)
+++ subversion/include/svn_wc.h	(working copy)
@@ -3306,6 +3306,42 @@
                                  apr_pool_t *pool);
 
 
+/** This structure reports the mix of revisions found within
+ * a working copy, including whether some parts are switched
+ * or currently modified.  If no working copy is found, an error
+ * is raised, possibly SVN_ERR_WC_PATH_NOT_FOUND if the path
+ * is a directory or SVN_ERR_WC_NOT_DIRECTORY if it is anything else.
+ */
+typedef struct svn_wc_revision_status_t
+{
+  svn_revnum_t min_rev;   /* lowest revision found. */
+  svn_revnum_t max_rev;   /* highest revision found. */
+
+  /* is anything ... */
+  svn_boolean_t switched; 
+  svn_boolean_t modified; /* any type of modification... */
+} 
+svn_wc_revision_status_t;
+
+/** Compute the revision summary status in the @a result structure 
+ * for a working copy at @a wc_path.  The @a trail_url is used to
+ * determine if WC_PATH itself is switched.  The summary may address the
+ * last changed vs the current revisions if @a committed.  
+ * Cancel stuff @a cancal_func and @a cancel_baton is passed downwards, 
+ * although they may be NULL.
+ *
+ * @since New in 1.4
+ */
+svn_error_t *
+svn_wc_revision_status (svn_wc_revision_status_t *result,
+                        const char *wc_path,
+                        const char *trail_url,
+                        svn_boolean_t committed,
+                        svn_cancel_func_t cancel_func,
+                        void *cancel_baton,
+                        apr_pool_t *pool);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/libsvn_wc/revision_status.c
===================================================================
--- subversion/libsvn_wc/revision_status.c	(revision 17490)
+++ subversion/libsvn_wc/revision_status.c	(working copy)
@@ -1,4 +1,6 @@
 /*
+ * revision_status.c -- Show versions in current copy.
+ *
  * ====================================================================
  * Copyright (c) 2003-2004 CollabNet.  All rights reserved.
  *
@@ -14,31 +16,23 @@
  * ====================================================================
  */
 
-#include "svn_cmdline.h"
 #include "svn_pools.h"
-#include "svn_client.h"
 #include "svn_utf.h"
 #include "svn_path.h"
-#include "svn_opt.h"
+#include "svn_wc.h"
 
 #include "svn_private_config.h"
 
-#define SVNVERSION_OPT_VERSION SVN_OPT_FIRST_LONGOPT_ID
-
 struct status_baton
 {
-  svn_revnum_t min_rev;   /* lowest revision found. */
-  svn_revnum_t max_rev;   /* highest revision found. */
-  svn_boolean_t switched; /* is anything switched? */
-  svn_boolean_t modified; /* is anything modified? */
-  svn_boolean_t committed; /* examine last committed revisions */
-  const char *wc_path;    /* path whose URL we're looking for. */
-  const char *wc_url;     /* URL for the path whose URL we're looking for. */
-  apr_pool_t *pool;       /* pool in which to store alloc-needy things. */
+  svn_wc_revision_status_t *result;           /* where to put the result */
+  svn_boolean_t committed;           /* examine last committed revisions */
+  const char *wc_path;               /* path whose URL we're looking for */
+  const char *wc_url;    /* URL for the path whose URL we're looking for */
+  apr_pool_t *pool;         /* pool in which to store alloc-needy things */
 };
 
-
-/* An svn_wc_status_func_t callback function for anaylyzing status
+/* An svn_wc_status_func2_t callback function for anaylyzing status
    structures. */
 static void
 analyze_status (void *baton,
@@ -46,9 +40,9 @@
                 svn_wc_status2_t *status)
 {
   struct status_baton *sb = baton;
-  
+
   if (! status->entry)
-    return;
+      return;
 
   /* Added files have a revision of no interest */
   if (status->text_status != svn_wc_status_added)
@@ -56,18 +50,20 @@
       svn_revnum_t item_rev = (sb->committed
                                ? status->entry->cmt_rev
                                : status->entry->revision);
-
-      if (sb->min_rev == SVN_INVALID_REVNUM || item_rev < sb->min_rev)
-        sb->min_rev = item_rev;
-
-      if (sb->max_rev == SVN_INVALID_REVNUM || item_rev > sb->max_rev)
-        sb->max_rev = item_rev;
+      
+      if (sb->result->min_rev == SVN_INVALID_REVNUM || 
+          item_rev < sb->result->min_rev)
+        sb->result->min_rev = item_rev;
+      
+      if (sb->result->max_rev == SVN_INVALID_REVNUM || 
+          item_rev > sb->result->max_rev)
+        sb->result->max_rev = item_rev;
     }
 
-  sb->switched |= status->switched;
-  sb->modified |= (status->text_status != svn_wc_status_normal);
-  sb->modified |= (status->prop_status != svn_wc_status_normal
-                   && status->prop_status != svn_wc_status_none);
+  sb->result->switched |= status->switched;
+  sb->result->modified |= (status->text_status != svn_wc_status_normal)
+                       |  (status->prop_status != svn_wc_status_normal
+                           && status->prop_status != svn_wc_status_none);
   
   if (sb->wc_path 
       && (! sb->wc_url) 
@@ -76,274 +72,107 @@
     sb->wc_url = apr_pstrdup (sb->pool, status->entry->url);
 }
 
-
-static svn_error_t * version(apr_getopt_t *os, apr_pool_t *pool)
+/* public interface. */
+svn_error_t *
+svn_wc_revision_status (svn_wc_revision_status_t *result,
+                        const char *wc_path,
+                        const char *trail_url,
+                        svn_boolean_t committed,
+                        svn_cancel_func_t cancel_func,
+                        void *cancel_baton,
+                        apr_pool_t *pool)
 {
-  return svn_opt_print_help(os, "svnversion", TRUE, FALSE, NULL, NULL,
-                            NULL, NULL, NULL, pool);
-}
-
-static void
-usage(apr_pool_t *pool)
-{
-  svn_error_clear (svn_cmdline_fprintf
-                    (stderr, pool, _("Type 'svnversion --help' for usage.\n")));
-  exit(1);
-}
-
-
-static void
-help(const apr_getopt_option_t *options, apr_pool_t *pool)
-{
-  svn_error_clear
-    (svn_cmdline_fprintf
-     (stdout, pool,
-      _("usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]\n\n"
-        "  Produce a compact 'version number' for the working copy path\n"
-        "  WC_PATH.  TRAIL_URL is the trailing portion of the URL used to\n"
-        "  determine if WC_PATH itself is switched (detection of switches\n"
-        "  within WC_PATH does not rely on TRAIL_URL).  The version number\n"
-        "  is written to standard output.  For example:\n"
-        "\n"
-        "    $ svnversion . /repos/svn/trunk \n"
-        "    4168\n"
-        "\n"
-        "  The version number will be a single number if the working\n"
-        "  copy is single revision, unmodified, not switched and with\n"
-        "  an URL that matches the TRAIL_URL argument.  If the working\n"
-        "  copy is unusual the version number will be more complex:\n"
-        "\n"
-        "   4123:4168     mixed revision working copy\n"
-        "   4168M         modified working copy\n"
-        "   4123S         switched working copy\n"
-        "   4123:4168MS   mixed revision, modified, switched working copy\n"
-        "\n"
-        "  If invoked on a directory that is not a working copy, an\n"
-        "  exported directory say, the program will output 'exported'.\n"
-        "\n"
-        "  If invoked without arguments WC_PATH will be the current "
-        "directory.\n"
-        "\n"
-        "Valid options:\n")));
-  while (options->description)
-    {
-      const char *optstr;
-      svn_opt_format_option(&optstr, options, TRUE, pool);
-      svn_error_clear (svn_cmdline_fprintf(stdout, pool, "  %s\n", optstr));
-      ++options;
-    }
-  svn_error_clear (svn_cmdline_fprintf(stdout, pool, "\n"));
-  exit(0);
-}
-
-
-/* Version compatibility check */
-static svn_error_t *
-check_lib_versions (void)
-{
-  static const svn_version_checklist_t checklist[] =
-    {
-      { "svn_subr",   svn_subr_version },
-      { "svn_client", svn_client_version },
-      { "svn_wc",     svn_wc_version },
-      { NULL, NULL }
-    };
-
-   SVN_VERSION_DEFINE (my_version);
-   return svn_ver_check_list (&my_version, checklist);
-}
-
-
-/*
- * Why is this not an svn subcommand?  I have this vague idea that it could
- * be run as part of the build process, with the output embedded in the svn
- * program.  Obviously we don't want to have to run svn when building svn.
- * We could always put this into libsvn_client and share it between
- * svnversion and svn.
- */
-int
-main(int argc, const char *argv[])
-{
-  const char *wc_path;
-  apr_allocator_t *allocator;
-  apr_pool_t *pool;
   int wc_format;
-  svn_client_ctx_t ctx = { 0 };
   struct status_baton sb;
-  svn_opt_revision_t rev;
-  svn_boolean_t no_newline = FALSE;
-  svn_error_t *err;
-  apr_getopt_t *os;
-  const apr_getopt_option_t options[] =
-    {
-      {"no-newline", 'n', 0, N_("do not output the trailing newline")},
-      {"committed",  'c', 0, N_("last changed rather than current revisions")},
-      {"help", 'h', 0, N_("display this help")},
-      {"version", SVNVERSION_OPT_VERSION, 0, N_("show version information")},
-      {0,             0,  0,  0}
-    };
+  apr_pool_t *subpool;
+  const char *anchor, *target;
+  svn_wc_adm_access_t *anchor_access, *target_access;
+  svn_wc_traversal_info_t *traversal_info;
+  const svn_delta_editor_t *editor;
+  void *edit_baton, *set_locks_baton;
+  svn_revnum_t edit_revision = SVN_INVALID_REVNUM;
 
-  /* Initialize the app. */
-  if (svn_cmdline_init ("svnversion", stderr) != EXIT_SUCCESS)
-    return EXIT_FAILURE;
+  /* set result as nil */
+  result->min_rev    = SVN_INVALID_REVNUM;
+  result->max_rev    = SVN_INVALID_REVNUM;
+  result->switched   = FALSE;
+  result->modified   = FALSE;
 
-  /* Create our top-level pool.  Use a seperate mutexless allocator,
-   * given this application is single threaded.
-   */
-  if (apr_allocator_create (&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set (allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex (NULL, allocator);
-  apr_allocator_owner_set (allocator, pool);
-
-  /* Check library versions */
-  err = check_lib_versions ();
-  if (err)
-    {
-      svn_handle_error2 (err, stderr, FALSE, "svnversion: ");
-      svn_error_clear (err);
-      svn_pool_destroy (pool);
-      return EXIT_FAILURE;
-    }
-
-#if defined(WIN32) || defined(__CYGWIN__)
-  /* Set the working copy administrative directory name. */
-  if (getenv ("SVN_ASP_DOT_NET_HACK"))
-    {
-      err = svn_wc_set_adm_dir ("_svn", pool);
-      if (err)
-        {
-          svn_handle_error2 (err, stderr, FALSE, "svnversion: ");
-          return EXIT_FAILURE;
-        }
-    }
-#endif
-
-  sb.switched = FALSE;
-  sb.modified = FALSE;
-  sb.committed = FALSE;
-  sb.min_rev = SVN_INVALID_REVNUM;
-  sb.max_rev = SVN_INVALID_REVNUM;
+  /* initialize walking stick */
+  subpool = svn_pool_create (pool);
+  sb.result = result;
+  sb.committed = committed;
   sb.wc_path = NULL;
   sb.wc_url = NULL;
-  sb.pool = pool;
+  sb.pool = subpool;
 
-  apr_getopt_init(&os, pool, argc, argv);
-  os->interleave = 1;
-  while (1)
-    {
-      int opt;
-      const char *arg;
-      apr_status_t status = apr_getopt_long(os, options, &opt, &arg);
-      if (APR_STATUS_IS_EOF(status))
-        break;
-      if (status != APR_SUCCESS)
-        {
-          usage(pool);
-          return EXIT_FAILURE;
-        }
-      switch (opt)
-        {
-        case 'n':
-          no_newline = TRUE;
-          break;
-        case 'c':
-          sb.committed = TRUE;
-          break;
-	case 'h':
-	  help(options, pool);
-	  break;
-        case SVNVERSION_OPT_VERSION:
-          SVN_INT_ERR(version(os, pool));
-          exit(0);
-          break;
-        default:
-          usage(pool);
-          return EXIT_FAILURE;
-        }
-    }
+  wc_path = svn_path_internal_style (wc_path, subpool);
 
-  if (os->ind > argc || os->ind < argc - 2)
-    {
-      usage(pool);
-      return EXIT_FAILURE;
-    }
+  SVN_ERR (svn_wc_check_wc (wc_path, &wc_format, subpool));
 
-  SVN_INT_ERR (svn_utf_cstring_to_utf8 (&wc_path, 
-			  (os->ind == argc) ? "." : os->argv[os->ind++], 
-			  pool));
-  wc_path = svn_path_internal_style (wc_path, pool);
-  SVN_INT_ERR (svn_wc_check_wc (wc_path, &wc_format, pool));
   if (! wc_format)
     {
       svn_node_kind_t kind;
-      SVN_INT_ERR(svn_io_check_path (wc_path, &kind, pool));
+      SVN_ERR(svn_io_check_path (wc_path, &kind, subpool));
+      svn_pool_destroy (subpool);
       if (kind == svn_node_dir)
         {
-          SVN_INT_ERR (svn_cmdline_printf (pool, _("exported%s"), 
-                                           no_newline ? "" : "\n"));
-          svn_pool_destroy (pool);
-          return EXIT_SUCCESS;
+          return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                                   _("'%s' is exported\n"), wc_path);
         }
       else
         {
-          svn_error_clear
-            (svn_cmdline_fprintf (stderr, pool,
-                                  _("'%s' not versioned, and not exported\n"),
-                                  wc_path));
-          svn_pool_destroy (pool);
-          return EXIT_FAILURE;
+          return svn_error_createf(SVN_ERR_WC_NOT_DIRECTORY, NULL,
+                                   _("'%s' not versioned, and not exported\n"),
+                                   wc_path);
         }
     }
 
   sb.wc_path = wc_path;
-  rev.kind = svn_opt_revision_unspecified;
-  ctx.config = apr_hash_make (pool);
 
-  err = svn_client_status2 (NULL, wc_path, &rev, analyze_status, 
-                            &sb, TRUE, TRUE, FALSE, FALSE, TRUE, &ctx, pool);
-  if (err && (err->apr_err == SVN_ERR_CANCELLED))
-    svn_error_clear (err);
-  else
-    SVN_INT_ERR (err);
+  traversal_info = svn_wc_init_traversal_info (subpool);
 
-  if ((! sb.switched ) && (os->ind < argc))
+  SVN_ERR (svn_wc_adm_open_anchor (&anchor_access, &target_access, &target,
+                                   wc_path, FALSE, -1,
+                                   cancel_func, cancel_baton,
+                                   subpool));
+
+  anchor = svn_wc_adm_access_path (anchor_access);
+
+  SVN_ERR (svn_wc_get_status_editor2 (&editor, &edit_baton, &set_locks_baton,
+                                      &edit_revision, anchor_access, target,
+                                      NULL  /* config */,
+                                      TRUE  /* recurse */, 
+                                      TRUE  /* get_all */, 
+                                      FALSE /* no_ignore */,
+                                      analyze_status, &sb, 
+                                      cancel_func, cancel_baton,
+                                      traversal_info,
+                                      subpool));
+
+  SVN_ERR (editor->close_edit (edit_baton, subpool));
+
+  SVN_ERR (svn_wc_adm_close (anchor_access));
+
+  if ((! result->switched ) && trail_url!=NULL)
     {
       /* If the trailing part of the URL of the working copy directory
          does not match the given trailing URL then the whole working
          copy is switched. */
-      const char *trail_url;
-      SVN_INT_ERR (svn_utf_cstring_to_utf8 (&trail_url, os->argv[os->ind],
-                                            pool));
       if (! sb.wc_url)
         {
-          sb.switched = TRUE;
+          result->switched = TRUE;
         }
       else
         {
           apr_size_t len1 = strlen (trail_url);
           apr_size_t len2 = strlen (sb.wc_url);
           if ((len1 > len2) || strcmp (sb.wc_url + len2 - len1, trail_url))
-            sb.switched = TRUE;
+            result->switched = TRUE;
         }
     }
 
-  SVN_INT_ERR (svn_cmdline_printf (pool, "%ld", sb.min_rev));
-  if (sb.min_rev != sb.max_rev)
-    SVN_INT_ERR (svn_cmdline_printf (pool, ":%ld", sb.max_rev));
-  if (sb.modified)
-    SVN_INT_ERR (svn_cmdline_fputs ("M", stdout, pool));
-  if (sb.switched)
-    SVN_INT_ERR (svn_cmdline_fputs ("S", stdout, pool));
-  if (! no_newline)
-    SVN_INT_ERR (svn_cmdline_fputs ("\n", stdout, pool));
+  svn_pool_destroy (subpool);
 
-  svn_pool_destroy (pool);
-
-  /* Flush stdout to make sure that the user will see any printing errors. */
-  SVN_INT_ERR (svn_cmdline_fflush (stdout));
-
-  return EXIT_SUCCESS;
+  return SVN_NO_ERROR;
 }
Index: subversion/svnversion/main.c
===================================================================
--- subversion/svnversion/main.c	(revision 17490)
+++ subversion/svnversion/main.c	(working copy)
@@ -16,7 +16,7 @@
 
 #include "svn_cmdline.h"
 #include "svn_pools.h"
-#include "svn_client.h"
+#include "svn_wc.h"
 #include "svn_utf.h"
 #include "svn_path.h"
 #include "svn_opt.h"
@@ -25,58 +25,7 @@
 
 #define SVNVERSION_OPT_VERSION SVN_OPT_FIRST_LONGOPT_ID
 
-struct status_baton
-{
-  svn_revnum_t min_rev;   /* lowest revision found. */
-  svn_revnum_t max_rev;   /* highest revision found. */
-  svn_boolean_t switched; /* is anything switched? */
-  svn_boolean_t modified; /* is anything modified? */
-  svn_boolean_t committed; /* examine last committed revisions */
-  const char *wc_path;    /* path whose URL we're looking for. */
-  const char *wc_url;     /* URL for the path whose URL we're looking for. */
-  apr_pool_t *pool;       /* pool in which to store alloc-needy things. */
-};
 
-
-/* An svn_wc_status_func_t callback function for anaylyzing status
-   structures. */
-static void
-analyze_status (void *baton,
-                const char *path,
-                svn_wc_status2_t *status)
-{
-  struct status_baton *sb = baton;
-  
-  if (! status->entry)
-    return;
-
-  /* Added files have a revision of no interest */
-  if (status->text_status != svn_wc_status_added)
-    {
-      svn_revnum_t item_rev = (sb->committed
-                               ? status->entry->cmt_rev
-                               : status->entry->revision);
-
-      if (sb->min_rev == SVN_INVALID_REVNUM || item_rev < sb->min_rev)
-        sb->min_rev = item_rev;
-
-      if (sb->max_rev == SVN_INVALID_REVNUM || item_rev > sb->max_rev)
-        sb->max_rev = item_rev;
-    }
-
-  sb->switched |= status->switched;
-  sb->modified |= (status->text_status != svn_wc_status_normal);
-  sb->modified |= (status->prop_status != svn_wc_status_normal
-                   && status->prop_status != svn_wc_status_none);
-  
-  if (sb->wc_path 
-      && (! sb->wc_url) 
-      && (strcmp (path, sb->wc_path) == 0)
-      && (status->entry))
-    sb->wc_url = apr_pstrdup (sb->pool, status->entry->url);
-}
-
-
 static svn_error_t * version(apr_getopt_t *os, apr_pool_t *pool)
 {
   return svn_opt_print_help(os, "svnversion", TRUE, FALSE, NULL, NULL,
@@ -144,7 +93,6 @@
   static const svn_version_checklist_t checklist[] =
     {
       { "svn_subr",   svn_subr_version },
-      { "svn_client", svn_client_version },
       { "svn_wc",     svn_wc_version },
       { NULL, NULL }
     };
@@ -153,27 +101,21 @@
    return svn_ver_check_list (&my_version, checklist);
 }
 
-
 /*
- * Why is this not an svn subcommand?  I have this vague idea that it could
- * be run as part of the build process, with the output embedded in the svn
- * program.  Obviously we don't want to have to run svn when building svn.
- * We could always put this into libsvn_client and share it between
- * svnversion and svn.
+ * It is also an svn subcommand?  
+ * It can be run as part of the build process, with the output embedded in the 
+ * svn program.  Obviously we don't want to have to run svn when building svn.
  */
 int
 main(int argc, const char *argv[])
 {
-  const char *wc_path;
   apr_allocator_t *allocator;
   apr_pool_t *pool;
-  int wc_format;
-  svn_client_ctx_t ctx = { 0 };
-  struct status_baton sb;
-  svn_opt_revision_t rev;
-  svn_boolean_t no_newline = FALSE;
+  svn_wc_revision_status_t res;
+  svn_boolean_t no_newline = FALSE, committed = FALSE;
   svn_error_t *err;
   apr_getopt_t *os;
+  const char * wc_path, * trail_url;
   const apr_getopt_option_t options[] =
     {
       {"no-newline", 'n', 0, N_("do not output the trailing newline")},
@@ -221,15 +163,6 @@
     }
 #endif
 
-  sb.switched = FALSE;
-  sb.modified = FALSE;
-  sb.committed = FALSE;
-  sb.min_rev = SVN_INVALID_REVNUM;
-  sb.max_rev = SVN_INVALID_REVNUM;
-  sb.wc_path = NULL;
-  sb.wc_url = NULL;
-  sb.pool = pool;
-
   apr_getopt_init(&os, pool, argc, argv);
   os->interleave = 1;
   while (1)
@@ -250,11 +183,11 @@
           no_newline = TRUE;
           break;
         case 'c':
-          sb.committed = TRUE;
+          committed = TRUE;
           break;
-	case 'h':
-	  help(options, pool);
-	  break;
+        case 'h':
+          help(options, pool);
+          break;
         case SVNVERSION_OPT_VERSION:
           SVN_INT_ERR(version(os, pool));
           exit(0);
@@ -271,72 +204,44 @@
       return EXIT_FAILURE;
     }
 
-  SVN_INT_ERR (svn_utf_cstring_to_utf8 (&wc_path, 
-			  (os->ind == argc) ? "." : os->argv[os->ind++], 
-			  pool));
-  wc_path = svn_path_internal_style (wc_path, pool);
-  SVN_INT_ERR (svn_wc_check_wc (wc_path, &wc_format, pool));
-  if (! wc_format)
+  SVN_INT_ERR(svn_utf_cstring_to_utf8
+              (&wc_path,  (os->ind < argc)? os->argv[os->ind]: ".", pool));
+  
+  if (os->ind+1 < argc)
+      SVN_INT_ERR(svn_utf_cstring_to_utf8
+                  (&trail_url, os->argv[os->ind+1], pool));
+  else
+    trail_url = NULL;
+
+  err = svn_wc_revision_status (&res, wc_path, trail_url, committed, 
+                                NULL, NULL, pool);
+
+  if (err)
     {
-      svn_node_kind_t kind;
-      SVN_INT_ERR(svn_io_check_path (wc_path, &kind, pool));
-      if (kind == svn_node_dir)
+      if (err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
         {
-          SVN_INT_ERR (svn_cmdline_printf (pool, _("exported%s"), 
-                                           no_newline ? "" : "\n"));
-          svn_pool_destroy (pool);
-          return EXIT_SUCCESS;
+          /* but it was a directory, let us guess it was exported... */
+          SVN_INT_ERR (svn_cmdline_fputs(N_("exported"), stdout, pool));
         }
       else
-        {
-          svn_error_clear
-            (svn_cmdline_fprintf (stderr, pool,
-                                  _("'%s' not versioned, and not exported\n"),
-                                  wc_path));
-          svn_pool_destroy (pool);
+        { 
+          svn_handle_error2 (err, stderr, FALSE, "svnversion: "); 
+          svn_error_clear (err);
           return EXIT_FAILURE;
         }
     }
-
-  sb.wc_path = wc_path;
-  rev.kind = svn_opt_revision_unspecified;
-  ctx.config = apr_hash_make (pool);
-
-  err = svn_client_status2 (NULL, wc_path, &rev, analyze_status, 
-                            &sb, TRUE, TRUE, FALSE, FALSE, TRUE, &ctx, pool);
-  if (err && (err->apr_err == SVN_ERR_CANCELLED))
-    svn_error_clear (err);
   else
-    SVN_INT_ERR (err);
-
-  if ((! sb.switched ) && (os->ind < argc))
     {
-      /* If the trailing part of the URL of the working copy directory
-         does not match the given trailing URL then the whole working
-         copy is switched. */
-      const char *trail_url;
-      SVN_INT_ERR (svn_utf_cstring_to_utf8 (&trail_url, os->argv[os->ind],
-                                            pool));
-      if (! sb.wc_url)
-        {
-          sb.switched = TRUE;
-        }
-      else
-        {
-          apr_size_t len1 = strlen (trail_url);
-          apr_size_t len2 = strlen (sb.wc_url);
-          if ((len1 > len2) || strcmp (sb.wc_url + len2 - len1, trail_url))
-            sb.switched = TRUE;
-        }
+      /* Build compact '123[:456]M?S?' string. */
+      SVN_INT_ERR (svn_cmdline_printf (pool, "%ld", res.min_rev));
+      if (res.min_rev != res.max_rev)
+        SVN_INT_ERR (svn_cmdline_printf (pool, ":%ld", res.max_rev));
+      if (res.modified)
+        SVN_INT_ERR (svn_cmdline_fputs ("M", stdout, pool));
+      if (res.switched)
+        SVN_INT_ERR (svn_cmdline_fputs ("S", stdout, pool));
     }
-
-  SVN_INT_ERR (svn_cmdline_printf (pool, "%ld", sb.min_rev));
-  if (sb.min_rev != sb.max_rev)
-    SVN_INT_ERR (svn_cmdline_printf (pool, ":%ld", sb.max_rev));
-  if (sb.modified)
-    SVN_INT_ERR (svn_cmdline_fputs ("M", stdout, pool));
-  if (sb.switched)
-    SVN_INT_ERR (svn_cmdline_fputs ("S", stdout, pool));
+  
   if (! no_newline)
     SVN_INT_ERR (svn_cmdline_fputs ("\n", stdout, pool));
 
