Re: svn commit: r1232634 - /subversion/branches/ev2-export/subversion/libsvn_client/export.c
On Tue, Jan 17, 2012 at 11:10 PM, Daniel Shahaf danie...@elego.de wrote: hwri...@apache.org wrote on Tue, Jan 17, 2012 at 23:04:32 -: Author: hwright Date: Tue Jan 17 23:04:32 2012 New Revision: 1232634 URL: http://svn.apache.org/viewvc?rev=1232634view=rev Log: On the ev2-export branch: Replace one hack with another, which allows us to remove the vestigal delta editor from the export functionality. * subversion/libsvn_client/export.c (dir_baton, file_baton, change_file_prop, close_file): Remove. (svn_client_export5): Instead of manually driving the delta editor, manually drive an Ev2 editor. This has the happy consequence of only requiring one function call, instead of three. Modified: subversion/branches/ev2-export/subversion/libsvn_client/export.c Modified: subversion/branches/ev2-export/subversion/libsvn_client/export.c URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_client/export.c?rev=1232634r1=1232633r2=1232634view=diff == +++ subversion/branches/ev2-export/subversion/libsvn_client/export.c Tue Jan 17 23:04:32 2012 @@ -671,166 +671,6 @@ struct edit_baton }; static svn_error_t * fetch_props_func(apr_hash_t **props, void *baton, @@ -1138,8 +978,8 @@ svn_client_export5(svn_revnum_t *result_ if (kind == svn_node_file) { apr_hash_t *props; + svn_stream_t *tmp_stream; + const char *tmppath; svn_node_kind_t to_kind; if (svn_path_is_empty(to_path)) @@ -1171,41 +1011,21 @@ svn_client_export5(svn_revnum_t *result_ overwrite directory with non-directory), svn_dirent_local_style(to_path, pool)); + SVN_ERR(svn_stream_open_unique(tmp_stream, tmppath, + svn_dirent_dirname(eb-root_path, pool), + svn_io_file_del_on_pool_cleanup, + pool, pool)); SVN_ERR(svn_ra_get_file(ra_session, , revnum, + tmp_stream, NULL, props, pool)); + SVN_ERR(svn_stream_close(tmp_stream)); + SVN_ERR(svn_stream_open_readonly(tmp_stream, tmppath, pool, pool)); Same question as before. Why the tempfile? Can you avoid it? (Perhaps that requires an svn_stream_copy() call?) The tempfile here is due to the way the svn_ra_get_file() interface works. Note that instead of returning a stream, that API accepts and already open stream and then pushes content to it. In contrast, the Ev2 add_file handler, as well as svn_stream_copy3(), pulls content from the source stream. Given this mismatch, a temporary storage location is needed. It may be possible to utilize the new spillbuffer code to build a stream which can act as a buffer when needed and only spill to disk when the file grows beyond a certain threshold, though I've not explored it. -Hyrum -- uberSVN: Apache Subversion Made Easy http://www.uberSVN.com/
svn commit: r1232634 - /subversion/branches/ev2-export/subversion/libsvn_client/export.c
Author: hwright Date: Tue Jan 17 23:04:32 2012 New Revision: 1232634 URL: http://svn.apache.org/viewvc?rev=1232634view=rev Log: On the ev2-export branch: Replace one hack with another, which allows us to remove the vestigal delta editor from the export functionality. * subversion/libsvn_client/export.c (dir_baton, file_baton, change_file_prop, close_file): Remove. (svn_client_export5): Instead of manually driving the delta editor, manually drive an Ev2 editor. This has the happy consequence of only requiring one function call, instead of three. Modified: subversion/branches/ev2-export/subversion/libsvn_client/export.c Modified: subversion/branches/ev2-export/subversion/libsvn_client/export.c URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_client/export.c?rev=1232634r1=1232633r2=1232634view=diff == --- subversion/branches/ev2-export/subversion/libsvn_client/export.c (original) +++ subversion/branches/ev2-export/subversion/libsvn_client/export.c Tue Jan 17 23:04:32 2012 @@ -671,166 +671,6 @@ struct edit_baton }; -struct dir_baton -{ - struct edit_baton *edit_baton; - const char *path; -}; - - -struct file_baton -{ - struct edit_baton *edit_baton; - - const char *path; - const char *tmppath; - - /* We need to keep this around so we can explicitly close it in close_file, - thus flushing its output to disk so we can copy and translate it. */ - svn_stream_t *tmp_stream; - - /* The MD5 digest of the file's fulltext. This is all zeros until - the last textdelta window handler call returns. */ - unsigned char text_digest[APR_MD5_DIGESTSIZE]; - - /* The three svn: properties we might actually care about. */ - const svn_string_t *eol_style_val; - const svn_string_t *keywords_val; - const svn_string_t *executable_val; - svn_boolean_t special; - - /* Any keyword vals to be substituted */ - const char *revision; - const char *url; - const char *author; - apr_time_t date; - - /* Pool associated with this baton. */ - apr_pool_t *pool; -}; - - -static svn_error_t * -change_file_prop(void *file_baton, - const char *name, - const svn_string_t *value, - apr_pool_t *pool) -{ - struct file_baton *fb = file_baton; - - if (! value) -return SVN_NO_ERROR; - - /* Store only the magic three properties. */ - if (strcmp(name, SVN_PROP_EOL_STYLE) == 0) -fb-eol_style_val = svn_string_dup(value, fb-pool); - - else if (! fb-edit_baton-ignore_keywords - strcmp(name, SVN_PROP_KEYWORDS) == 0) -fb-keywords_val = svn_string_dup(value, fb-pool); - - else if (strcmp(name, SVN_PROP_EXECUTABLE) == 0) -fb-executable_val = svn_string_dup(value, fb-pool); - - /* Try to fill out the baton's keywords-structure too. */ - else if (strcmp(name, SVN_PROP_ENTRY_COMMITTED_REV) == 0) -fb-revision = apr_pstrdup(fb-pool, value-data); - - else if (strcmp(name, SVN_PROP_ENTRY_COMMITTED_DATE) == 0) -SVN_ERR(svn_time_from_cstring(fb-date, value-data, fb-pool)); - - else if (strcmp(name, SVN_PROP_ENTRY_LAST_AUTHOR) == 0) -fb-author = apr_pstrdup(fb-pool, value-data); - - else if (strcmp(name, SVN_PROP_SPECIAL) == 0) -fb-special = TRUE; - - return SVN_NO_ERROR; -} - - -/* Move the tmpfile to file, and send feedback. */ -static svn_error_t * -close_file(void *file_baton, - const char *text_digest, - apr_pool_t *pool) -{ - struct file_baton *fb = file_baton; - struct edit_baton *eb = fb-edit_baton; - svn_checksum_t *text_checksum; - svn_checksum_t *actual_checksum; - - /* Was a txdelta even sent? */ - if (! fb-tmppath) -return SVN_NO_ERROR; - - SVN_ERR(svn_stream_close(fb-tmp_stream)); - - SVN_ERR(svn_checksum_parse_hex(text_checksum, svn_checksum_md5, text_digest, - pool)); - actual_checksum = svn_checksum__from_digest(fb-text_digest, - svn_checksum_md5, pool); - - /* Note that text_digest can be NULL when talking to certain repositories. - In that case text_checksum will be NULL and the following match code - will note that the checksums match */ - if (!svn_checksum_match(text_checksum, actual_checksum)) -return svn_checksum_mismatch_err(text_checksum, actual_checksum, pool, - _(Checksum mismatch for '%s'), - svn_dirent_local_style(fb-path, pool)); - - if ((! fb-eol_style_val) (! fb-keywords_val) (! fb-special)) -{ - SVN_ERR(svn_io_file_rename(fb-tmppath, fb-path, pool)); -} - else -{ - svn_subst_eol_style_t style; - const char *eol = NULL; - svn_boolean_t repair = FALSE; - apr_hash_t *final_kw = NULL; - - if (fb-eol_style_val) -{ - SVN_ERR(get_eol_style(style, eol, fb-eol_style_val-data, -eb-native_eol)); -
Re: svn commit: r1232634 - /subversion/branches/ev2-export/subversion/libsvn_client/export.c
hwri...@apache.org wrote on Tue, Jan 17, 2012 at 23:04:32 -: Author: hwright Date: Tue Jan 17 23:04:32 2012 New Revision: 1232634 URL: http://svn.apache.org/viewvc?rev=1232634view=rev Log: On the ev2-export branch: Replace one hack with another, which allows us to remove the vestigal delta editor from the export functionality. * subversion/libsvn_client/export.c (dir_baton, file_baton, change_file_prop, close_file): Remove. (svn_client_export5): Instead of manually driving the delta editor, manually drive an Ev2 editor. This has the happy consequence of only requiring one function call, instead of three. Modified: subversion/branches/ev2-export/subversion/libsvn_client/export.c Modified: subversion/branches/ev2-export/subversion/libsvn_client/export.c URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_client/export.c?rev=1232634r1=1232633r2=1232634view=diff == +++ subversion/branches/ev2-export/subversion/libsvn_client/export.c Tue Jan 17 23:04:32 2012 @@ -671,166 +671,6 @@ struct edit_baton }; static svn_error_t * fetch_props_func(apr_hash_t **props, void *baton, @@ -1138,8 +978,8 @@ svn_client_export5(svn_revnum_t *result_ if (kind == svn_node_file) { apr_hash_t *props; + svn_stream_t *tmp_stream; + const char *tmppath; svn_node_kind_t to_kind; if (svn_path_is_empty(to_path)) @@ -1171,41 +1011,21 @@ svn_client_export5(svn_revnum_t *result_ overwrite directory with non-directory), svn_dirent_local_style(to_path, pool)); + SVN_ERR(svn_stream_open_unique(tmp_stream, tmppath, + svn_dirent_dirname(eb-root_path, pool), + svn_io_file_del_on_pool_cleanup, + pool, pool)); SVN_ERR(svn_ra_get_file(ra_session, , revnum, + tmp_stream, NULL, props, pool)); + SVN_ERR(svn_stream_close(tmp_stream)); + SVN_ERR(svn_stream_open_readonly(tmp_stream, tmppath, pool, pool)); Same question as before. Why the tempfile? Can you avoid it? (Perhaps that requires an svn_stream_copy() call?) + /* Since you cannot actually root an editor at a file, we + * manually drive a function of our editor. */ + SVN_ERR(add_file_ev2(eb, , NULL, tmp_stream, props, + SVN_INVALID_REVNUM, pool)); } else if (kind == svn_node_dir) {