Author: julianfoad
Date: Thu Apr  8 10:29:07 2010
New Revision: 931855

URL: http://svn.apache.org/viewvc?rev=931855&view=rev
Log:
Move the checksum calculation for new text base files into the single
function svn_wc__open_writable_base().

* subversion/libsvn_wc/adm_files.c,
  subversion/libsvn_wc/adm_files.h
  (svn_wc__open_writable_base): Add optional MD-5 and SHA-1 checksum outputs.

* subversion/libsvn_wc/update_editor.c
  (get_pristine_tee_stream): Remove the checksum output parameter.
  (add_file_with_history, apply_textdelta, svn_wc_add_repos_file4): Get the
    checksums from svn_wc__open_writable_base() instead of from
    get_pristine_tee_stream() and svn_stream_checksummed2().

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_files.c
    subversion/trunk/subversion/libsvn_wc/adm_files.h
    subversion/trunk/subversion/libsvn_wc/update_editor.c

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.c?rev=931855&r1=931854&r2=931855&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.c Thu Apr  8 10:29:07 2010
@@ -390,6 +390,8 @@ svn_wc__open_adm_stream(svn_stream_t **s
 svn_error_t *
 svn_wc__open_writable_base(svn_stream_t **stream,
                            const char **temp_base_abspath,
+                           svn_checksum_t **md5_checksum,
+                           svn_checksum_t **sha1_checksum,
                            svn_wc__db_t *db,
                            const char *local_abspath,
                            apr_pool_t *result_pool,
@@ -407,6 +409,13 @@ svn_wc__open_writable_base(svn_stream_t 
                                  temp_dir_abspath,
                                  svn_io_file_del_none,
                                  result_pool, scratch_pool));
+  if (md5_checksum)
+    *stream = svn_stream_checksummed2(*stream, NULL, md5_checksum,
+                                      svn_checksum_md5, FALSE, result_pool);
+  if (sha1_checksum)
+    *stream = svn_stream_checksummed2(*stream, NULL, sha1_checksum,
+                                      svn_checksum_sha1, FALSE, result_pool);
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.h?rev=931855&r1=931854&r2=931855&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.h (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.h Thu Apr  8 10:29:07 2010
@@ -123,12 +123,20 @@ svn_error_t *svn_wc__open_adm_stream(svn
 /* Open a writable stream to a temporary (normal or revert) text base,
    associated with the versioned file LOCAL_ABSPATH in DB.  Set *STREAM to
    the opened stream and *TEMP_BASE_ABSPATH to the path to the temporary
-   file, both allocated in RESULT_POOL.  The temporary file will have an
-   arbitrary unique name, in contrast to the deterministic name that
-   svn_wc__text_base_path(tmp=TRUE) returns. */
+   file.  The temporary file will have an arbitrary unique name, in contrast
+   to the deterministic name that svn_wc__text_base_path(tmp=TRUE) returns.
+
+   Arrange that, on stream closure, *MD5_CHECKSUM and *SHA1_CHECKSUM will be
+   set to the MD-5 and SHA-1 checksums respectively of that file.
+   MD5_CHECKSUM and/or SHA1_CHECKSUM may be NULL if not wanted.
+
+   Allocate the new stream, path and checksums in RESULT_POOL.
+ */
 svn_error_t *
 svn_wc__open_writable_base(svn_stream_t **stream,
                            const char **temp_base_abspath,
+                           svn_checksum_t **md5_checksum,
+                           svn_checksum_t **sha1_checksum,
                            svn_wc__db_t *db,
                            const char *local_abspath,
                            apr_pool_t *result_pool,

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=931855&r1=931854&r2=931855&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Thu Apr  8 10:29:07 
2010
@@ -3149,13 +3149,10 @@ absent_directory(const char *path,
 /* Set *TEE_OUTPUT_STREAM to a writable stream that copies its data to both
    OUTPUT_STREAM and a new WC-NG pristine temp file corresponding to (DB,
    LOCAL_ABSPATH). Set *NEW_PRISTINE_TMP_ABSPATH to the path of that file.
-   Arrange that, on stream closure, *NEW_PRISTINE_SHA1_CHECKSUM will be set
-   to the SHA-1 checksum of that file.
  */
 static svn_error_t *
 get_pristine_tee_stream(svn_stream_t **tee_output_stream,
                         const char **new_pristine_tmp_abspath,
-                        svn_checksum_t **new_pristine_sha1_checksum,
                         svn_wc__db_t *db,
                         const char *local_abspath,
                         svn_stream_t *output_stream,
@@ -3171,10 +3168,6 @@ get_pristine_tee_stream(svn_stream_t **t
   SVN_ERR(svn_stream_open_unique(&pristine_temp, new_pristine_tmp_abspath,
                                  pristine_tempdir, svn_io_file_del_none,
                                  result_pool, scratch_pool));
-  pristine_temp = svn_stream_checksummed2(pristine_temp, NULL,
-                                          new_pristine_sha1_checksum,
-                                          svn_checksum_sha1, TRUE,
-                                          result_pool);
 
   *tee_output_stream = svn_stream_tee(output_stream, pristine_temp,
                                       result_pool);
@@ -3436,24 +3429,20 @@ add_file_with_history(const char *path,
   /* Open the text base for writing (this will get us a temporary file).  */
   SVN_ERR(svn_wc__open_writable_base(&copied_stream,
                                      &tfb->copied_text_base_abspath,
+  /* Compute an MD5 checksum for the stream as we write stuff into it.
+     ### this is temporary. in many cases, we already *know* the checksum
+     ### since it is a copy. */
+                                     &tfb->copied_text_base_md5_checksum,
+                                     &tfb->copied_text_base_sha1_checksum,
                                      db, pb->local_abspath,
                                      pool, pool));
 #ifdef SVN_EXPERIMENTAL
   /* Copy the 'copied_stream' into a WC-NG pristine temp file as well. */
   SVN_ERR(get_pristine_tee_stream(&copied_stream, 
&tfb->new_pristine_tmp_abspath,
-                                  &tfb->copied_text_base_sha1_checksum, db,
-                                  tfb->local_abspath, copied_stream,
+                                  db, tfb->local_abspath, copied_stream,
                                   pool, subpool));
 #endif
 
-  /* Compute a checksum for the stream as we write stuff into it.
-     ### this is temporary. in many cases, we already *know* the checksum
-     ### since it is a copy. */
-  copied_stream = svn_stream_checksummed2(
-                                copied_stream,
-                                NULL, &tfb->copied_text_base_md5_checksum,
-                                svn_checksum_md5, FALSE, pool);
-
   if (src_local_abspath != NULL) /* Found a file to copy */
     {
       /* Copy the existing file's text-base over to the (temporary)
@@ -4072,6 +4061,7 @@ apply_textdelta(void *file_baton,
 
   /* Open the text base for writing (this will get us a temporary file).  */
   err = svn_wc__open_writable_base(&target, &hb->new_text_base_tmp_abspath,
+                                   NULL, &hb->new_text_base_sha1_checksum,
                                    fb->edit_baton->db, fb->local_abspath,
                                    handler_pool, pool);
   if (err)
@@ -4084,7 +4074,6 @@ apply_textdelta(void *file_baton,
   /* Copy the 'target' stream into a WC-NG pristine temp file as well.
      ###: This is currently tee'd for compat. */
   SVN_ERR(get_pristine_tee_stream(&target, &hb->new_pristine_tmp_abspath,
-                                  &hb->new_text_base_sha1_checksum,
                                   fb->edit_baton->db, fb->local_abspath,
                                   target, handler_pool, pool));
 #endif
@@ -5931,11 +5920,9 @@ svn_wc_add_repos_file4(svn_wc_context_t 
      can refer to it. Compute its checksum as we copy. */
   SVN_ERR(svn_wc__open_writable_base(&tmp_base_contents,
                                      &tmp_text_base_abspath,
+                                     &base_checksum, NULL,
                                      wc_ctx->db, local_abspath,
                                      pool, pool));
-  new_base_contents = svn_stream_checksummed2(new_base_contents,
-                                              &base_checksum, NULL,
-                                              svn_checksum_md5, TRUE, pool);
   SVN_ERR(svn_stream_copy3(new_base_contents, tmp_base_contents,
                            cancel_func, cancel_baton,
                            pool));


Reply via email to