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/12/18 12:07:32 UTC

svn commit: r1551910 - in /subversion/trunk/subversion/libsvn_ra_serf: get_lock.c lock.c locks.c

Author: rhuijben
Date: Wed Dec 18 11:07:32 2013
New Revision: 1551910

URL: http://svn.apache.org/r1551910
Log:
In ra serf: decouple the code that implements svn_ra_get_lock() from the code that
implements svn_ra_lock() and svn_ra_unlock(). This fixes a few error messages for
unlikely http response codes for get_lock and allows further refactoring for lock
and unlock.

* subversion/libsvn_ra_serf/getlock.c
  New file. Copied from locks.c.
  (lock_info_t): Remove two variables.
  (locks_ttable): Remove invalid transition.
  (set_lock_headers,
   determine_error): Remove functions.
  (handle_lock): Remove specialized error handling.
  (create_lock_body): Remove function.
  (svn_ra_serf__get_lock): Use standard error reporting and extend with
    handling as we did for neon.
  (svn_ra_serf__lock): Remove function.
  (unlock_context_t): Remove struct.
  (set_unlock_headers,
   svn_ra_serf__unlock): Remove function.

* subversion/libsvn_ra_serf/lock.c
  New file. Copied from locks.c.
  (unnamed enum): Remove unused values.
  (lock_info_t): Rename to...
  (lock_ctx_t): ... this.
  (locks_ttable): Remove invalid transitions.
  (locks_expected_status): Remove variable.
  (locks_closed,
   set_lock_headers,
   handle_lock): Update caller.
  (create_getlock_body,
   setup_getlock_headers): Remove function.
  (create_lock_body): Update caller.
  (svn_ra_serf__get_lock): Remove function.
  (svn_ra_serf__lock): Update caller.

* subversion/libsvn_ra_serf/locks.c

Added:
    subversion/trunk/subversion/libsvn_ra_serf/get_lock.c
      - copied, changed from r1551888, subversion/trunk/subversion/libsvn_ra_serf/locks.c
    subversion/trunk/subversion/libsvn_ra_serf/lock.c
      - copied, changed from r1551888, subversion/trunk/subversion/libsvn_ra_serf/locks.c
Removed:
    subversion/trunk/subversion/libsvn_ra_serf/locks.c

Copied: subversion/trunk/subversion/libsvn_ra_serf/get_lock.c (from r1551888, subversion/trunk/subversion/libsvn_ra_serf/locks.c)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/get_lock.c?p2=subversion/trunk/subversion/libsvn_ra_serf/get_lock.c&p1=subversion/trunk/subversion/libsvn_ra_serf/locks.c&r1=1551888&r2=1551910&rev=1551910&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/locks.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/get_lock.c Wed Dec 18 11:07:32 2013
@@ -1,5 +1,5 @@
 /*
- * locks.c :  entry point for locking RA functions for ra_serf
+ * get_lock.c :  obtain single lock information functions for ra_serf
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -66,9 +66,6 @@ typedef struct lock_info_t {
 
   svn_lock_t *lock;
 
-  svn_boolean_t force;
-  svn_revnum_t revision;
-
   svn_boolean_t read_headers;
 
   svn_ra_serf__handler_t *handler;
@@ -84,8 +81,6 @@ typedef struct lock_info_t {
 static const svn_ra_serf__xml_transition_t locks_ttable[] = {
   /* The INITIAL state can transition into D:prop (LOCK) or
      to D:multistatus (PROPFIND)  */
-  { INITIAL, D_, "prop", PROP,
-    FALSE, { NULL }, FALSE },
   { INITIAL, D_, "multistatus", MULTISTATUS,
     FALSE, { NULL }, FALSE },
 
@@ -188,59 +183,6 @@ locks_closed(svn_ra_serf__xml_estate_t *
   return SVN_NO_ERROR;
 }
 
-
-static svn_error_t *
-set_lock_headers(serf_bucket_t *headers,
-                 void *baton,
-                 apr_pool_t *pool)
-{
-  lock_info_t *lock_ctx = baton;
-
-  if (lock_ctx->force)
-    {
-      serf_bucket_headers_set(headers, SVN_DAV_OPTIONS_HEADER,
-                              SVN_DAV_OPTION_LOCK_STEAL);
-    }
-
-  if (SVN_IS_VALID_REVNUM(lock_ctx->revision))
-    {
-      serf_bucket_headers_set(headers, SVN_DAV_VERSION_NAME_HEADER,
-                              apr_ltoa(pool, lock_ctx->revision));
-    }
-
-  return APR_SUCCESS;
-}
-
-
-/* Register an error within the session. If something is already there,
-   then it will take precedence.  */
-static svn_error_t *
-determine_error(svn_ra_serf__handler_t *handler,
-                svn_error_t *err)
-{
-  apr_status_t errcode;
-
-  if (err)
-    return err;
-
-  if (handler->sline.code == 200 || handler->sline.code == 207)
-    return SVN_NO_ERROR;
-  else if (handler->sline.code == 423)
-    errcode = SVN_ERR_FS_PATH_ALREADY_LOCKED;
-  else if (handler->sline.code == 403)
-    errcode = SVN_ERR_RA_DAV_FORBIDDEN;
-  else
-    errcode = SVN_ERR_RA_DAV_REQUEST_FAILED;
-
-  /* The server did not send us a detailed human-readable error.
-     Provide a generic error.  */
-  return svn_error_createf(errcode, NULL,
-                           _("Lock request failed: %d %s"),
-                           handler->sline.code,
-                           handler->sline.reason ? handler->sline.reason : "");
-}
-
-
 /* Implements svn_ra_serf__response_handler_t */
 static svn_error_t *
 handle_lock(serf_request_t *request,
@@ -250,18 +192,6 @@ handle_lock(serf_request_t *request,
 {
   lock_info_t *ctx = handler_baton;
 
-  /* 403 (Forbidden) when a lock doesn't exist.
-     423 (Locked) when a lock already exists.  */
-  if (ctx->handler->sline.code == 403
-      || ctx->handler->sline.code == 423)
-    {
-      /* Go look in the body for a server-provided error. This will
-         reset flags for the core handler to Do The Right Thing. We
-         won't be back to this handler again.  */
-      return svn_error_trace(svn_ra_serf__expect_empty_body(
-                               request, response, ctx->handler, pool));
-    }
-
   if (!ctx->read_headers)
     {
       serf_bucket_t *headers;
@@ -322,43 +252,6 @@ setup_getlock_headers(serf_bucket_t *hea
   return SVN_NO_ERROR;
 }
 
-/* Implements svn_ra_serf__request_body_delegate_t */
-static svn_error_t *
-create_lock_body(serf_bucket_t **body_bkt,
-                 void *baton,
-                 serf_bucket_alloc_t *alloc,
-                 apr_pool_t *pool)
-{
-  lock_info_t *ctx = baton;
-  serf_bucket_t *buckets;
-
-  buckets = serf_bucket_aggregate_create(alloc);
-
-  svn_ra_serf__add_xml_header_buckets(buckets, alloc);
-  svn_ra_serf__add_open_tag_buckets(buckets, alloc, "lockinfo",
-                                    "xmlns", "DAV:",
-                                    SVN_VA_NULL);
-
-  svn_ra_serf__add_open_tag_buckets(buckets, alloc, "lockscope", SVN_VA_NULL);
-  svn_ra_serf__add_tag_buckets(buckets, "exclusive", NULL, alloc);
-  svn_ra_serf__add_close_tag_buckets(buckets, alloc, "lockscope");
-
-  svn_ra_serf__add_open_tag_buckets(buckets, alloc, "locktype", SVN_VA_NULL);
-  svn_ra_serf__add_tag_buckets(buckets, "write", NULL, alloc);
-  svn_ra_serf__add_close_tag_buckets(buckets, alloc, "locktype");
-
-  if (ctx->lock->comment)
-    {
-      svn_ra_serf__add_tag_buckets(buckets, "owner", ctx->lock->comment,
-                                   alloc);
-    }
-
-  svn_ra_serf__add_close_tag_buckets(buckets, alloc, "lockinfo");
-
-  *body_bkt = buckets;
-  return SVN_NO_ERROR;
-}
-
 svn_error_t *
 svn_ra_serf__get_lock(svn_ra_session_t *ra_session,
                       svn_lock_t **lock,
@@ -407,249 +300,21 @@ svn_ra_serf__get_lock(svn_ra_session_t *
   lock_ctx->handler = handler;
 
   err = svn_ra_serf__context_run_one(handler, pool);
-  err = svn_error_trace(determine_error(handler, err));
+  err = svn_error_compose_create(
+                    svn_ra_serf__error_on_status(handler->sline,
+                                                 handler->path,
+                                                 handler->location),
+                    err);
 
-  if (handler->sline.code == 404)
-    {
-      return svn_error_create(SVN_ERR_RA_ILLEGAL_URL, err,
-                              _("Malformed URL for repository"));
-    }
   if (err)
     {
       /* TODO Shh.  We're telling a white lie for now. */
-      return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, err,
-                              _("Server does not support locking features"));
+      return svn_error_trace(
+             svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, err,
+                              _("Server does not support locking features")));
     }
 
   *lock = lock_ctx->lock;
 
   return SVN_NO_ERROR;
 }
-
-svn_error_t *
-svn_ra_serf__lock(svn_ra_session_t *ra_session,
-                  apr_hash_t *path_revs,
-                  const char *comment,
-                  svn_boolean_t force,
-                  svn_ra_lock_callback_t lock_func,
-                  void *lock_baton,
-                  apr_pool_t *scratch_pool)
-{
-  svn_ra_serf__session_t *session = ra_session->priv;
-  apr_hash_index_t *hi;
-  apr_pool_t *iterpool;
-
-  iterpool = svn_pool_create(scratch_pool);
-
-  /* ### TODO for issue 2263: Send all the locks over the wire at once.  This
-     ### loop is just a temporary shim.
-     ### an alternative, which is backwards-compat with all servers is to
-     ### pipeline these requests. ie. stop using run_wait/run_one.  */
-
-  for (hi = apr_hash_first(scratch_pool, path_revs);
-       hi;
-       hi = apr_hash_next(hi))
-    {
-      svn_ra_serf__handler_t *handler;
-      svn_ra_serf__xml_context_t *xmlctx;
-      const char *req_url;
-      lock_info_t *lock_ctx;
-      svn_error_t *err;
-      svn_error_t *new_err = NULL;
-
-      svn_pool_clear(iterpool);
-
-      lock_ctx = apr_pcalloc(iterpool, sizeof(*lock_ctx));
-
-      lock_ctx->pool = iterpool;
-      lock_ctx->path = svn__apr_hash_index_key(hi);
-      lock_ctx->revision = *((svn_revnum_t*)svn__apr_hash_index_val(hi));
-      lock_ctx->lock = svn_lock_create(iterpool);
-      lock_ctx->lock->path = lock_ctx->path;
-      lock_ctx->lock->comment = comment;
-
-      lock_ctx->force = force;
-      req_url = svn_path_url_add_component2(session->session_url.path,
-                                            lock_ctx->path, iterpool);
-
-      xmlctx = svn_ra_serf__xml_context_create(locks_ttable,
-                                               NULL, locks_closed, NULL, NULL,
-                                               lock_ctx,
-                                               iterpool);
-      handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, iterpool);
-
-      handler->method = "LOCK";
-      handler->path = req_url;
-      handler->body_type = "text/xml";
-      handler->conn = session->conns[0];
-      handler->session = session;
-
-      handler->header_delegate = set_lock_headers;
-      handler->header_delegate_baton = lock_ctx;
-
-      handler->body_delegate = create_lock_body;
-      handler->body_delegate_baton = lock_ctx;
-
-      lock_ctx->inner_handler = handler->response_handler;
-      lock_ctx->inner_baton = handler->response_baton;
-      handler->response_handler = handle_lock;
-      handler->response_baton = lock_ctx;
-
-      lock_ctx->handler = handler;
-
-      err = svn_ra_serf__context_run_one(handler, iterpool);
-      err = svn_error_trace(determine_error(handler, err));
-
-      if (lock_func)
-        new_err = lock_func(lock_baton, lock_ctx->path, TRUE, lock_ctx->lock,
-                            err, iterpool);
-      svn_error_clear(err);
-
-      SVN_ERR(new_err);
-    }
-
-  svn_pool_destroy(iterpool);
-
-  return SVN_NO_ERROR;
-}
-
-struct unlock_context_t {
-  const char *token;
-  svn_boolean_t force;
-};
-
-static svn_error_t *
-set_unlock_headers(serf_bucket_t *headers,
-                   void *baton,
-                   apr_pool_t *pool)
-{
-  struct unlock_context_t *ctx = baton;
-
-  serf_bucket_headers_set(headers, "Lock-Token", ctx->token);
-  if (ctx->force)
-    {
-      serf_bucket_headers_set(headers, SVN_DAV_OPTIONS_HEADER,
-                              SVN_DAV_OPTION_LOCK_BREAK);
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_ra_serf__unlock(svn_ra_session_t *ra_session,
-                    apr_hash_t *path_tokens,
-                    svn_boolean_t force,
-                    svn_ra_lock_callback_t lock_func,
-                    void *lock_baton,
-                    apr_pool_t *scratch_pool)
-{
-  svn_ra_serf__session_t *session = ra_session->priv;
-  apr_hash_index_t *hi;
-  apr_pool_t *iterpool;
-
-  iterpool = svn_pool_create(scratch_pool);
-
-  /* ### TODO for issue 2263: Send all the locks over the wire at once.  This
-     ### loop is just a temporary shim.
-     ### an alternative, which is backwards-compat with all servers is to
-     ### pipeline these requests. ie. stop using run_wait/run_one.  */
-
-  for (hi = apr_hash_first(scratch_pool, path_tokens);
-       hi;
-       hi = apr_hash_next(hi))
-    {
-      svn_ra_serf__handler_t *handler;
-      const char *req_url, *path, *token;
-      svn_lock_t *existing_lock = NULL;
-      struct unlock_context_t unlock_ctx;
-      svn_error_t *err = NULL;
-      svn_error_t *new_err = NULL;
-
-
-      svn_pool_clear(iterpool);
-
-      path = svn__apr_hash_index_key(hi);
-      token = svn__apr_hash_index_val(hi);
-
-      if (force && (!token || token[0] == '\0'))
-        {
-          SVN_ERR(svn_ra_serf__get_lock(ra_session, &existing_lock, path,
-                                        iterpool));
-          token = existing_lock->token;
-          if (!token)
-            {
-              err = svn_error_createf(SVN_ERR_RA_NOT_LOCKED, NULL,
-                                      _("'%s' is not locked in the repository"),
-                                      path);
-
-              if (lock_func)
-                {
-                  svn_error_t *err2;
-                  err2 = lock_func(lock_baton, path, FALSE, NULL, err,
-                                   iterpool);
-                  svn_error_clear(err);
-                  err = NULL;
-                  if (err2)
-                    return svn_error_trace(err2);
-                }
-              else
-                {
-                  svn_error_clear(err);
-                  err = NULL;
-                }
-              continue;
-            }
-        }
-
-      unlock_ctx.force = force;
-      unlock_ctx.token = apr_pstrcat(iterpool, "<", token, ">", SVN_VA_NULL);
-
-      req_url = svn_path_url_add_component2(session->session_url.path, path,
-                                            iterpool);
-
-      handler = apr_pcalloc(iterpool, sizeof(*handler));
-
-      handler->handler_pool = iterpool;
-      handler->method = "UNLOCK";
-      handler->path = req_url;
-      handler->conn = session->conns[0];
-      handler->session = session;
-
-      handler->header_delegate = set_unlock_headers;
-      handler->header_delegate_baton = &unlock_ctx;
-
-      handler->response_handler = svn_ra_serf__expect_empty_body;
-      handler->response_baton = handler;
-
-      SVN_ERR(svn_ra_serf__context_run_one(handler, iterpool));
-
-      switch (handler->sline.code)
-        {
-          case 204:
-            break; /* OK */
-          case 403:
-            /* Api users expect this specific error code to detect failures */
-            err = svn_error_createf(SVN_ERR_FS_LOCK_OWNER_MISMATCH, NULL,
-                                    _("Unlock request failed: %d %s"),
-                                    handler->sline.code,
-                                    handler->sline.reason);
-            break;
-          default:
-            err = svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
-                                    _("Unlock request failed: %d %s"),
-                                    handler->sline.code,
-                                    handler->sline.reason);
-        }
-
-      if (lock_func)
-        new_err = lock_func(lock_baton, path, FALSE, existing_lock, err,
-                            iterpool);
-
-      svn_error_clear(err);
-      SVN_ERR(new_err);
-    }
-
-  svn_pool_destroy(iterpool);
-
-  return SVN_NO_ERROR;
-}

Copied: subversion/trunk/subversion/libsvn_ra_serf/lock.c (from r1551888, subversion/trunk/subversion/libsvn_ra_serf/locks.c)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/lock.c?p2=subversion/trunk/subversion/libsvn_ra_serf/lock.c&p1=subversion/trunk/subversion/libsvn_ra_serf/locks.c&r1=1551888&r2=1551910&rev=1551910&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/locks.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/lock.c Wed Dec 18 11:07:32 2013
@@ -1,5 +1,5 @@
 /*
- * locks.c :  entry point for locking RA functions for ra_serf
+ * lock.c :  entry point for locking RA functions for ra_serf
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -44,9 +44,6 @@
  */
 enum {
   INITIAL = 0,
-  MULTISTATUS,
-  RESPONSE,
-  PROPSTAT,
   PROP,
   LOCK_DISCOVERY,
   ACTIVE_LOCK,
@@ -59,7 +56,8 @@ enum {
   HREF
 };
 
-typedef struct lock_info_t {
+
+typedef struct lock_ctx_t {
   apr_pool_t *pool;
 
   const char *path;
@@ -77,7 +75,8 @@ typedef struct lock_info_t {
   svn_ra_serf__response_handler_t inner_handler;
   void *inner_baton;
 
-} lock_info_t;
+} lock_ctx_t;
+
 
 #define D_ "DAV:"
 #define S_ SVN_XML_NAMESPACE
@@ -86,14 +85,6 @@ static const svn_ra_serf__xml_transition
      to D:multistatus (PROPFIND)  */
   { INITIAL, D_, "prop", PROP,
     FALSE, { NULL }, FALSE },
-  { INITIAL, D_, "multistatus", MULTISTATUS,
-    FALSE, { NULL }, FALSE },
-
-  { MULTISTATUS, D_, "response", RESPONSE,
-    FALSE, { NULL }, FALSE },
-
-  { RESPONSE, D_, "propstat", PROPSTAT,
-    FALSE, { NULL }, FALSE },
 
   { PROPSTAT, D_, "prop", PROP,
     FALSE, { NULL }, FALSE },
@@ -142,11 +133,6 @@ static const svn_ra_serf__xml_transition
   { 0 }
 };
 
-static const int locks_expected_status[] = {
-  207,
-  0
-};
-
 /* Conforms to svn_ra_serf__xml_closed_t  */
 static svn_error_t *
 locks_closed(svn_ra_serf__xml_estate_t *xes,
@@ -156,7 +142,7 @@ locks_closed(svn_ra_serf__xml_estate_t *
              apr_hash_t *attrs,
              apr_pool_t *scratch_pool)
 {
-  lock_info_t *lock_ctx = baton;
+  lock_ctx_t *lock_ctx = baton;
 
   if (leaving_state == TIMEOUT)
     {
@@ -194,7 +180,7 @@ set_lock_headers(serf_bucket_t *headers,
                  void *baton,
                  apr_pool_t *pool)
 {
-  lock_info_t *lock_ctx = baton;
+  lock_ctx_t *lock_ctx = baton;
 
   if (lock_ctx->force)
     {
@@ -248,7 +234,7 @@ handle_lock(serf_request_t *request,
             void *handler_baton,
             apr_pool_t *pool)
 {
-  lock_info_t *ctx = handler_baton;
+  lock_ctx_t *ctx = handler_baton;
 
   /* 403 (Forbidden) when a lock doesn't exist.
      423 (Locked) when a lock already exists.  */
@@ -290,46 +276,12 @@ handle_lock(serf_request_t *request,
 
 /* Implements svn_ra_serf__request_body_delegate_t */
 static svn_error_t *
-create_getlock_body(serf_bucket_t **body_bkt,
-                    void *baton,
-                    serf_bucket_alloc_t *alloc,
-                    apr_pool_t *pool)
-{
-  serf_bucket_t *buckets;
-
-  buckets = serf_bucket_aggregate_create(alloc);
-
-  svn_ra_serf__add_xml_header_buckets(buckets, alloc);
-  svn_ra_serf__add_open_tag_buckets(buckets, alloc, "propfind",
-                                    "xmlns", "DAV:",
-                                    SVN_VA_NULL);
-  svn_ra_serf__add_open_tag_buckets(buckets, alloc, "prop", SVN_VA_NULL);
-  svn_ra_serf__add_tag_buckets(buckets, "lockdiscovery", NULL, alloc);
-  svn_ra_serf__add_close_tag_buckets(buckets, alloc, "prop");
-  svn_ra_serf__add_close_tag_buckets(buckets, alloc, "propfind");
-
-  *body_bkt = buckets;
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t*
-setup_getlock_headers(serf_bucket_t *headers,
-                      void *baton,
-                      apr_pool_t *pool)
-{
-  serf_bucket_headers_setn(headers, "Depth", "0");
-
-  return SVN_NO_ERROR;
-}
-
-/* Implements svn_ra_serf__request_body_delegate_t */
-static svn_error_t *
 create_lock_body(serf_bucket_t **body_bkt,
                  void *baton,
                  serf_bucket_alloc_t *alloc,
                  apr_pool_t *pool)
 {
-  lock_info_t *ctx = baton;
+  lock_ctx_t *ctx = baton;
   serf_bucket_t *buckets;
 
   buckets = serf_bucket_aggregate_create(alloc);
@@ -360,73 +312,6 @@ create_lock_body(serf_bucket_t **body_bk
 }
 
 svn_error_t *
-svn_ra_serf__get_lock(svn_ra_session_t *ra_session,
-                      svn_lock_t **lock,
-                      const char *path,
-                      apr_pool_t *pool)
-{
-  svn_ra_serf__session_t *session = ra_session->priv;
-  svn_ra_serf__handler_t *handler;
-  svn_ra_serf__xml_context_t *xmlctx;
-  lock_info_t *lock_ctx;
-  const char *req_url;
-  svn_error_t *err;
-
-  req_url = svn_path_url_add_component2(session->session_url.path, path, pool);
-
-  lock_ctx = apr_pcalloc(pool, sizeof(*lock_ctx));
-
-  lock_ctx->pool = pool;
-  lock_ctx->path = req_url;
-  lock_ctx->lock = svn_lock_create(pool);
-  lock_ctx->lock->path = apr_pstrdup(pool, path); /* be sure  */
-
-  xmlctx = svn_ra_serf__xml_context_create(locks_ttable,
-                                           NULL, locks_closed, NULL, NULL,
-                                           lock_ctx,
-                                           pool);
-  handler = svn_ra_serf__create_expat_handler(xmlctx, locks_expected_status, pool);
-
-  handler->method = "PROPFIND";
-  handler->path = req_url;
-  handler->body_type = "text/xml";
-  handler->conn = session->conns[0];
-  handler->session = session;
-
-  handler->body_delegate = create_getlock_body;
-  handler->body_delegate_baton = lock_ctx;
-
-  handler->header_delegate = setup_getlock_headers;
-  handler->header_delegate_baton = lock_ctx;
-
-  lock_ctx->inner_handler = handler->response_handler;
-  lock_ctx->inner_baton = handler->response_baton;
-  handler->response_handler = handle_lock;
-  handler->response_baton = lock_ctx;
-
-  lock_ctx->handler = handler;
-
-  err = svn_ra_serf__context_run_one(handler, pool);
-  err = svn_error_trace(determine_error(handler, err));
-
-  if (handler->sline.code == 404)
-    {
-      return svn_error_create(SVN_ERR_RA_ILLEGAL_URL, err,
-                              _("Malformed URL for repository"));
-    }
-  if (err)
-    {
-      /* TODO Shh.  We're telling a white lie for now. */
-      return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, err,
-                              _("Server does not support locking features"));
-    }
-
-  *lock = lock_ctx->lock;
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
 svn_ra_serf__lock(svn_ra_session_t *ra_session,
                   apr_hash_t *path_revs,
                   const char *comment,
@@ -453,7 +338,7 @@ svn_ra_serf__lock(svn_ra_session_t *ra_s
       svn_ra_serf__handler_t *handler;
       svn_ra_serf__xml_context_t *xmlctx;
       const char *req_url;
-      lock_info_t *lock_ctx;
+      lock_ctx_t *lock_ctx;
       svn_error_t *err;
       svn_error_t *new_err = NULL;