You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Stein <gs...@gmail.com> on 2009/02/03 17:25:05 UTC

Re: svn commit: r35632 - in branches/http-protocol-v2: . subversion/libsvn_ra_neon

Dear CMike,

I haven't reviewed this. Not gonna. Waste of effort.

Cheers,
-g

On Mon, Feb 2, 2009 at 17:06, C. Michael Pilato <cm...@collab.net> wrote:
> Author: cmpilato
> Date: Mon Feb  2 08:06:34 2009
> New Revision: 35632
>
> Log:
> Dear Greg S.,
>
> On the 'http-protocol-v2' branch:  Grab some low-hanging fruit,
> teaching ra-neon to do some of the HTTP v2 stuff.
>
> * subversion/libsvn_ra_neon/ra_neon.h
>  (svn_ra_neon__session_t): Add 'me_resource', 'pegrev_stub', and
>    'rev_stub' members.
>  (SVN_RA_NEON__HAVE_HTTPV2_SUPPORT): New macro.
>
> * subversion/libsvn_ra_neon/options.c
>  (parse_capabilities): Notice and cache some of the new HTTP v2
>    OPTIONS response header values.
>
> * subversion/libsvn_ra_neon/fetch.c
>  (reporter_finish_report): Report against the "me resource" if we can.
>  (svn_ra_neon__rev_proplist): Use new "rev stub" if we can.
>
> * subversion/libsvn_ra_neon/get_dated_rev.c
>  (svn_ra_neon__get_dated_revision): Report against the "me resource"
>    if we can.
>
> * BRANCH-README
>  Update status.
>
> Love,
>
> C-Mike
>
> Modified:
>   branches/http-protocol-v2/BRANCH-README
>   branches/http-protocol-v2/subversion/libsvn_ra_neon/fetch.c
>   branches/http-protocol-v2/subversion/libsvn_ra_neon/get_dated_rev.c
>   branches/http-protocol-v2/subversion/libsvn_ra_neon/options.c
>   branches/http-protocol-v2/subversion/libsvn_ra_neon/ra_neon.h
>
> Modified: branches/http-protocol-v2/BRANCH-README
> URL: http://svn.collab.net/viewvc/svn/branches/http-protocol-v2/BRANCH-README?pathrev=35632&r1=35631&r2=35632
> ==============================================================================
> --- branches/http-protocol-v2/BRANCH-README     Mon Feb  2 07:56:44 2009        (r35631)
> +++ branches/http-protocol-v2/BRANCH-README     Mon Feb  2 08:06:34 2009        (r35632)
> @@ -67,7 +67,7 @@ TODO:
>
>  * Optional:  Do some of this stuff for ra_neon, too:
>
> -    - Get and cache UUID and repos_root from OPTIONS
> -    - Get me resource, and pegrev stub from OPTIONS
> -    - Use me resource instead of the VCC
> -    - Use pegrev stubs instead of get_baseline_info() walks
> +    - Get and cache UUID and repos_root from OPTIONS         [DONE]
> +    - Get me resource, and pegrev stub from OPTIONS          [DONE]
> +    - Use me resource instead of the VCC                     [STARTED]
> +    - Use pegrev stubs instead of get_baseline_info() walks  [STARTED]
>
> Modified: branches/http-protocol-v2/subversion/libsvn_ra_neon/fetch.c
> URL: http://svn.collab.net/viewvc/svn/branches/http-protocol-v2/subversion/libsvn_ra_neon/fetch.c?pathrev=35632&r1=35631&r2=35632
> ==============================================================================
> --- branches/http-protocol-v2/subversion/libsvn_ra_neon/fetch.c Mon Feb  2 07:56:44 2009        (r35631)
> +++ branches/http-protocol-v2/subversion/libsvn_ra_neon/fetch.c Mon Feb  2 08:06:34 2009        (r35632)
> @@ -1178,23 +1178,31 @@ svn_error_t *svn_ra_neon__rev_proplist(s
>                                        apr_pool_t *pool)
>  {
>   svn_ra_neon__session_t *ras = session->priv;
> -  svn_ra_neon__resource_t *baseline;
> +  svn_ra_neon__resource_t *bln;
>
>   *props = apr_hash_make(pool);
>
> -  /* Main objective: do a PROPFIND (allprops) on a baseline object */
> -  SVN_ERR(svn_ra_neon__get_baseline_props(NULL, &baseline,
> -                                          ras,
> -                                          ras->url->data,
> -                                          rev,
> -                                          NULL, /* get ALL properties */
> -                                          pool));
> +  /* Main objective: do a PROPFIND (allprops) on a baseline object. If we
> +     have HTTP v2 support available, we can build the URI of that object.
> +     Otherwise, we have to hunt for a bit.  (We pass NULL for 'which_props'
> +     in these functions because we want 'em all.)  */
> +  if (SVN_RA_NEON__HAVE_HTTPV2_SUPPORT(ras))
> +    {
> +      const char *url = apr_psprintf(pool, "%s/%ld", ras->rev_stub, rev);
> +      SVN_ERR(svn_ra_neon__get_props_resource(&bln, ras, url,
> +                                              NULL, NULL, pool));
> +    }
> +  else
> +    {
> +      SVN_ERR(svn_ra_neon__get_baseline_props(NULL, &bln, ras, ras->url->data,
> +                                              rev, NULL, pool));
> +    }
>
>   /* Build a new property hash, based on the one in the baseline
>      resource.  In particular, convert the xml-property-namespaces
>      into ones that the client understands.  Strip away the DAV:
>      liveprops as well. */
> -  return filter_props(*props, baseline, FALSE, pool);
> +  return filter_props(*props, bln, FALSE, pool);
>  }
>
>
> @@ -2351,7 +2359,7 @@ static svn_error_t * reporter_finish_rep
>  {
>   report_baton_t *rb = report_baton;
>   svn_error_t *err;
> -  const char *vcc;
> +  const char *report_target;
>   apr_hash_t *request_headers = apr_hash_make(pool);
>   apr_hash_set(request_headers, "Accept-Encoding", APR_HASH_KEY_STRING,
>                "svndiff1;q=0.9,svndiff;q=0.8");
> @@ -2372,10 +2380,15 @@ static svn_error_t * reporter_finish_rep
>   rb->encoding = MAKE_BUFFER(rb->pool);
>   rb->href = MAKE_BUFFER(rb->pool);
>
> -  /* get the VCC.  if this doesn't work out for us, don't forget to
> -     remove the tmpfile before returning the error. */
> -  if ((err = svn_ra_neon__get_vcc(&vcc, rb->ras,
> -                                  rb->ras->url->data, pool)))
> +  /* Got HTTP v2 support?  We'll report against the "me resource". */
> +  if (SVN_RA_NEON__HAVE_HTTPV2_SUPPORT(rb->ras))
> +    {
> +      report_target = rb->ras->me_resource;
> +    }
> +  /* Else, get the VCC.  (If this doesn't work out for us, don't
> +     forget to remove the tmpfile before returning the error.)  */
> +  else if ((err = svn_ra_neon__get_vcc(&report_target, rb->ras,
> +                                       rb->ras->url->data, pool)))
>     {
>       /* We're done with the file.  this should delete it. Note: it
>          isn't a big deal if this line is never executed -- the pool
> @@ -2385,7 +2398,7 @@ static svn_error_t * reporter_finish_rep
>     }
>
>   /* dispatch the REPORT. */
> -  err = svn_ra_neon__parsed_request(rb->ras, "REPORT", vcc,
> +  err = svn_ra_neon__parsed_request(rb->ras, "REPORT", report_target,
>                                     NULL, rb->tmpfile, NULL,
>                                     start_element,
>                                     cdata_handler,
>
> Modified: branches/http-protocol-v2/subversion/libsvn_ra_neon/get_dated_rev.c
> URL: http://svn.collab.net/viewvc/svn/branches/http-protocol-v2/subversion/libsvn_ra_neon/get_dated_rev.c?pathrev=35632&r1=35631&r2=35632
> ==============================================================================
> --- branches/http-protocol-v2/subversion/libsvn_ra_neon/get_dated_rev.c Mon Feb  2 07:56:44 2009        (r35631)
> +++ branches/http-protocol-v2/subversion/libsvn_ra_neon/get_dated_rev.c Mon Feb  2 08:06:34 2009        (r35632)
> @@ -116,7 +116,7 @@ svn_error_t *svn_ra_neon__get_dated_revi
>  {
>   svn_ra_neon__session_t *ras = session->priv;
>   const char *body;
> -  const char *vcc_url;
> +  const char *report_target;
>   svn_error_t *err;
>   drev_baton_t *b = apr_palloc(pool, sizeof(*b));
>
> @@ -124,9 +124,16 @@ svn_error_t *svn_ra_neon__get_dated_revi
>   b->cdata = NULL;
>   b->revision = SVN_INVALID_REVNUM;
>
> -  /* Run the 'dated-rev-report' on the VCC url, which is always
> -     guaranteed to exist.   */
> -  SVN_ERR(svn_ra_neon__get_vcc(&vcc_url, ras, ras->root.path, pool));
> +  /* Got HTTP v2 support?  We'll report against the "me resource".
> +     Otherwise, we'll use the VCC.  */
> +  if (SVN_RA_NEON__HAVE_HTTPV2_SUPPORT(ras))
> +    {
> +      report_target = ras->me_resource;
> +    }
> +  else
> +    {
> +      SVN_ERR(svn_ra_neon__get_vcc(&report_target, ras, ras->root.path, pool));
> +    }
>
>   body = apr_psprintf(pool,
>                       "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
> @@ -137,7 +144,7 @@ svn_error_t *svn_ra_neon__get_dated_revi
>                       svn_time_to_cstring(timestamp, pool));
>
>   err = svn_ra_neon__parsed_request(ras, "REPORT",
> -                                    vcc_url, body, NULL, NULL,
> +                                    report_target, body, NULL, NULL,
>                                     drev_start_element,
>                                     svn_ra_neon__xml_collect_cdata,
>                                     drev_end_element,
>
> Modified: branches/http-protocol-v2/subversion/libsvn_ra_neon/options.c
> URL: http://svn.collab.net/viewvc/svn/branches/http-protocol-v2/subversion/libsvn_ra_neon/options.c?pathrev=35632&r1=35631&r2=35632
> ==============================================================================
> --- branches/http-protocol-v2/subversion/libsvn_ra_neon/options.c       Mon Feb  2 07:56:44 2009        (r35631)
> +++ branches/http-protocol-v2/subversion/libsvn_ra_neon/options.c       Mon Feb  2 08:06:34 2009        (r35632)
> @@ -118,8 +118,9 @@ static const char *capability_no = "no";
>  static const char *capability_server_yes = "server-yes";
>
>
> -/* Store in RAS the capabilities discovered from REQ's headers.
> -   Use POOL for temporary allocation only. */
> +/* Store in RAS the capabilities and other interesting tidbits of
> +   information discovered from REQ's headers.  Use POOL for temporary
> +   allocation only. */
>  static void
>  parse_capabilities(ne_request *req,
>                    svn_ra_neon__session_t *ras,
> @@ -186,6 +187,41 @@ parse_capabilities(ne_request *req,
>         apr_hash_set(ras->capabilities, SVN_RA_CAPABILITY_PARTIAL_REPLAY,
>                      APR_HASH_KEY_STRING, capability_yes);
>     }
> +
> +  /* Not strictly capabilities, but while we're here, we might as well... */
> +#if 0
> +  if ((header_value = ne_get_response_header(req, SVN_DAV_YOUNGEST_REV_HEADER)))
> +    {
> +    }
> +#endif
> +  if ((header_value = ne_get_response_header(req, SVN_DAV_REPOS_UUID_HEADER)))
> +    {
> +      ras->uuid = apr_pstrdup(ras->pool, header_value);
> +    }
> +  if ((header_value = ne_get_response_header(req, SVN_DAV_ROOT_URI_HEADER)))
> +    {
> +      ne_uri root = ras->root;
> +      char *root_uri;
> +
> +      root.path = (char *)header_value;
> +      root_uri = ne_uri_unparse(&root);
> +      ras->repos_root = apr_pstrdup(ras->pool, root_uri);
> +      free(root_uri);
> +    }
> +
> +  /* HTTP v2 stuff */
> +  if ((header_value = ne_get_response_header(req, SVN_DAV_ME_RESOURCE_HEADER)))
> +    {
> +      ras->me_resource = apr_pstrdup(ras->pool, header_value);
> +    }
> +  if ((header_value = ne_get_response_header(req, SVN_DAV_PEGREV_STUB_HEADER)))
> +    {
> +      ras->pegrev_stub = apr_pstrdup(ras->pool, header_value);
> +    }
> +  if ((header_value = ne_get_response_header(req, SVN_DAV_REV_STUB_HEADER)))
> +    {
> +      ras->rev_stub = apr_pstrdup(ras->pool, header_value);
> +    }
>  }
>
>
>
> Modified: branches/http-protocol-v2/subversion/libsvn_ra_neon/ra_neon.h
> URL: http://svn.collab.net/viewvc/svn/branches/http-protocol-v2/subversion/libsvn_ra_neon/ra_neon.h?pathrev=35632&r1=35631&r2=35632
> ==============================================================================
> --- branches/http-protocol-v2/subversion/libsvn_ra_neon/ra_neon.h       Mon Feb  2 07:56:44 2009        (r35631)
> +++ branches/http-protocol-v2/subversion/libsvn_ra_neon/ra_neon.h       Mon Feb  2 08:06:34 2009        (r35632)
> @@ -116,8 +116,31 @@ typedef struct {
>      well-informed internal code may just compare against those
>      constants' addresses, therefore). */
>   apr_hash_t *capabilities;
> +
> +  /*** HTTP v2 protocol stuff. ***
> +   *
> +   * We assume that if mod_dav_svn sends one of the special v2 OPTIONs
> +   * response headers, it has sent all of them.  Specifically, we'll
> +   * be looking at the presence of the "me resource" as a flag that
> +   * the server supports v2 of our HTTP protocol.
> +   */
> +
> +  /* The "me resource".  Typically used as a target for REPORTs that
> +     are path-agnostic.  If we have this, we can speak HTTP v2 to the
> +     server.  */
> +  const char *me_resource;
> +
> +  /* Opaque URL "stubs".  If the OPTIONS response returns these, then
> +     we know we're using HTTP protocol v2. */
> +  const char *pegrev_stub;      /* for accessing REV/PATH pairs */
> +  const char *rev_stub;         /* for accessing revisions (i.e. revprops) */
> +
> +  /*** End HTTP v2 stuff ***/
> +
>  } svn_ra_neon__session_t;
>
> +#define SVN_RA_NEON__HAVE_HTTPV2_SUPPORT(ras) ((ras)->me_resource != NULL)
> +
>
>  typedef struct {
>   ne_request *ne_req;                   /* neon request structure */
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1091235
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1097705