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

Subversion repository most-recent revision number

From: Xypanastheu <Gembler_at_gmail.com>
Date: Mon, 7 Jan 2008 22:12:14 -0800 (PST)

I am trying to write a small Windows console application
that uses the SVN client C++ API
to get the latest / most-recent revision number
from a Subversion repository out on the server.

My code is below. I have tried to go as far as I can with it.
I'd appreciate any feedback or help that you can give me.

I'm not sure what to do for the revision value.

What are batons (e.g. svn_client_info()'s receiver_baton), and how
are they used ?

What libs do I need to use ? :
  for apr_pool_create() and apr_pool_destroy()
  use svn-win32-1.4.6/lib/apr/libapr.lib

  for svn_client_info()
  use ???

Is there any existing example/test code that does what I am trying to
do ?

Thanks,
Chip Chianicti

/
*******************************************************************************
* PROJECT SVN Revision
* DESCRIPT Get Subversion repository latest / most-recent revision
number.
*******************************************************************************/

#include <stdio.h>

#include "apr_general.h" //btw does #include "apr_pools.h"
//#include "svn_types.h" //svn_error_t
//#include "svn_opt.h" //svn_opt_revision_t
#include "svn_client.h" //svn_info_receiver_t -(), btw does
#include svn_types.h
//#include "svn_config.h" //svn_boolean_t ?

/*=== PROTOTYPES
==========================================================*/
svn_error_t *
Callback_svn_client_info
(void *baton, const char *path, const svn_info_t *info, apr_pool_t
*pool);

void
Callback_svn_wc_notify_func
(void *baton, const char *path, svn_wc_notify_action_t action,
svn_node_kind_t kind, const char *mime_type, svn_wc_notify_state_t
content_state, svn_wc_notify_state_t prop_state, svn_revnum_t
revision);

svn_error_t *
Callback_svn_client_get_commit_log
(const char **log_msg, const char **tmp_file, apr_array_header_t
*commit_items, void *baton, apr_pool_t *pool);

svn_error_t *
Callback_svn_cancel_func_t
(void *cancel_baton);

void
Callback_svn_wc_notify_func2
(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool);

svn_error_t *
Callback_svn_client_get_commit_log2_t
(const char **log_msg, const char **tmp_file, const apr_array_header_t
*commit_items, void *baton, apr_pool_t *pool);

void
Callback_svn_ra_progress_notify_func_t
(apr_off_t progress, apr_off_t total, void *baton, apr_pool_t *pool);

/
*******************************************************************************
* FUNCTION main()
* DESCRIPT
*******************************************************************************/
int main ()
{
  printf ("\nHello hello.\n");

  /*=== BEGIN SVN CODE
======================================================*/
  apr_pool_t * pool;

  /*=== CREATE POOL
=========================================================*/
  apr_pool_create(&pool, NULL);

  /*=== USE POOL
============================================================*/
  svn_error_t *SvnError;
  svn_opt_revision_t PegRevision;
  svn_opt_revision_t Revision;
         //svn_info_receiver_t //Callback
  svn_boolean_t Recurse;
  svn_client_ctx_t ClientCtx;

  PegRevision.kind = svn_opt_revision_unspecified;
  //PegRevision.value = ???
  Revision.kind = svn_opt_revision_unspecified;
  //Revision.value = ???

  Recurse = 0;

  //ClientCtx.auth_baton = ???
  ClientCtx.notify_func = Callback_svn_wc_notify_func;
  //ClientCtx.notify_baton = ???
  ClientCtx.log_msg_func = Callback_svn_client_get_commit_log;
  //ClientCtx.log_msg_baton = ???
  //ClientCtx.config = ???
  ClientCtx.cancel_func = Callback_svn_cancel_func_t;
  //ClientCtx.cancel_baton = ???
  ClientCtx.notify_func2 = Callback_svn_wc_notify_func2;
  //ClientCtx.notify_baton2 = ???
  ClientCtx.log_msg_func2 = Callback_svn_client_get_commit_log2_t;
  //ClientCtx.log_msg_baton2 = ???
  ClientCtx.progress_func =
Callback_svn_ra_progress_notify_func_t;
  //ClientCtx.progress_baton = ???

  #if (0)
  SvnError = svn_client_info
    (
      "http://subversion/svn/software/VRS", //path or url
      &PegRevision,
      &Revision,
      Callback_svn_client_info, //callback
      NULL, //receiver_baton,
      Recurse,
      &ClientCtx,
      pool
    );
  #endif

  /*=== DESTROY POOL
========================================================*/
  apr_pool_destroy(pool);

  /*=== END SVN CODE
========================================================*/

  printf ("\nPrgm done.\n");

  return (0);
}

/
*******************************************************************************
* FUNCTION Callback_svn_client_info ()
* DESCRIPT
*******************************************************************************/
svn_error_t *
Callback_svn_client_info
(void *baton, const char *path, const svn_info_t *info, apr_pool_t
*pool)
{
  svn_error_t SvnError;
  svn_error_t *pSvnError;
  pSvnError = &SvnError;
  return (pSvnError);
  //svn_error_t SvnError;
  //return (&SvnError);
}

/
*******************************************************************************
* FUNCTION Callback_svn_wc_notify_func
* DESCRIPT
*******************************************************************************/
void
Callback_svn_wc_notify_func
( void *baton,
  const char *path,
  svn_wc_notify_action_t action,
  svn_node_kind_t kind,
  const char *mime_type,
  svn_wc_notify_state_t content_state,
  svn_wc_notify_state_t prop_state,
  svn_revnum_t revision
)
{
}

/
*******************************************************************************
* FUNCTION Callback_svn_client_get_commit_log()
* DESCRIPT
*******************************************************************************/
svn_error_t *
Callback_svn_client_get_commit_log
( const char **log_msg,
  const char **tmp_file,
  apr_array_header_t *commit_items,
  void *baton,
  apr_pool_t *pool
)
{
  svn_error_t SvnError;
  svn_error_t *pSvnError;
  pSvnError = &SvnError;
  return (pSvnError);
}

/
*******************************************************************************
* FUNCTION Callback_svn_cancel_func_t()
* DESCRIPT
*******************************************************************************/
svn_error_t *
Callback_svn_cancel_func_t (void *cancel_baton)
{
  svn_error_t SvnError;
  svn_error_t *pSvnError;
  pSvnError = &SvnError;
  return (pSvnError);
}

/
*******************************************************************************
* FUNCTION Callback_svn_wc_notify_func2()
* DESCRIPT
*******************************************************************************/
void
Callback_svn_wc_notify_func2
(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool)
{
}

/
*******************************************************************************
* FUNCTION Callback_svn_client_get_commit_log2_t()
* DESCRIPT
*******************************************************************************/
svn_error_t *
Callback_svn_client_get_commit_log2_t
( const char **log_msg,
  const char **tmp_file,
  const apr_array_header_t *commit_items,
  void *baton,
  apr_pool_t *pool
)
{
  svn_error_t SvnError;
  svn_error_t *pSvnError;
  pSvnError = &SvnError;
  return (pSvnError);
}

/
*******************************************************************************
* FUNCTION Callback_svn_ra_progress_notify_func_t()
* DESCRIPT
*******************************************************************************/
void
Callback_svn_ra_progress_notify_func_t
(apr_off_t progress, apr_off_t total, void *baton, apr_pool_t *pool)
{
}

// DDDDD OOO CCC U U M M EEEE N N TTTTT A
TTTTT III OOO N N
// D D O O C C U U MM MM E NN N T A A
T I O O NN N
// D D O O C U U M M M M EEE NN N T A A
T I O O NN N
// D D O O C U U M M M E N N N T AAAAA
T I O O N N N
// D D O O C C U U M M M E N NN T A A
T I O O N NN
// DDDDD OOO CCC UUU M M EEEEE N NN T A A
T III OOO N NN

#if (0)

/
*******************************************************************************
* PATH svn-win32-1.4.6\include
* FILE svn_types.h
*******************************************************************************/
typedef struct svn_error_t
{

  apr_status_t apr_err; /** APR error value, possibly SVN_
custom err */
  const char *message; /** details from producer of error */
  struct svn_error_t *child; /** ptr to the error we "wrap" */
  apr_pool_t *pool; /** The pool holding this error and any
child errors it wraps */
  const char *file; /** Source file where the error
originated. Only used iff @c SVN_DEBUG. */
  long line; /** Source line where the error
originated. Only used iff @c SVN_DEBUG. */

} svn_error_t;

/
*******************************************************************************
* PATH svn-win32-1.4.6\include
* FILE svn_opt.h
*******************************************************************************/
enum svn_opt_revision_kind
{
  svn_opt_revision_unspecified, /** No revision information given.
*/
  svn_opt_revision_number, /** revision given as number */
  svn_opt_revision_date, /** revision given as date */
  svn_opt_revision_committed, /** rev of most recent change */
  svn_opt_revision_previous, /** (rev of most recent change) - 1
*/
  svn_opt_revision_base, /** .svn/entries current revision
*/
  svn_opt_revision_working, /** current, plus local mods */
  svn_opt_revision_head /** repository youngest */
};

typedef union svn_opt_revision_value_t
{
  svn_revnum_t number;
  apr_time_t date;
} svn_opt_revision_value_t;

typedef struct svn_opt_revision_t
{
  enum svn_opt_revision_kind kind; /**< See
svn_opt_revision_kind */
  svn_opt_revision_value_t value; /**< Extra data qualifying
the @c kind */

} svn_opt_revision_t;

/
*******************************************************************************
* PATH svn-win32-1.4.6\include
* FILE svn_client.h
*******************************************************************************/
/**
 * The callback invoked by svn_client_info(). Each invocation
 * describes @a path with the information present in @a info. Note
 * that any fields within @a info may be NULL if information is
 * unavailable. Use @a pool for all temporary allocation.
 *
 * @since New in 1.2.
 */
typedef svn_error_t *(*svn_info_receiver_t)
  (void *baton,
   const char *path,
   const svn_info_t *info,
   apr_pool_t *pool);

/
*******************************************************************************
* PATH svn-win32-1.4.6\include
* FILE svn_types.h
*******************************************************************************/
/** YABT: Yet Another Boolean Type */
typedef int svn_boolean_t;

/
*******************************************************************************
* PATH svn-win32-1.4.6\include
* FILE svn_client.h
*******************************************************************************/
typedef struct svn_client_ctx_t
{
  svn_auth_baton_t * auth_baton; /** main
authentication baton. */
  svn_wc_notify_func_t notify_func; /** notification
callback function. */
  void * notify_baton; /** notification
callback baton for notify_func() */
  svn_client_get_commit_log_t log_msg_func; /** Log message
callback function. NULL means that Subversion */
  void * log_msg_baton; /** log message
callback baton */
  apr_hash_t * config; /** a hash mapping
of <tt>const char *</tt> configuration file names to @c svn_config_t
*'s. */
  svn_cancel_func_t cancel_func; /** a callback to
be used to see if the client wishes to cancel the running operation.
*/
  void * cancel_baton; /** a baton to
pass to the cancellation callback. */
  svn_wc_notify_func2_t notify_func2; /** notification
function, defaulting to a function that forwards to notify_func(). */
  void * notify_baton2; /** notification
baton for notify_func2(). */
  svn_client_get_commit_log2_t log_msg_func2; /** Log message
callback function. NULL means that Subversion should try log_msg_func.
*/
  void * log_msg_baton2; /** callback baton
for log_msg_func2 */
  svn_ra_progress_notify_func_t progress_func; /** Notification
callback for network progress information. */
  void * progress_baton; /** Callback baton
for progress_func. */

} svn_client_ctx_t;

#endif

/
*******************************************************************************
* PROJECT END
*******************************************************************************/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-01-08 17:21:59 CET

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.