[prev in list] [next in list] [prev in thread] [next in thread] 

List:       subversion-cvs
Subject:    
From:       dlr () tigris ! org
Date:       2007-09-28 20:08:29
Message-ID: 200709282008.l8SK8Tnq023810 () svn2 ! sjc ! collab ! net
[Download RAW message or body]

Author: dlr
Date: Fri Sep 28 13:08:29 2007
New Revision: 26837

Log:
Replace svn_error_root_cause_is() API -- which was new for 1.5 -- with
svn_error_root_cause(), to better support its usage.

* subversion/include/svn_error.h
* subversion/libsvn_subr/error.c
  (svn_error_root_cause): Add new function.
  (svn_error_root_cause_is): Remove function.

* subversion/libsvn_client/merge.c
  (get_mergeinfo_error_handler): Adjust for API change.

* subversion/libsvn_client/prop_commands.c
  (wc_walker_error_handler): Adjust for API change.

* subversion/libsvn_client/update.c
  (svn_client__update_internal): Adjust for API change.

* subversion/tests/libsvn_subr/error-test.c
  Add include of svn_error_codes.h.
  (test_error_root_cause): Rename from test_error_is_root_cause().
   Update for test case for API change.
  (test_funcs): Change test name.


Modified:
   trunk/subversion/include/svn_error.h
   trunk/subversion/libsvn_client/merge.c
   trunk/subversion/libsvn_client/prop_commands.c
   trunk/subversion/libsvn_client/update.c
   trunk/subversion/libsvn_subr/error.c
   trunk/subversion/tests/libsvn_subr/error-test.c

Modified: trunk/subversion/include/svn_error.h
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/include/svn_error.h?pathrev=26837&r1=26836&r2=26837
 ==============================================================================
--- trunk/subversion/include/svn_error.h	(original)
+++ trunk/subversion/include/svn_error.h	Fri Sep 28 13:08:29 2007
@@ -148,13 +148,13 @@
  */
 void svn_error_compose(svn_error_t *chain, svn_error_t *new_err);
 
-/** Return whether @a apr_err exists as the root cause of @a err by
- * finding the last error in its chain (e.g. it or its children), and
- * comparing its @c apr_error field.
+/** Return the root cause of @a err by finding the last error in its
+ * chain (e.g. it or its children).  @a err may be @c SVN_NO_ERROR, in
+ * which case @c SVN_NO_ERROR is returned.
  *
  * @since New in 1.5.
  */
-svn_boolean_t svn_error_root_cause_is(svn_error_t *err, apr_status_t apr_err);
+svn_error_t *svn_error_root_cause(svn_error_t *err);
 
 /** Create a new error that is a deep copy of @a err and return it.
  *

Modified: trunk/subversion/libsvn_client/merge.c
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_client/merge.c?pathrev=26837&r1=26836&r2=26837
 ==============================================================================
--- trunk/subversion/libsvn_client/merge.c	(original)
+++ trunk/subversion/libsvn_client/merge.c	Fri Sep 28 13:08:29 2007
@@ -2632,14 +2632,18 @@
                             void *walk_baton,
                             apr_pool_t *pool)
 {
-  if (svn_error_root_cause_is(err, SVN_ERR_WC_PATH_NOT_FOUND)
-      || svn_error_root_cause_is(err, SVN_ERR_WC_NOT_LOCKED))
+  svn_error_t *root_err = svn_error_root_cause(err);
+  if (root_err == SVN_NO_ERROR)
+    return err;
+
+  switch (root_err->apr_err)
     {
+    case SVN_ERR_WC_PATH_NOT_FOUND:
+    case SVN_ERR_WC_NOT_LOCKED:
       svn_error_clear(err);
       return SVN_NO_ERROR;
-    }
-  else
-    {
+
+    default:
       return err;
     }
 }

Modified: trunk/subversion/libsvn_client/prop_commands.c
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_client/prop_commands.c?pathrev=26837&r1=26836&r2=26837
 ==============================================================================
--- trunk/subversion/libsvn_client/prop_commands.c	(original)
+++ trunk/subversion/libsvn_client/prop_commands.c	Fri Sep 28 13:08:29 2007
@@ -734,8 +734,12 @@
                         void *walk_baton,
                         apr_pool_t *pool)
 {
+  svn_error_t *root_err = svn_error_root_cause(err);
+  if (root_err == SVN_NO_ERROR)
+    return err;
+
   /* Suppress errors from missing paths. */
-  if (svn_error_root_cause_is(err, SVN_ERR_WC_PATH_NOT_FOUND))
+  if (root_err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
     {
       svn_error_clear(err);
       return SVN_NO_ERROR;

Modified: trunk/subversion/libsvn_client/update.c
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_client/update.c?pathrev=26837&r1=26836&r2=26837
 ==============================================================================
--- trunk/subversion/libsvn_client/update.c	(original)
+++ trunk/subversion/libsvn_client/update.c	Fri Sep 28 13:08:29 2007
@@ -267,14 +267,16 @@
                                      depth, ctx, pool);
   if (err)
     {
-      if (svn_error_root_cause_is(err, SVN_ERR_WC_PATH_NOT_FOUND)
-          || svn_error_root_cause_is(err, SVN_ERR_UNVERSIONED_RESOURCE))
+      svn_error_t *root_err = svn_error_root_cause(err);
+      switch (root_err->apr_err)
         {
+        case SVN_ERR_WC_PATH_NOT_FOUND:
+        case SVN_ERR_UNVERSIONED_RESOURCE:
           svn_error_clear(err);
           err = SVN_NO_ERROR;
-        }
-      else
-        {
+          break;
+
+        default:
           return err;
         }
     }

Modified: trunk/subversion/libsvn_subr/error.c
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_subr/error.c?pathrev=26837&r1=26836&r2=26837
 ==============================================================================
--- trunk/subversion/libsvn_subr/error.c	(original)
+++ trunk/subversion/libsvn_subr/error.c	Fri Sep 28 13:08:29 2007
@@ -230,19 +230,18 @@
   apr_pool_destroy(oldpool);
 }
 
-svn_boolean_t
-svn_error_root_cause_is(svn_error_t *err, apr_status_t apr_err)
+svn_error_t *
+svn_error_root_cause(svn_error_t *err)
 {
   while (err)
     {
       if (err->child)
         err = err->child;
       else
-        /* We've reached the end of the line. */
-        return (err->apr_err == apr_err);
+        break;
     }
 
-  return FALSE;
+  return err;
 }
 
 svn_error_t *

Modified: trunk/subversion/tests/libsvn_subr/error-test.c
URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/libsvn_subr/error-test.c?pathrev=26837&r1=26836&r2=26837
 ==============================================================================
--- trunk/subversion/tests/libsvn_subr/error-test.c	(original)
+++ trunk/subversion/tests/libsvn_subr/error-test.c	Fri Sep 28 13:08:29 2007
@@ -20,23 +20,24 @@
 #include <string.h>
 #include <apr_general.h>
 
+#include "svn_error_codes.h"
 #include "svn_error.h"
 
 #include "../svn_test.h"
 
 static svn_error_t *
-test_error_is_root_cause(const char **msg,
-                              svn_boolean_t msg_only,
-                              svn_test_opts_t *opts,
-                              apr_pool_t *pool)
+test_error_root_cause(const char **msg,
+                      svn_boolean_t msg_only,
+                      svn_test_opts_t *opts,
+                      apr_pool_t *pool)
 {
   apr_status_t secondary_err_codes[] = { SVN_ERR_STREAM_UNRECOGNIZED_DATA,
                                          SVN_ERR_STREAM_MALFORMED_DATA };
   apr_status_t root_cause_err_code = SVN_ERR_STREAM_UNEXPECTED_EOF;
   int i;
-  svn_error_t *err;
+  svn_error_t *err, *root_err;
 
-  *msg = "test svn_error_root_cause_is";
+  *msg = "test svn_error_root_cause";
 
   if (msg_only)
     return SVN_NO_ERROR;
@@ -48,22 +49,32 @@
 
   /* Verify that the error is detected at the proper location in the
      error chain. */
+  root_err = svn_error_root_cause(err);
+  if (root_err == NULL)
+    {
+      svn_error_clear(err);
+      return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+                               "svn_error_root_cause failed to locate any "
+                               "root error in the chain");
+    }
+
   for (i = 0; i < 2; i++)
-   {
-    if (svn_error_root_cause_is(err, secondary_err_codes[i]))
-      {
-        svn_error_clear(err);
-        return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
-                                 "svn_error_root_cause_is returned a "
-                                 "false-postive");
-      }
-   }
+    {
+      if (root_err->apr_err == secondary_err_codes[i])
+        {
+          svn_error_clear(err);
+          return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+                                   "svn_error_root_cause returned the "
+                                   "wrong error from the chain");
+        }
+    }
 
-  if (!svn_error_root_cause_is(err, root_cause_err_code))
+  if (root_err->apr_err != root_cause_err_code)
     {
       svn_error_clear(err);
       return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
-                               "svn_error_root_cause_is detection failed");
+                               "svn_error_root_cause failed to locate the "
+                               "correct error from teh chain");
     }
 
   svn_error_clear(err);
@@ -76,6 +87,6 @@
 struct svn_test_descriptor_t test_funcs[] =
   {
     SVN_TEST_NULL,
-    SVN_TEST_PASS(test_error_is_root_cause),
+    SVN_TEST_PASS(test_error_root_cause),
     SVN_TEST_NULL
   };

---------------------------------------------------------------------
To unsubscribe, e-mail: svn-unsubscribe@subversion.tigris.org
For additional commands, e-mail: svn-help@subversion.tigris.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic