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

revision/date handling in the client library

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2002-01-25 22:07:32 CET

Hello

Revision/date handling in the client library interface is less than
perfect. At present we get four values from the command line

  svn_revnum_t start_revision;
  svn_revnum_t end_revision;
  apr_time_t start_date;
  apr_time_t end_date;

Sometimes both a number and a date are passed to the client library to
define a revision (e.g. svn_client_diff), and sometimes only a number
(e.g. svn_client_log). Those that take both tend to return an error if
both are specified. In addition since all apr_time_t values are valid
times it is not possible to properly determine whether a date has been
specified. Adding a validity flag and passing three paramaters to
define one revision is silly. The application cannot do the
date-to-number conversion since that requires an ra session, which it
doesn't at present have.

Based on an earlier idea from Branko, how about

enum svn_client_revision_type {
  svn_client_revision_unspecified,
  svn_client_revision_number, /* -r NUMBER */
  svn_client_revision_date, /* -D DATE */
  svn_client_revision_commited, /* .svn/entries commited-rev */
  svn_client_revision_previous, /* .svn/entries commited-rev-1 Is this useful? */
  svn_client_revision_current, /* .svn/entries revision */
  svn_client_revision_head /* -r HEAD, RA youngest */
};

typedef struct svn_client_revision_s {

  enum svn_client_revision_type type;

  svn_revnum_t number;
  apr_time_t date;

} svn_client_revision_t;

#define SVN_CLIENT_REVISION_IS_UNSPECIFIED(r) \
        ((r).type == svn_client_revision_unspecified)

/* return revision number in *number using ra if required */
svn_error_t *
svn_cl__get_revision_number (svn_ra_plugin_t *ra_lib,
                             void *session,
                             svn_client_revision_t *revision,
                             const svn_stringbuf_t *path,
                             svn_revnum_t *number);

Now have the application parse the command line into two
svn_client_revision_t structures, perhaps complaining about attempts
to specify both a date and time for the same revision. Then always
pass svn_client_revision_t* into the client library routines to
define a revision. Handling in the client is along the lines

   if (SVN_CLIENT_REVISION_IS_UNSPECIFIED(*rev))
      complain if appropriate

   SVN_ERR (svn_cl__get_revision_number (ra_lib, session, path, rev, &num));
   use num and forget all about dates/HEAD/whatever

Look at the ugly revision handling in svn_client_diff to see how bad
it gets at present.

Comments?

-- 
Philip
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:00 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.