You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/06/20 19:06:23 UTC

svn commit: r1495104 - in /subversion/trunk/subversion/libsvn_ra_serf: blame.c commit.c getdate.c getlocations.c getlocationsegments.c getlocks.c inherited_props.c log.c mergeinfo.c options.c property.c ra_serf.h replay.c update.c util.c

Author: rhuijben
Date: Thu Jun 20 17:06:22 2013
New Revision: 1495104

URL: http://svn.apache.org/r1495104
Log:
Improve http status checking in ra_serf, by providing a default error for
unexpected server error, unexpected client error and unexpected moved status
values instead of handling all of the unexpected values as SVN_NO_ERROR.

This turns the
[[
In file
   'D:\Development\SVN\Releases\TortoiseSVN-1.8.0\ext\subversion\subversion\libsvn_client\ra.c'
   line 647: assertion failed (peg_revnum != SVN_INVALID_REVNUM)
]]

into the http error that is causing this problem.
Something like:
[[
svn: E175002: DAV request failed: Content length required
]]

* subversion/libsvn_ra_serf/blame.c
  (svn_ra_serf__get_file_revs): Update caller.

* subversion/libsvn_ra_serf/commit.c
  (return_response_err): Update caller.

* subversion/libsvn_ra_serf/getdate.c
  (svn_ra_serf__get_dated_revision): Add status check and verify result to
    make sense.

* subversion/libsvn_ra_serf/getlocations.c
  (svn_ra_serf__get_locations): Update caller.

* subversion/libsvn_ra_serf/getlocationsegments.c
  (svn_ra_serf__get_location_segments): Update caller.

* subversion/libsvn_ra_serf/getlocks.c
  (svn_ra_serf__get_locks): Update caller.

* subversion/libsvn_ra_serf/inherited_props.c
  (svn_ra_serf__get_inherited_props): Update caller.

* subversion/libsvn_ra_serf/log.c
  (svn_ra_serf__get_log): Update caller.

* subversion/libsvn_ra_serf/mergeinfo.c
  (svn_ra_serf__get_mergeinfo): Update caller. Don't drop detailed errors.

* subversion/libsvn_ra_serf/options.c
  (svn_ra_serf__v2_get_youngest_revnum): Update caller. Verify if result
    makes sense.
  (svn_ra_serf__v1_get_activity_collection): Update caller.
  (svn_ra_serf__exchange_capabilities): Update caller.

* subversion/libsvn_ra_serf/property.c
  (svn_ra_serf__wait_for_props): Update caller.

* subversion/libsvn_ra_serf/ra_serf.h
  (svn_ra_serf__error_on_status): Update argument to pass the entire status to
    allow creating better messages for unknown errors.

* subversion/libsvn_ra_serf/replay.c
  (svn_ra_serf__replay): Update caller.
  (svn_ra_serf__replay_range): Update caller.

* subversion/libsvn_ra_serf/update.c
  (handle_stream): Update caller.
  (finish_report): Update caller.

* subversion/libsvn_ra_serf/util.c
  (svn_ra_serf__error_on_status): Extend arguments. Provide specialized error
    for http status 411 and a generic error for all currently unexpected
    errors.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/blame.c
    subversion/trunk/subversion/libsvn_ra_serf/commit.c
    subversion/trunk/subversion/libsvn_ra_serf/getdate.c
    subversion/trunk/subversion/libsvn_ra_serf/getlocations.c
    subversion/trunk/subversion/libsvn_ra_serf/getlocationsegments.c
    subversion/trunk/subversion/libsvn_ra_serf/getlocks.c
    subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c
    subversion/trunk/subversion/libsvn_ra_serf/log.c
    subversion/trunk/subversion/libsvn_ra_serf/mergeinfo.c
    subversion/trunk/subversion/libsvn_ra_serf/options.c
    subversion/trunk/subversion/libsvn_ra_serf/property.c
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
    subversion/trunk/subversion/libsvn_ra_serf/replay.c
    subversion/trunk/subversion/libsvn_ra_serf/update.c
    subversion/trunk/subversion/libsvn_ra_serf/util.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/blame.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/blame.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/blame.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/blame.c Thu Jun 20 17:06:22 2013
@@ -366,7 +366,7 @@ svn_ra_serf__get_file_revs(svn_ra_sessio
   err = svn_ra_serf__context_run_one(handler, pool);
 
   err = svn_error_compose_create(
-            svn_ra_serf__error_on_status(handler->sline.code,
+            svn_ra_serf__error_on_status(handler->sline,
                                          handler->path,
                                          handler->location),
             err);

Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Thu Jun 20 17:06:22 2013
@@ -223,7 +223,7 @@ return_response_err(svn_ra_serf__handler
   /* Try to return one of the standard errors for 301, 404, etc.,
      then look for an error embedded in the response.  */
   return svn_error_compose_create(svn_ra_serf__error_on_status(
-                                    handler->sline.code,
+                                    handler->sline,
                                     handler->path,
                                     handler->location),
                                   err);

Modified: subversion/trunk/subversion/libsvn_ra_serf/getdate.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/getdate.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/getdate.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/getdate.c Thu Jun 20 17:06:22 2013
@@ -131,6 +131,7 @@ svn_ra_serf__get_dated_revision(svn_ra_s
   svn_ra_serf__handler_t *handler;
   svn_ra_serf__xml_context_t *xmlctx;
   const char *report_target;
+  svn_error_t *err;
 
   date_ctx = apr_palloc(pool, sizeof(*date_ctx));
   date_ctx->time = tm;
@@ -155,7 +156,15 @@ svn_ra_serf__get_dated_revision(svn_ra_s
 
   *date_ctx->revision = SVN_INVALID_REVNUM;
 
-  /* ### use svn_ra_serf__error_on_status() ?  */
+  err = svn_ra_serf__context_run_one(handler, pool);
 
-  return svn_error_trace(svn_ra_serf__context_run_one(handler, pool));
+  SVN_ERR(svn_error_compose_create(
+              svn_ra_serf__error_on_status(handler->sline,
+                                           report_target,
+                                           handler->location),
+              err));
+
+  SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(*revision));
+
+  return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_ra_serf/getlocations.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/getlocations.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/getlocations.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/getlocations.c Thu Jun 20 17:06:22 2013
@@ -192,7 +192,7 @@ svn_ra_serf__get_locations(svn_ra_sessio
   err = svn_ra_serf__context_run_one(handler, pool);
 
   SVN_ERR(svn_error_compose_create(
-              svn_ra_serf__error_on_status(handler->sline.code,
+              svn_ra_serf__error_on_status(handler->sline,
                                            req_url,
                                            handler->location),
               err));

Modified: subversion/trunk/subversion/libsvn_ra_serf/getlocationsegments.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/getlocationsegments.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/getlocationsegments.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/getlocationsegments.c Thu Jun 20 17:06:22 2013
@@ -194,7 +194,7 @@ svn_ra_serf__get_location_segments(svn_r
   err = svn_ra_serf__context_run_one(handler, pool);
 
   err = svn_error_compose_create(
-         svn_ra_serf__error_on_status(handler->sline.code,
+         svn_ra_serf__error_on_status(handler->sline,
                                       handler->path,
                                       handler->location),
          err);

Modified: subversion/trunk/subversion/libsvn_ra_serf/getlocks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/getlocks.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/getlocks.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/getlocks.c Thu Jun 20 17:06:22 2013
@@ -266,7 +266,7 @@ svn_ra_serf__get_locks(svn_ra_session_t 
      have existed earlier (E.g. 'svn ls http://s/svn/trunk/file@1' */
   if (handler->sline.code != 404)
     {
-      SVN_ERR(svn_ra_serf__error_on_status(handler->sline.code,
+      SVN_ERR(svn_ra_serf__error_on_status(handler->sline,
                                            handler->path,
                                            handler->location));
     }

Modified: subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c Thu Jun 20 17:06:22 2013
@@ -332,7 +332,7 @@ svn_ra_serf__get_inherited_props(svn_ra_
 
   err = svn_ra_serf__context_run_one(handler, scratch_pool);
   SVN_ERR(svn_error_compose_create(
-                    svn_ra_serf__error_on_status(handler->sline.code,
+                    svn_ra_serf__error_on_status(handler->sline,
                                                  handler->path,
                                                  handler->location),
                     err));

Modified: subversion/trunk/subversion/libsvn_ra_serf/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/log.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/log.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/log.c Thu Jun 20 17:06:22 2013
@@ -595,7 +595,7 @@ svn_ra_serf__get_log(svn_ra_session_t *r
   err = svn_ra_serf__context_run_one(handler, pool);
 
   SVN_ERR(svn_error_compose_create(
-              svn_ra_serf__error_on_status(handler->sline.code,
+              svn_ra_serf__error_on_status(handler->sline,
                                            req_url,
                                            handler->location),
               err));

Modified: subversion/trunk/subversion/libsvn_ra_serf/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/mergeinfo.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/mergeinfo.c Thu Jun 20 17:06:22 2013
@@ -191,7 +191,7 @@ svn_ra_serf__get_mergeinfo(svn_ra_sessio
                            svn_boolean_t include_descendants,
                            apr_pool_t *pool)
 {
-  svn_error_t *err, *err2;
+  svn_error_t *err;
   mergeinfo_context_t *mergeinfo_ctx;
   svn_ra_serf__session_t *session = ra_session->priv;
   svn_ra_serf__handler_t *handler;
@@ -229,15 +229,10 @@ svn_ra_serf__get_mergeinfo(svn_ra_sessio
 
   err = svn_ra_serf__context_run_one(handler, pool);
 
-  err2 = svn_ra_serf__error_on_status(handler->sline.code, handler->path,
-                                      handler->location);
-  if (err2)
-    {
-      svn_error_clear(err);
-      return err2;
-    }
-
-  SVN_ERR(err);
+  SVN_ERR(svn_error_compose_create(
+                svn_ra_serf__error_on_status(handler->sline, handler->path,
+                                             handler->location),
+                err));
 
   if (handler->done && apr_hash_count(mergeinfo_ctx->result_catalog))
     *catalog = mergeinfo_ctx->result_catalog;

Modified: subversion/trunk/subversion/libsvn_ra_serf/options.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/options.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/options.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/options.c Thu Jun 20 17:06:22 2013
@@ -436,11 +436,12 @@ svn_ra_serf__v2_get_youngest_revnum(svn_
 
   SVN_ERR(create_options_req(&opt_ctx, session, conn, scratch_pool));
   SVN_ERR(svn_ra_serf__context_run_one(opt_ctx->handler, scratch_pool));
-  SVN_ERR(svn_ra_serf__error_on_status(opt_ctx->handler->sline.code,
+  SVN_ERR(svn_ra_serf__error_on_status(opt_ctx->handler->sline,
                                        opt_ctx->handler->path,
                                        opt_ctx->handler->location));
 
   *youngest = opt_ctx->youngest_rev;
+  SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(*youngest));
 
   return SVN_NO_ERROR;
 }
@@ -460,7 +461,7 @@ svn_ra_serf__v1_get_activity_collection(
   SVN_ERR(create_options_req(&opt_ctx, session, conn, scratch_pool));
   SVN_ERR(svn_ra_serf__context_run_one(opt_ctx->handler, scratch_pool));
 
-  SVN_ERR(svn_ra_serf__error_on_status(opt_ctx->handler->sline.code,
+  SVN_ERR(svn_ra_serf__error_on_status(opt_ctx->handler->sline,
                                        opt_ctx->handler->path,
                                        opt_ctx->handler->location));
 
@@ -499,7 +500,7 @@ svn_ra_serf__exchange_capabilities(svn_r
     }
 
   SVN_ERR(svn_error_compose_create(
-              svn_ra_serf__error_on_status(opt_ctx->handler->sline.code,
+              svn_ra_serf__error_on_status(opt_ctx->handler->sline,
                                            serf_sess->session_url.path,
                                            opt_ctx->handler->location),
               err));

Modified: subversion/trunk/subversion/libsvn_ra_serf/property.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/property.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/property.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/property.c Thu Jun 20 17:06:22 2013
@@ -635,7 +635,7 @@ svn_ra_serf__wait_for_props(svn_ra_serf_
 
   err = svn_ra_serf__context_run_one(handler, scratch_pool);
 
-  err2 = svn_ra_serf__error_on_status(handler->sline.code,
+  err2 = svn_ra_serf__error_on_status(handler->sline,
                                       handler->path,
                                       handler->location);
 

Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Thu Jun 20 17:06:22 2013
@@ -1744,7 +1744,7 @@ svn_ra_serf__credentials_callback(char *
  * where it necessary.
  */
 svn_error_t *
-svn_ra_serf__error_on_status(int status_code,
+svn_ra_serf__error_on_status(serf_status_line sline,
                              const char *path,
                              const char *location);
 

Modified: subversion/trunk/subversion/libsvn_ra_serf/replay.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/replay.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/replay.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/replay.c Thu Jun 20 17:06:22 2013
@@ -696,7 +696,7 @@ svn_ra_serf__replay(svn_ra_session_t *ra
   err = svn_ra_serf__context_run_wait(&replay_ctx->done, session, pool);
 
   SVN_ERR(svn_error_compose_create(
-              svn_ra_serf__error_on_status(handler->sline.code,
+              svn_ra_serf__error_on_status(handler->sline,
                                            handler->path,
                                            handler->location),
               err));
@@ -905,7 +905,7 @@ svn_ra_serf__replay_range(svn_ra_session
           svn_ra_serf__handler_t *done_handler = ctx->report_handler;
 
           done_list = done_list->next;
-          SVN_ERR(svn_ra_serf__error_on_status(done_handler->sline.code,
+          SVN_ERR(svn_ra_serf__error_on_status(done_handler->sline,
                                                done_handler->path,
                                                done_handler->location));
           svn_pool_destroy(ctx->src_rev_pool);

Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Thu Jun 20 17:06:22 2013
@@ -1268,7 +1268,7 @@ handle_stream(serf_request_t *request,
   /* ### new field. make sure we didn't miss some initialization.  */
   SVN_ERR_ASSERT(fetch_ctx->handler != NULL);
 
-  err = svn_ra_serf__error_on_status(fetch_ctx->handler->sline.code,
+  err = svn_ra_serf__error_on_status(fetch_ctx->handler->sline,
                                      fetch_ctx->info->name,
                                      fetch_ctx->handler->location);
   if (err)
@@ -2891,7 +2891,7 @@ finish_report(void *report_baton,
         {
           return svn_error_trace(
                     svn_error_compose_create(
-                        svn_ra_serf__error_on_status(handler->sline.code,
+                        svn_ra_serf__error_on_status(handler->sline,
                                                      handler->path,
                                                      handler->location),
                         err));

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1495104&r1=1495103&r2=1495104&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Thu Jun 20 17:06:22 2013
@@ -2386,17 +2386,17 @@ svn_ra_serf__report_resource(const char 
 }
 
 svn_error_t *
-svn_ra_serf__error_on_status(int status_code,
+svn_ra_serf__error_on_status(serf_status_line sline,
                              const char *path,
                              const char *location)
 {
-  switch(status_code)
+  switch(sline.code)
     {
       case 301:
       case 302:
       case 307:
         return svn_error_createf(SVN_ERR_RA_DAV_RELOCATED, NULL,
-                                 (status_code == 301)
+                                 (sline.code == 301)
                                  ? _("Repository moved permanently to '%s';"
                                      " please relocate")
                                  : _("Repository moved temporarily to '%s';"
@@ -2411,8 +2411,18 @@ svn_ra_serf__error_on_status(int status_
       case 423:
         return svn_error_createf(SVN_ERR_FS_NO_LOCK_TOKEN, NULL,
                                  _("'%s': no lock token available"), path);
+
+      case 411:
+        return svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
+                                _("DAV request failed: "
+                                  "Content length required"));
     }
 
+  if (sline.code >= 300)
+    return svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
+                             _("Unexpected HTTP status %d '%s' on '%s'\n"),
+                             sline.code, sline.reason, path);
+
   return SVN_NO_ERROR;
 }