You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2012/05/10 07:16:50 UTC

svn commit: r1336484 - in /subversion/trunk/subversion/libsvn_ra_serf: property.c ra_serf.h serf.c

Author: gstein
Date: Thu May 10 05:16:49 2012
New Revision: 1336484

URL: http://svn.apache.org/viewvc?rev=1336484&view=rev
Log:
Create a helper function to get the youngest revnum, using OPTIONS for
HTTPv2 or a PROPFIND dance for HTTPv1. The latter is factored out of
svn_ra_serf__get_baseline_info() which ends up with no public callers
and has been made private.

* subversion/libsvn_ra_serf/ra_serf.h:
  (svn_ra_serf__get_youngest_revnum): new declaration. almost
    equivalent to the vtable support function
    svn_ra_serf__get_latest_revnum in serf.c (just a param type)
  (svn_ra_serf__get_baseline_info): removed. no longer used.
  (svn_ra_serf__get_stable_url): note that URL may be NULL

* subversion/libsvn_ra_serf/property.c:
  (v1_get_youngest_revnum): new function. factored out of
    get_baseline_info(). for HTTPv1 servers this is a PROPFIND dance,
    or (hopefully) pulled from the baseline cache.
  (svn_ra_serf__get_youngest_revnum): use the above function for v1 or
    an OPTIONS request for v2.
  (svn_ra_serf__get_baseline_info): made private and renamed to ...
  (get_baseline_info): ... this. tighten scope of VCC_URL. move a
    bunch of functionality out to v1_get_youngest_revnum().
  (svn_ra_serf__get_stable_url): track function rename

* subversion/libsvn_ra_serf/serf.c:
  (svn_ra_serf__get_latest_revnum): use the new
    svn_ra_serf__get_youngest_revnum() helper function.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/property.c
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
    subversion/trunk/subversion/libsvn_ra_serf/serf.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/property.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/property.c?rev=1336484&r1=1336483&r2=1336484&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/property.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/property.c Thu May 10 05:16:49 2012
@@ -946,17 +946,114 @@ retrieve_baseline_info(svn_revnum_t *act
   return SVN_NO_ERROR;
 }
 
+
+/* For HTTPv1 servers, do a PROPFIND dance on the VCC to fetch the youngest
+   revnum. If BASECOLL_URL is non-NULL, then the corresponding baseline
+   collection URL is also returned.
+
+   Do the work over CONN.
+
+   *BASECOLL_URL (if requested) will be allocated in RESULT_POOL. All
+   temporary allocations will be made in SCRATCH_POOL.  */
+static svn_error_t *
+v1_get_youngest_revnum(svn_revnum_t *youngest,
+                       const char **basecoll_url,
+                       svn_ra_serf__connection_t *conn,
+                       const char *vcc_url,
+                       apr_pool_t *result_pool,
+                       apr_pool_t *scratch_pool)
+{
+  const char *baseline_url;
+  const char *bc_url;
+
+  /* Fetching DAV:checked-in from the VCC (with no Label: to specify a
+     revision) will return the latest Baseline resource's URL.  */
+  SVN_ERR(svn_ra_serf__fetch_dav_prop(&baseline_url, conn, vcc_url,
+                                      SVN_INVALID_REVNUM,
+                                      "checked-in",
+                                      scratch_pool, scratch_pool));
+  if (!baseline_url)
+    {
+      return svn_error_create(SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
+                              _("The OPTIONS response did not include "
+                                "the requested checked-in value"));
+    }
+  baseline_url = svn_urlpath__canonicalize(baseline_url, scratch_pool);
+
+  /* From the Baseline resource, we can fetch the DAV:baseline-collection
+     and DAV:version-name properties. The latter is the revision number,
+     which is formally the name used in Label: headers.  */
+
+  /* First check baseline information cache. */
+  SVN_ERR(svn_ra_serf__blncache_get_baseline_info(&bc_url,
+                                                  youngest,
+                                                  conn->session->blncache,
+                                                  baseline_url,
+                                                  scratch_pool));
+  if (!bc_url)
+    {
+      SVN_ERR(retrieve_baseline_info(youngest, &bc_url,
+                                     conn->session, conn,
+                                     baseline_url, SVN_INVALID_REVNUM,
+                                     scratch_pool));
+      SVN_ERR(svn_ra_serf__blncache_set(conn->session->blncache,
+                                        baseline_url, *youngest,
+                                        bc_url, scratch_pool));
+    }
+
+  if (basecoll_url != NULL)
+    *basecoll_url = apr_pstrdup(result_pool, bc_url);
+
+  return SVN_NO_ERROR;
+}
+
+
 svn_error_t *
-svn_ra_serf__get_baseline_info(const char **bc_url,
-                               const char **bc_relative,
-                               svn_ra_serf__session_t *session,
-                               svn_ra_serf__connection_t *conn,
-                               const char *url,
-                               svn_revnum_t revision,
-                               svn_revnum_t *latest_revnum,
-                               apr_pool_t *pool)
+svn_ra_serf__get_youngest_revnum(svn_revnum_t *youngest,
+                                 svn_ra_serf__session_t *session,
+                                 apr_pool_t *scratch_pool)
 {
-  const char *vcc_url, *relative_url, *basecoll_url, *baseline_url;
+  const char *vcc_url;
+
+  if (SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(session))
+    return svn_error_trace(svn_ra_serf__v2_get_youngest_revnum(
+                             youngest, session->conns[0], scratch_pool));
+
+  SVN_ERR(svn_ra_serf__discover_vcc(&vcc_url, session, NULL, scratch_pool));
+
+  return svn_error_trace(v1_get_youngest_revnum(youngest, NULL,
+                                                session->conns[0], vcc_url,
+                                                scratch_pool, scratch_pool));
+}
+
+
+/* Set *BC_URL to the baseline collection url, and set *BC_RELATIVE to
+   the path relative to that url for URL in REVISION using SESSION.
+   BC_RELATIVE will be URI decoded.
+
+   REVISION may be SVN_INVALID_REVNUM (to mean "the current HEAD
+   revision").  If URL is NULL, use SESSION's session url.
+
+   If LATEST_REVNUM is not NULL, set it to the baseline revision. If
+   REVISION was set to SVN_INVALID_REVNUM, this will return the current
+   HEAD revision.
+
+   If non-NULL, use CONN for communications with the server;
+   otherwise, use the default connection.
+
+   All temporary allocations are performed in SCRATCH_POOL.  */
+static svn_error_t *
+get_baseline_info(const char **bc_url,
+                  const char **bc_relative,
+                  svn_ra_serf__session_t *session,
+                  svn_ra_serf__connection_t *conn,
+                  const char *url,
+                  svn_revnum_t revision,
+                  svn_revnum_t *latest_revnum,
+                  apr_pool_t *pool)
+{
+  const char *basecoll_url;
+  const char *relative_url;
 
   /* No URL?  No sweat.  We'll use the session URL. */
   if (! url)
@@ -997,6 +1094,8 @@ svn_ra_serf__get_baseline_info(const cha
   /* Otherwise, we fall back to the old VCC_URL PROPFIND hunt.  */
   else
     {
+      const char *vcc_url;
+
       SVN_ERR(svn_ra_serf__discover_vcc(&vcc_url, session, conn, pool));
 
       if (SVN_IS_VALID_REVNUM(revision))
@@ -1023,35 +1122,9 @@ svn_ra_serf__get_baseline_info(const cha
         {
           svn_revnum_t actual_revision;
 
-          SVN_ERR(svn_ra_serf__fetch_dav_prop(&baseline_url, conn, vcc_url,
-                                              SVN_INVALID_REVNUM,
-                                              "checked-in",
-                                              pool, pool));
-          if (!baseline_url)
-            {
-              return svn_error_create(SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
-                                      _("The OPTIONS response did not include "
-                                        "the requested checked-in value"));
-            }
-
-          baseline_url = svn_urlpath__canonicalize(baseline_url, pool);
-
-          /* First check baseline information cache. */
-          SVN_ERR(svn_ra_serf__blncache_get_baseline_info(&basecoll_url,
-                                                          &actual_revision,
-                                                          session->blncache,
-                                                          baseline_url,
-                                                          pool));
-          if (!basecoll_url)
-            {
-              SVN_ERR(retrieve_baseline_info(&actual_revision, &basecoll_url,
-                                             session, conn,
-                                             baseline_url, SVN_INVALID_REVNUM,
-                                             pool));
-              SVN_ERR(svn_ra_serf__blncache_set(session->blncache,
-                                                baseline_url, actual_revision,
-                                                basecoll_url, pool));
-            }
+          SVN_ERR(v1_get_youngest_revnum(&actual_revision, &basecoll_url,
+                                         conn, vcc_url,
+                                         pool, pool));
 
           if (latest_revnum)
             {
@@ -1083,10 +1156,10 @@ svn_ra_serf__get_stable_url(const char *
   const char *basecoll_url;
   const char *relpath;
 
-  SVN_ERR(svn_ra_serf__get_baseline_info(&basecoll_url, &relpath,
-                                         session, conn,
-                                         url, revision, latest_revnum,
-                                         scratch_pool));
+  SVN_ERR(get_baseline_info(&basecoll_url, &relpath,
+                            session, conn,
+                            url, revision, latest_revnum,
+                            scratch_pool));
   *stable_url = svn_path_url_add_component2(basecoll_url, relpath,
                                             result_pool);
 

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=1336484&r1=1336483&r2=1336484&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Thu May 10 05:16:49 2012
@@ -1150,31 +1150,18 @@ svn_ra_serf__get_relative_path(const cha
                                svn_ra_serf__connection_t *conn,
                                apr_pool_t *pool);
 
-/* Set *BC_URL to the baseline collection url, and set *BC_RELATIVE to
- * the path relative to that url for URL in REVISION using SESSION.
- * BC_RELATIVE will be URI decoded.
- *
- * REVISION may be SVN_INVALID_REVNUM (to mean "the current HEAD
- * revision").  If URL is NULL, use SESSION's session url.
- *
- * If LATEST_REVNUM is not NULL, set it to the baseline revision. If
- * REVISION was set to SVN_INVALID_REVNUM, this will return the current
- * HEAD revision.
- *
- * If non-NULL, use CONN for communications with the server;
- * otherwise, use the default connection.
- *
- * Use POOL for all allocations.
- */
+
+/* Using the default connection in SESSION (conns[0]), get the youngest
+   revnum from the server, returning it in *YOUNGEST.
+
+   This function operates synchronously.
+
+   All temporary allocations are performed in SCRATCH_POOL.  */
 svn_error_t *
-svn_ra_serf__get_baseline_info(const char **bc_url,
-                               const char **bc_relative,
-                               svn_ra_serf__session_t *session,
-                               svn_ra_serf__connection_t *conn,
-                               const char *url,
-                               svn_revnum_t revision,
-                               svn_revnum_t *latest_revnum,
-                               apr_pool_t *pool);
+svn_ra_serf__get_youngest_revnum(svn_revnum_t *youngest,
+                                 svn_ra_serf__session_t *session,
+                                 apr_pool_t *scratch_pool);
+
 
 /* Generate a revision-stable URL.
 
@@ -1193,6 +1180,8 @@ svn_ra_serf__get_baseline_info(const cha
    SVN_INVALID_REVNUM, then the stable URL will refer to the youngest
    revision at the time this function was called.
 
+   If URL is NULL, then the session root will be used.
+
    The stable URL will be placed into *STABLE_URL, allocated from RESULT_POOL.
 
    If LATEST_REVNUM is not NULL, then the revision used will be placed into

Modified: subversion/trunk/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/serf.c?rev=1336484&r1=1336483&r2=1336484&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/serf.c Thu May 10 05:16:49 2012
@@ -498,18 +498,10 @@ svn_ra_serf__get_latest_revnum(svn_ra_se
                                svn_revnum_t *latest_revnum,
                                apr_pool_t *pool)
 {
-  const char *relative_url, *basecoll_url;
   svn_ra_serf__session_t *session = ra_session->priv;
 
-  /* ### HTTPv2: use OPTIONS to get youngest.  */
-
-  /* ### HTTPv1: extract the relevant bits from get_baseline_info() since
-     ### we don't care about anything beyond the revnum.  */
-  return svn_ra_serf__get_baseline_info(&basecoll_url, &relative_url,
-                                        session, NULL /* conn */,
-                                        NULL /* url */, SVN_INVALID_REVNUM,
-                                        latest_revnum,
-                                        pool);
+  return svn_error_trace(svn_ra_serf__get_youngest_revnum(
+                           latest_revnum, session, pool));
 }
 
 static svn_error_t *