You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2012/05/07 19:48:16 UTC
svn commit: r1335152 - /subversion/trunk/subversion/libsvn_delta/text_delta.c
Author: cmpilato
Date: Mon May 7 17:48:16 2012
New Revision: 1335152
URL: http://svn.apache.org/viewvc?rev=1335152&view=rev
Log:
* subversion/libsvn_delta/text_delta.c
(svn_txdelta_send_stream): Finish an old TODO item about doing
straight window generation here instead of firing up the diff
machinery just to diff aagainst the empty stream.
Suggested by: gstein
Modified:
subversion/trunk/subversion/libsvn_delta/text_delta.c
Modified: subversion/trunk/subversion/libsvn_delta/text_delta.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/text_delta.c?rev=1335152&r1=1335151&r2=1335152&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/text_delta.c (original)
+++ subversion/trunk/subversion/libsvn_delta/text_delta.c Mon May 7 17:48:16 2012
@@ -904,29 +904,54 @@ svn_error_t *svn_txdelta_send_stream(svn
unsigned char *digest,
apr_pool_t *pool)
{
- svn_txdelta_stream_t *txstream;
- svn_error_t *err;
+ svn_txdelta_window_t delta_window = { 0 };
+ svn_txdelta_op_t delta_op;
+ svn_string_t window_data;
+ char read_buf[SVN__STREAM_CHUNK_SIZE + 1];
+ svn_checksum_ctx_t *md5_checksum_ctx;
- /* ### this is a hack. we should simply read from the stream, construct
- ### some windows, and pass those to the handler. there isn't any reason
- ### to crank up a full "diff" algorithm just to copy a stream.
- ###
- ### will fix RSN. */
-
- /* Create a delta stream which converts an *empty* bytestream into the
- target bytestream. */
- svn_txdelta(&txstream, svn_stream_empty(pool), stream, pool);
- err = svn_txdelta_send_txstream(txstream, handler, handler_baton, pool);
+ if (digest)
+ md5_checksum_ctx = svn_checksum_ctx_create(svn_checksum_md5, pool);
- if (digest && (! err))
+ while (1)
{
- const unsigned char *result_md5;
- result_md5 = svn_txdelta_md5_digest(txstream);
- /* Since err is null, result_md5 "cannot" be null. */
- memcpy(digest, result_md5, APR_MD5_DIGESTSIZE);
+ apr_size_t read_len = SVN__STREAM_CHUNK_SIZE;
+
+ SVN_ERR(svn_stream_read(stream, read_buf, &read_len));
+ if (read_len == 0)
+ break;
+
+ window_data.data = read_buf;
+ window_data.len = read_len;
+
+ delta_op.action_code = svn_txdelta_new;
+ delta_op.offset = 0;
+ delta_op.length = read_len;
+
+ delta_window.tview_len = read_len;
+ delta_window.num_ops = 1;
+ delta_window.ops = &delta_op;
+ delta_window.new_data = &window_data;
+
+ SVN_ERR(handler(&delta_window, handler_baton));
+
+ if (digest)
+ SVN_ERR(svn_checksum_update(md5_checksum_ctx, read_buf, read_len));
+
+ if (read_len < SVN__STREAM_CHUNK_SIZE)
+ break;
}
+ SVN_ERR(handler(NULL, handler_baton));
- return err;
+ if (digest)
+ {
+ svn_checksum_t *md5_checksum;
+
+ SVN_ERR(svn_checksum_final(&md5_checksum, md5_checksum_ctx, pool));
+ memcpy(digest, md5_checksum->digest, APR_MD5_DIGESTSIZE);
+ }
+
+ return SVN_NO_ERROR;
}
svn_error_t *svn_txdelta_send_txstream(svn_txdelta_stream_t *txstream,