[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Find out the version of the repository server

From: Ben Reser <ben_at_reser.org>
Date: 2005-04-27 19:51:22 CEST

On Wed, Apr 27, 2005 at 06:12:37PM +0200, SteveKing wrote:
> First a little background why I need to find out the version of the
> repository server. Maybe you guys know another way to do what I want
> without knowing the version?
>
> Subversion 1.2 introduces svn_client_log2() which takes a 'limit'
> parameter. That's great. But, if you call that function with a < 1.2
> server, the server returns *all* revisions and the client just drops the
> ones not asked for. That can be *very* slow for many revisions.
> So, I'd like to somehow check if the 'limit' option works as it does
> with 1.2 servers and if not, just use svn_client_log2() without the
> limit param. To limit the revisions fetched, I could then adjust the
> revision range accordingly.
>
> Sure, I could always adjust the revision range to avoid the problems
> with < 1.2 servers, but then I might not get any log messages back if in
> the range I specify no changes to that path/URL happened - that's why
> I'd like to use the 'limit' param if possible.

I'm pretty sure someone has pointed this out to you before but why don't
you just use svn_ra_get_latest_revnum?

Sure you have to do the bother to setup an RA session but it's not any
harder to setup an RA session than it is a client ctx since the client
lib is using what you give it to setup the RA session.

Probably could get away with leaving all of the function pointers in
svn_ra_callbacks_t set to NULL and only setting the auth_baton (which
you have to set for a client ctx too).

If you've already got a ctx, you could just do something like this:

svn_error_t *my_client_get_latest_revnum (svn_client_ctx_t *ctx,
                                          const char *repos_URL,
                                          svn_revnum_t *latest_revnum,
                                          apr_pool_t *pool)
{
  svn_ra_session_t *ra_session;
  svn_ra_callbacks_t *ra_callbacks = ap_pcalloc (pool, sizeof(*ra_callbacks));
  ra_callbacks->auth_baton = ctx->auth_baton;

  SVN_ERR (svn_ra_open (&ra_session, repos_URL, ra_callbacks, NULL,
           ctx->config, pool);

  return svn_ra_get_latest_revnum (ra_session, latest_revnum, pool);
}

 
(Note that's untested and largely off the top of my head but it ought to
work.)
 
Then you don't have to worry about versions of the server nor getting
any extra data across the network that you don't really need.

-- 
Ben Reser <ben@reser.org>
http://ben.reser.org
"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Apr 27 21:11:02 2005

This is an archived mail posted to the Subversion Dev mailing list.