On Wed, 2 Mar 2005 kfogel@collab.net wrote:
> "Peter N. Lundblad" <peter@famlundblad.se> writes:
> > > > Also, svn_client_ctx_t is extensible by design. It is possible
> > > > to add the new notify function/baton as new
> > > > fields. svn_client_create_context could init them to a
> > > > function/baton that forwards to the old function. The other
> > > > alternative is to revise svn_client_ctx_t, leading to revision
> > > > of all client functions. Which do you prefer as the least ugly
> > > > way? Or do I miss an obvious other alternative?
> >
> > I still want an opinion about the above paragraph.
>
> So the idea is to put
>
> svn_wc_notify_func_t2 notify_func2;
> void *notify_baton2;
>
> at the end of svn_client_ctx_t? But I'm unclear on exactly how
> svn_client_create_context is supposed forward after that. That
> function doesn't have a handle on the actual notify_func and baton the
> caller is going to put in the ctx, so how can it set up the call
> forwarding? All svn_client_create_context does is allocate the
> structure; it doesn't currently initialize any fields.
>
What you asked for, Sir. A patch is below with this, obviously incomplete,
just for illustration.
the idea is that svn_client_create_context set the new func/baton to
something that will forward to the old deprecated stuff. If the user sets
the old func/baton, she will get notification as before. If she set the
new function, the old stuff will not be called, but that shouldn't be a
problem.
Thanks,
//Peter
Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (revision 13218)
+++ subversion/include/svn_wc.h (arbetskopia)
@@ -564,6 +564,26 @@
} svn_wc_notify_state_t;
+/** @since New in 1.2. */
+typedef struct svn_wc_notify_t {
+ 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_wc_notify_t;
+
+/** @since New in 1.2. */
+svn_wc_notify_t *
+svn_wc_create_notify (apr_pool_t *pool);
+
+/** @since New in 1.2. */
+typedef void (*svn_wc_notify_func2_t) (void *baton,
+ const char *path,
+ const svn_wc_notify_t *notify,
+ apr_pool_t *pool);
+
/** Notify the world that @a action has happened to @a path. @a path is
* either absolute or relative to cwd (i.e., not relative to an anchor).
*
Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h (revision 13218)
+++ subversion/include/svn_client.h (arbetskopia)
@@ -360,10 +360,12 @@
/** main authentication baton. */
svn_auth_baton_t *auth_baton;
- /** notification callback function */
+ /** @deprecated Provided for backwards compatibility with the 1.1 API.
+ notification callback function.
+ This will be called by @c notify_func2 by default. */
svn_wc_notify_func_t notify_func;
- /** notification callback baton */
+ /** notification callback baton for the above */
void *notify_baton;
/** log message callback function */
@@ -386,6 +388,11 @@
/** a baton to pass to the cancellation callback. */
void *cancel_baton;
+ /** notification function, defaulting to a function that fowrads
+ to @c notify_func. */
+ svn_wc_notify_func2_t notify_func2;
+ /** notification baton for the above. */
+ void *notify_baton2;
} svn_client_ctx_t;
Index: subversion/libsvn_client/ctx.c
===================================================================
--- subversion/libsvn_client/ctx.c (revision 13218)
+++ subversion/libsvn_client/ctx.c (arbetskopia)
@@ -29,10 +29,25 @@
/*** Code. ***/
+/* Call the notify_func of the context provided by BATON, if non-NULL. */
+static void
+call_notify_func (void *baton, const char *path, const svn_wc_notify_t *n,
+ apr_pool_t *pool)
+{
+ const svn_client_ctx_t *ctx = baton;
+
+ if (ctx->notify_func)
+ ctx->notify_func (ctx->notify_baton, path, n->action, n->kind,
+ n->mime_type, n->content_state, n->prop_state,
+ n->revision);
+}
+
svn_error_t *
svn_client_create_context (svn_client_ctx_t **ctx,
apr_pool_t *pool)
{
*ctx = apr_pcalloc (pool, sizeof (svn_client_ctx_t));
+ (*ctx)->notify_func2 = call_notify_func;
+ (*ctx)->notify_baton2 = *ctx;
return SVN_NO_ERROR;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Mar 2 18:02:00 2005