Author: ivan
Date: Thu Aug 22 16:41:11 2013
New Revision: 1516511
URL: http://svn.apache.org/r1516511
Log:
Fix issue 3260: problems with progress callback.
* subversion/include/svn_client.h
(svn_client_ctx_t): Add PROGRESS member.
* subversion/libsvn_client/ra.c
(callback_baton_t): Add LAST_PROGRESS member.
(progress_func): New. Accumulate progress information for all sessiona
and invoke real callback with cumulative progress.
(svn_client__open_ra_session_internal): Use progress_func.
Modified:
subversion/trunk/subversion/include/svn_client.h
subversion/trunk/subversion/libsvn_client/ra.c
Modified: subversion/trunk/subversion/include/svn_client.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1516511&r1=1516510&r2=1516511&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Thu Aug 22 16:41:11 2013
@@ -1014,6 +1014,10 @@ typedef struct svn_client_ctx_t
* @since New in 1.7. */
svn_wc_context_t *wc_ctx;
+ /** Total number of bytes transferred over network.
+ *
+ * @Since New in 1.9. */
+ apr_off_t progress;
} svn_client_ctx_t;
/** Initialize a client context.
Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1516511&r1=1516510&r2=1516511&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Thu Aug 22 16:41:11 2013
@@ -70,6 +70,8 @@ typedef struct callback_baton_t
/* A client context. */
svn_client_ctx_t *ctx;
+ /* Last progress reported by progress callback. */
+ apr_off_t last_progress;
} callback_baton_t;
@@ -287,6 +289,28 @@ get_client_string(void *baton,
return SVN_NO_ERROR;
}
+/* Implements svn_ra_progress_notify_func_t. Accumulates progress information
+ * for different RA sessions and reports total progress to caller. */
+static void
+progress_func(apr_off_t progress,
+ apr_off_t total,
+ void *baton,
+ apr_pool_t *pool)
+{
+ callback_baton_t *b = baton;
+ svn_client_ctx_t *ctx = b->ctx;
+
+ ctx->progress += (progress - b->last_progress);
+ b->last_progress = progress;
+
+ if (ctx->progress_func)
+ {
+ /* All RA implementations currently provide -1 for total. So it doesn't
+ make sense to develop some complex logic to combine total across all
+ RA sessions. */
+ ctx->progress_func(ctx->progress, -1, ctx->progress_baton, pool);
+ }
+}
#define SVN_CLIENT__MAX_REDIRECT_ATTEMPTS 3 /* ### TODO: Make configurable. */
@@ -320,8 +344,8 @@ svn_client__open_ra_session_internal(svn
cbtable->invalidate_wc_props = (write_dav_props && read_dav_props)
? invalidate_wc_props : NULL;
cbtable->auth_baton = ctx->auth_baton; /* new-style */
- cbtable->progress_func = ctx->progress_func;
- cbtable->progress_baton = ctx->progress_baton;
+ cbtable->progress_func = progress_func;
+ cbtable->progress_baton = cb;
cbtable->cancel_func = ctx->cancel_func ? cancel_callback : NULL;
cbtable->get_client_string = get_client_string;
if (base_dir_abspath)