- changed 9 files
Lay the groundwork that would allow ra_serf to stream svndiff deltaswithout creating temporary files when working against new servers.This patch adds a new delta editor callback, apply_textdelta_stream()that we'll use to stream the deltas, fully implements in the ra_serf'scommit editor, but doesn't yet change the behavior of existing editordrivers, such as svn_client_import5() or svn_client_commit6().This requires a minor tweak to the Subversion's HTTP protocol, andit's the reason why streaming would only work against new servers.Currently, all PUT requests include a special header that contains theresult checksum, which is used by the server to validate the integrityof the result after it applies the delta received over the wire. Whilethis approach works fine if the client first creates a temporary file withthe delta and only then starts sending it to the server (the result checksumis calculated while preparing the temporary file), it can't be used in thestream approach, as with it we'd need to know the result checksum _before_we start sending data.So we turn the existing scheme inside out, and teach mod_dav_svn to send theresult checksum in the responses to PUT requests. Then, the client wouldcheck if the received checksum matches what it calculated, and, possibly,return a checksum mismatch error (thus aborting the edit and the transaction).* subversion/include/svn_delta.h (svn_txdelta_stream_open_func_t): New callback type. (svn_delta_editor_t): Add a forward declaration for this type. (svn_delta_editor_t.apply_textdelta_stream): New vtable member.* subversion/libsvn_delta/default_editor.c (apply_textdelta_stream): Provide default implementation for this callback that performs a fallback to apply_textdelta(). (default_editor): Extend the default instance of an svn_delta_editor_t.* subversion/libsvn_delta/cancel.c (apply_textdelta_stream): Implement this forwarding callback, and ... (svn_delta_get_cancellation_editor): ...install it here.* subversion/include/svn_dav.h (SVN_DAV_NS_DAV_SVN_PUT_RESULT_CHECKSUM): New.* subversion/mod_dav_svn/repos.c (close_stream): Send the "X-SVN-Result-Fulltext-MD5" header when responding to successful PUT requests.* subversion/mod_dav_svn/version.c (get_vsn_options): Advertise new capability.* subversion/libsvn_ra_serf/ra_serf.h (svn_ra_serf__session_t.supports_put_result_checksum): New field.* subversion/libsvn_ra_serf/options.c (capabilities_headers_iterator_callback): Remember if the server sends the result checksum in the response to a successful PUT request.* subversion/libsvn_ra_serf/commit.c (file_context_t.svndiff_sent): New field. (file_context_t.remote_result_checksum): New field. (apply_textdelta): Update the comment stating that it would be nice to get rid of temporary files for svndiff delta. Factor out the svndiff format selection logic ... (negotiate_put_encoding): ...into this new helper function. (open_txdelta_baton_t): New. (txdelta_stream_errfunc): New error function for the stream bucket. (create_body_from_txdelta_stream): New svn_ra_serf__request_body_delegate_t that creates the request body by opening an svn_txdelta_stream_t, turning it into svn_stream_t and giving away a bucket wrapping around that stream. Use it in ... (apply_textdelta_stream): ...this new function that performs a PUT, and streams the request body. (put_response_ctx_t): New. (put_response_handler): New, remembers the result checksum we received from the server. (close_file): Don't do a PUT if we did it in apply_textdelta_stream(). Check for a checksum mismatch using the checksum returned from the server. (svn_ra_serf__get_commit_editor): Install the new apply_textdelta_stream() callback when working against new servers.