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

[PATCH] notification callbacks for network data transfers (V3)

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: 2005-08-27 13:54:25 CEST

Branko ÄŒibej wrote:
> Stefan Küng wrote:
>
>> New patch which uses Branko's comments to fix what was broken.
>
>
> Sorry this took so long... The patch looks good, I've a few minor comments

No problem. You said that it would take you some time, so I was prepared
to wait ;)

> I think we could commit this with some minor changes, even if we only
> get progress info fo ra_dav for now. Could you update the patch to
> trunk? Thaks.

Ok, done.
I'm planning on implementing this for ra_svn too, and maybe even for
file:/// access. But it will take a little more time.
Also, I wasn't sure if such a patch would be accepted, so I only wrote
one for ra_dav to start with - if this get's in, then I can start
working on the other protocols.

[snip]
>> * subversion/libsvn_client/copy.c
>> (repos_to_repos_copy): correct comment
>> ]]]
>>
>>
> Just a comment for the future: please use whole sentences in the log
> message; for example,
>
> * subversion/libsvn_client/copy.c
> (repos_to_repos_copy): Correct comment.

Ok. Done.

> You also put lots of tabs in the code where there weren't any before.

I think I got it right this time. Changed my editor to show spaces and
tabs differently so I can see where I messed up.

> The progress_baton field needs a docstring, too. Same in
> svn_ra_callbacks2_t.

Done.

>> +static void
>> +svn_ra_dav__neonprogress(void * baton, off_t progress, off_t total)
>> +{
>> + const svn_ra_callbacks_t * callbacks = (svn_ra_callbacks_t *)baton;
>> + if (callbacks->progress_func)
>> + {
>> + callbacks->progress_func(progress, total,
>> callbacks->progress_baton);
>> + }
>> +}
>>
>>
> This function's name shouldn't actually have a svn_ra_dav__ prefix --
> it's a static function, not library-private.

Changed it to ra_dav_neonprogress().

Patch attached.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.tigris.org

[[[
Implement a reduced version of issue #901 for DAV connections.

* subversion/include/svn_progress.h
  (new file): typedefs for the notification callback function.
* subversion/include/svn_client.h
  (svn_client_ctx_t): extend the client context structure with the
  callback function and baton.
* subversion/include/svn_ra.h
  (svn_ra_callbacks_t): deprecate the structure
  (svn_ra_callbacks2_t): same as svn_ra_callbacks_t, but with new
  progress notification callback and baton.
* subversion/libsvn_ra/ra_loader.c
  (svn_ra_open): deprecate function, calls svn_ra_open2()
  (svn_ra_open2): new function which takes an svn_ra_callbacks2_t
  instead of an svn_ra_callback_t.
* subversion/libsvn_client/ra.c
  (svn_client__open_ra_session_internal): set the progress notification
  callback and baton.
* subversion/libsvn_ra_dav/session.c
  (ra_dav_neonprogress): new function. The callback function neon calls
  during network data transfers.
  (svn_ra_dav__open): set the neon callback function for the session.
* subversion/libsvn_client/copy.c
  (repos_to_repos_copy): correct comment.
]]]
Index: subversion/libsvn_ra/ra_loader.c
===================================================================
--- subversion/libsvn_ra/ra_loader.c (Revision 15937)
+++ subversion/libsvn_ra/ra_loader.c (Arbeitskopie)
@@ -230,12 +230,12 @@
   return SVN_NO_ERROR;
 }
 
-svn_error_t *svn_ra_open (svn_ra_session_t **session_p,
- const char *repos_URL,
- const svn_ra_callbacks_t *callbacks,
- void *callback_baton,
- apr_hash_t *config,
- apr_pool_t *pool)
+svn_error_t *svn_ra_open2 (svn_ra_session_t **session_p,
+ const char *repos_URL,
+ const svn_ra_callbacks2_t *callbacks,
+ void *callback_baton,
+ apr_hash_t *config,
+ apr_pool_t *pool)
 {
   svn_ra_session_t *session;
   const struct ra_lib_defn *defn;
@@ -281,6 +281,27 @@
   return SVN_NO_ERROR;
 }
 
+svn_error_t *svn_ra_open (svn_ra_session_t **session_p,
+ const char *repos_URL,
+ const svn_ra_callbacks_t *callbacks,
+ void *callback_baton,
+ apr_hash_t *config,
+ apr_pool_t *pool)
+{
+ /* deprecated function. Copy the contents of the svn_ra_callbacks_t
+ to a new svn_ra_callbacks2_t and call svn_ra_open2() */
+ svn_ra_callbacks2_t callbacks2;
+ callbacks2.open_tmp_file = callbacks->open_tmp_file;
+ callbacks2.auth_baton = callbacks->auth_baton;
+ callbacks2.get_wc_prop = callbacks->get_wc_prop;
+ callbacks2.set_wc_prop = callbacks->set_wc_prop;
+ callbacks2.push_wc_prop = callbacks->push_wc_prop;
+ callbacks2.invalidate_wc_props = callbacks->invalidate_wc_props;
+ callbacks2.progress_func = NULL;
+ callbacks2.progress_baton = NULL;
+ svn_ra_open2 (session_p, repos_URL, &callbacks2, callback_baton, config, pool);
+}
+
 svn_error_t *svn_ra_get_latest_revnum (svn_ra_session_t *session,
                                        svn_revnum_t *latest_revnum,
                                        apr_pool_t *pool)
Index: subversion/include/svn_progress.h
===================================================================
--- subversion/include/svn_progress.h (Revision 0)
+++ subversion/include/svn_progress.h (Revision 0)
@@ -0,0 +1,38 @@
+/**
+ * @copyright
+ * ====================================================================
+ * Copyright (c) 2000-2004 CollabNet. All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals. For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ * @endcopyright
+ */
+#ifndef SVN_PROGRESS_H
+#define SVN_PROGRESS_H
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+
+typedef void (*svn_progress_notify_func_t) (apr_off_t progress, apr_off_t total,
+ void * baton);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* SVN_PROGRESS_H */
+

Eigenschaftsänderungen: subversion\include\svn_progress.h
___________________________________________________________________
Name: svn:eol-style
   + native

Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h (Revision 15937)
+++ subversion/include/svn_client.h (Arbeitskopie)
@@ -40,6 +40,7 @@
 #include "svn_error.h"
 #include "svn_opt.h"
 #include "svn_version.h"
+#include "svn_progress.h"
 
 
 #ifdef __cplusplus
@@ -533,6 +534,14 @@
   /** callback baton for log_msg_func2
    * @since New in 1.3. */
   void *log_msg_baton2;
+
+ /** notification callback for network progress information.
+ * @since New in 1.3. */
+ svn_progress_notify_func_t progress_func;
+
+ /** callback baton for svn_progress_notify_func_t.
+ * @since New in 1.3 */
+ void *progress_baton;
 } svn_client_ctx_t;
 
 
@@ -2374,7 +2383,7 @@
  *
  * @since New in 1.3.
  *
- * @note This function is similar to svn_ra_open(), but the caller avoids
+ * @note This function is similar to svn_ra_open2(), but the caller avoids
  * having to providing its own callback functions.
  */
 svn_error_t *
Index: subversion/include/svn_ra.h
===================================================================
--- subversion/include/svn_ra.h (Revision 15937)
+++ subversion/include/svn_ra.h (Arbeitskopie)
@@ -31,6 +31,7 @@
 #include "svn_error.h"
 #include "svn_delta.h"
 #include "svn_auth.h"
+#include "svn_progress.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -308,7 +309,62 @@
  *
  * Each routine takes a @a callback_baton originally provided with the
  * vtable.
+ *
+ * @since New in 1.3.
  */
+typedef struct svn_ra_callbacks2_t
+{
+ /** Open a unique temporary file for writing in the working copy.
+ * This file will be automatically deleted when @a fp is closed.
+ */
+ svn_error_t *(*open_tmp_file) (apr_file_t **fp,
+ void *callback_baton,
+ apr_pool_t *pool);
+
+ /** An authentication baton, created by the application, which is
+ * capable of retrieving all known types of credentials.
+ */
+ svn_auth_baton_t *auth_baton;
+
+ /*** The following items may be set to NULL to disallow the RA layer
+ to perform the respective operations of the vtable functions.
+ Perhaps WC props are not defined or are in invalid for this
+ session, or perhaps the commit operation this RA session will
+ perform is a server-side only one that shouldn't do post-commit
+ processing on a working copy path. ***/
+
+ /** Fetch working copy properties.
+ *
+ *<pre> ### we might have a problem if the RA layer ever wants a property
+ * ### that corresponds to a different revision of the file than
+ * ### what is in the WC. we'll cross that bridge one day...</pre>
+ */
+ svn_ra_get_wc_prop_func_t get_wc_prop;
+
+ /** Immediately set new values for working copy properties. */
+ svn_ra_set_wc_prop_func_t set_wc_prop;
+
+ /** Schedule new values for working copy properties. */
+ svn_ra_push_wc_prop_func_t push_wc_prop;
+
+ /** Invalidate working copy properties. */
+ svn_ra_invalidate_wc_props_func_t invalidate_wc_props;
+
+ /** Notification callback used for progress information */
+ svn_progress_notify_func_t progress_func;
+
+ /** notification callback baton, used with svn_progress_notifiy_func_t */
+ void *progress_baton;
+} svn_ra_callbacks2_t;
+
+/** A collection of callbacks implemented by libsvn_client which allows
+ * an RA layer to "pull" information from the client application, or
+ * possibly store information. libsvn_client passes this vtable to
+ * @c RA->open().
+ *
+ * Each routine takes a @a callback_baton originally provided with the
+ * vtable.
+ */
 typedef struct svn_ra_callbacks_t
 {
   /** Open a unique temporary file for writing in the working copy.
@@ -391,8 +447,33 @@
  *
  * @see svn_client_open_ra_session().
  *
- * @since New in 1.2.
+ * @since New in 1.3.
  */
+svn_error_t *svn_ra_open2 (svn_ra_session_t **session_p,
+ const char *repos_URL,
+ const svn_ra_callbacks2_t *callbacks,
+ void *callback_baton,
+ apr_hash_t *config,
+ apr_pool_t *pool);
+
+/**
+ * Open a repository session to @a repos_URL. Return an opaque object
+ * representing this session in @a *session_p, allocated in @a pool.
+ *
+ * @a callbacks/@a callback_baton is a table of callbacks provided by the
+ * client; see @c svn_ra_callbacks_t.
+ *
+ * @a config is a hash mapping <tt>const char *</tt> keys to
+ * @c svn_config_t * values. For example, the @c svn_config_t for the
+ * "~/.subversion/config" file is under the key "config".
+ *
+ * All RA requests require a session; they will continue to
+ * use @a pool for memory allocation.
+ *
+ * @see svn_client_open_ra_session().
+ *
+ * @deprecated Provided for backward compatibility with the 1.2 API.
+ */
 svn_error_t *svn_ra_open (svn_ra_session_t **session_p,
                           const char *repos_URL,
                           const svn_ra_callbacks_t *callbacks,
Index: subversion/libsvn_client/ra.c
===================================================================
--- subversion/libsvn_client/ra.c (Revision 15937)
+++ subversion/libsvn_client/ra.c (Arbeitskopie)
@@ -270,7 +270,7 @@
                                       svn_client_ctx_t *ctx,
                                       apr_pool_t *pool)
 {
- svn_ra_callbacks_t *cbtable = apr_pcalloc (pool, sizeof(*cbtable));
+ svn_ra_callbacks2_t *cbtable = apr_pcalloc (pool, sizeof(*cbtable));
   svn_client__callback_baton_t *cb = apr_pcalloc (pool, sizeof(*cb));
   
   cbtable->open_tmp_file = use_admin ? open_admin_tmp_file : open_tmp_file;
@@ -279,6 +279,8 @@
   cbtable->push_wc_prop = commit_items ? push_wc_prop : NULL;
   cbtable->invalidate_wc_props = read_only_wc ? NULL : invalidate_wc_props;
   cbtable->auth_baton = ctx->auth_baton; /* new-style */
+ cbtable->progress_func = ctx->progress_func;
+ cbtable->progress_baton = ctx->progress_baton;
 
   cb->base_dir = base_dir;
   cb->base_access = base_access;
@@ -286,7 +288,7 @@
   cb->commit_items = commit_items;
   cb->ctx = ctx;
 
- SVN_ERR (svn_ra_open (ra_session, base_url, cbtable, cb, ctx->config, pool));
+ SVN_ERR (svn_ra_open2 (ra_session, base_url, cbtable, cb, ctx->config, pool));
 
   return SVN_NO_ERROR;
 }
Index: subversion/libsvn_client/copy.c
===================================================================
--- subversion/libsvn_client/copy.c (Revision 15937)
+++ subversion/libsvn_client/copy.c (Arbeitskopie)
@@ -334,7 +334,7 @@
                                               ctx, pool);
 
   /* If the two URLs appear not to be in the same repository, then
- top_url will be empty and the call to svn_ra_open()
+ top_url will be empty and the call to svn_ra_open2()
      above will have failed. Below we check for that, and propagate a
      descriptive error back to the user.
    
Index: subversion/libsvn_ra_dav/session.c
===================================================================
--- subversion/libsvn_ra_dav/session.c (Revision 15937)
+++ subversion/libsvn_ra_dav/session.c (Arbeitskopie)
@@ -561,6 +561,15 @@
 #endif /* if/else SVN_NEON_0_25 */
 }
 
+static void
+ra_dav_neonprogress(void * baton, off_t progress, off_t total)
+{
+ const svn_ra_callbacks2_t * callbacks = (svn_ra_callbacks2_t *)baton;
+ if (callbacks->progress_func)
+ {
+ callbacks->progress_func(progress, total, callbacks->progress_baton);
+ }
+}
 
 
 /* ### need an ne_session_dup to avoid the second gethostbyname
@@ -793,6 +802,9 @@
         }
     }
 
+ /* set the neon callback to make it call the svn_progress_notify_func_t */
+ ne_set_progress(sess, ra_dav_neonprogress, callbacks);
+ ne_set_progress(sess2, ra_dav_neonprogress, callbacks);
   session->priv = ras;
 
   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 Sat Aug 27 13:55:20 2005

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.