_get_latest_revnum and _get_youngest_rev are effectively synonyms. A
reader is going to have no idea of the difference or which to use
without first consulting the documentation. Even now, I have to look
at your comments to suggest: rename _get_youngest_rev to something
like _get_cached_latest_revnum.
On Tue, Jan 13, 2009 at 22:09, Ben Collins-Sussman <sussman_at_red-bean.com> wrote:
> Author: sussman
> Date: Tue Jan 13 13:09:41 2009
> New Revision: 35220
>
> Log:
> Make serf's public get_youngest_rev() *not* use cached HEAD.
> Create an internal helper func to used cached HEAD instead.
>
> * subversion/libsvn_ra_serf/serf.c
> (svn_ra_serf__get_latest_revnum): don't use the cached HEAD.
>
> * subversion/libsvn_ra_serf/ra_serf.h
> (svn_ra_serf__get_youngest_rev): declare new helper func.
>
> * subversion/libsvn_ra_serf/property.c
> (svn_ra_serf__get_youngest_rev): new internal helper func. tries
> to use cached HEAD value first.
> (svn_ra_serf__get_baseline_info): cache HEAD when we discover it.
>
> Modified:
> branches/http-protocol-v2/subversion/libsvn_ra_serf/property.c
> branches/http-protocol-v2/subversion/libsvn_ra_serf/ra_serf.h
> branches/http-protocol-v2/subversion/libsvn_ra_serf/serf.c
>
> Modified: branches/http-protocol-v2/subversion/libsvn_ra_serf/property.c
> URL: http://svn.collab.net/viewvc/svn/branches/http-protocol-v2/subversion/libsvn_ra_serf/property.c?pathrev=35220&r1=35219&r2=35220
> ==============================================================================
> --- branches/http-protocol-v2/subversion/libsvn_ra_serf/property.c Tue Jan 13 12:45:22 2009 (r35219)
> +++ branches/http-protocol-v2/subversion/libsvn_ra_serf/property.c Tue Jan 13 13:09:41 2009 (r35220)
> @@ -922,6 +922,26 @@ svn_ra_serf__set_bare_props(void *baton,
> ns, ns_len, name, name_len, val, pool);
> }
>
> +svn_error_t *
> +svn_ra_serf__get_youngest_rev(svn_revnum_t *youngest_revnum,
> + svn_ra_serf__session_t *session,
> + apr_pool_t *pool)
> +{
> + const char *relative_url, *basecoll_url;
> +
> + if (SVN_IS_VALID_REVNUM(session->youngest_rev))
> + {
> + /* Return cached value */
> + *youngest_revnum = session->youngest_rev;
> + return SVN_NO_ERROR;
> + }
> +
> + /* else do a network request to get HEAD */
> + return svn_ra_serf__get_baseline_info(&basecoll_url, &relative_url,
> + session, session->repos_url.path,
> + SVN_INVALID_REVNUM, youngest_revnum,
> + pool);
> +}
>
> svn_error_t *
> svn_ra_serf__get_baseline_info(const char **bc_url,
> @@ -993,6 +1013,7 @@ svn_ra_serf__get_baseline_info(const cha
> }
>
> *latest_revnum = SVN_STR_TO_REV(version_name);
> + session->youngest_rev = *latest_revnum; /* cache this! */
> }
>
> *bc_url = basecoll_url;
>
> Modified: branches/http-protocol-v2/subversion/libsvn_ra_serf/ra_serf.h
> URL: http://svn.collab.net/viewvc/svn/branches/http-protocol-v2/subversion/libsvn_ra_serf/ra_serf.h?pathrev=35220&r1=35219&r2=35220
> ==============================================================================
> --- branches/http-protocol-v2/subversion/libsvn_ra_serf/ra_serf.h Tue Jan 13 12:45:22 2009 (r35219)
> +++ branches/http-protocol-v2/subversion/libsvn_ra_serf/ra_serf.h Tue Jan 13 13:09:41 2009 (r35220)
> @@ -1072,6 +1072,24 @@ svn_ra_serf__get_baseline_info(const cha
> svn_revnum_t *latest_revnum,
> apr_pool_t *pool);
>
> +/* Set YOUNGEST_REVNUM to the head revision of the repository opened
> + * by SESSION.
> + *
> + * NOTE: this function will first attempt to return a *cached* revnum
> + * within the session_t; if not available, it makes a network request
> + * to discover it. As such, this routine is best called by internal
> + * routines which need a value for HEAD which is "recent enough".
> + * Routines which absolutely need the latest value to be fetched by
> + * network request should call svn_ra_serf__get_baseline_info() instead.
> + *
> + * Use POOL for all allocations.
> + */
> +svn_error_t *
> +svn_ra_serf__get_youngest_rev(svn_revnum_t *youngest_revnum,
> + svn_ra_serf__session_t *session,
> + apr_pool_t *pool);
> +
> +
> /** RA functions **/
>
> svn_error_t *
>
> Modified: branches/http-protocol-v2/subversion/libsvn_ra_serf/serf.c
> URL: http://svn.collab.net/viewvc/svn/branches/http-protocol-v2/subversion/libsvn_ra_serf/serf.c?pathrev=35220&r1=35219&r2=35220
> ==============================================================================
> --- branches/http-protocol-v2/subversion/libsvn_ra_serf/serf.c Tue Jan 13 12:45:22 2009 (r35219)
> +++ branches/http-protocol-v2/subversion/libsvn_ra_serf/serf.c Tue Jan 13 13:09:41 2009 (r35220)
> @@ -522,14 +522,9 @@ svn_ra_serf__get_latest_revnum(svn_ra_se
> const char *relative_url, *basecoll_url;
> svn_ra_serf__session_t *session = ra_session->priv;
>
> - /* Using HTTP protocol v2; already got it in the initial OPTIONS response. */
> - if (SVN_IS_VALID_REVNUM(session->youngest_rev))
> - {
> - *latest_revnum = session->youngest_rev;
> - return SVN_NO_ERROR;
> - }
> -
> - /* Fall back to old-fashioned way of getting it. */
> + /* Because this is a public RA function, we deliberately do *not*
> + use the cached HEAD value in our session_t. The caller might
> + depend on the value to not be stale. */
> return svn_ra_serf__get_baseline_info(&basecoll_url, &relative_url,
> session, session->repos_url.path,
> SVN_INVALID_REVNUM, latest_revnum,
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1022842
>
Received on 2009-01-15 06:42:03 CET