You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2014/03/13 12:06:20 UTC

svn commit: r1577109 - in /subversion/trunk/subversion/libsvn_wc: adm_crawler.c adm_files.c adm_files.h externals.c update_editor.c wc_db.h wc_db_pristine.c

Author: rhuijben
Date: Thu Mar 13 11:06:20 2014
New Revision: 1577109

URL: http://svn.apache.org/r1577109
Log:
Replace the usage of the old svn_wc__open_writable_base() function that we
already used before wc-ng's pristine store, with a new
svn_wc__db_pristine_prepare_install() function.

This patch moves a bit of code in preparation for more refactoring of this
logic.

* subversion/libsvn_wc/adm_crawler.c
  (svn_wc__internal_transmit_text_deltas): Update caller.

* subversion/libsvn_wc/adm_files.c
  (svn_wc__open_writable_base): Remove function. Move implementation to
    svn_wc__db_pristine_prepare_install().

* subversion/libsvn_wc/adm_files.h
  (svn_wc__open_writable_base): Remove function.

* subversion/libsvn_wc/externals.c
  (apply_textdelta): Update caller.

* subversion/libsvn_wc/update_editor.c
  (lazy_target_baton): Remove unneeded baton.
  (lazy_open_target): Directly use handler baton instead
    of a baton with the same info.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_pristine_prepare_install): New function.

* subversion/libsvn_wc/wc_db_pristine.c
  (svn_wc__db_pristine_prepare_install): New function. Implementation copied
    from svn_wc__open_writable_base.

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_crawler.c
    subversion/trunk/subversion/libsvn_wc/adm_files.c
    subversion/trunk/subversion/libsvn_wc/adm_files.h
    subversion/trunk/subversion/libsvn_wc/externals.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h
    subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c

Modified: subversion/trunk/subversion/libsvn_wc/adm_crawler.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_crawler.c?rev=1577109&r1=1577108&r2=1577109&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_crawler.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_crawler.c Thu Mar 13 11:06:20 2014
@@ -1038,11 +1038,11 @@ svn_wc__internal_transmit_text_deltas(co
     {
       svn_stream_t *new_pristine_stream;
 
-      SVN_ERR(svn_wc__open_writable_base(&new_pristine_stream,
-                                         &new_pristine_tmp_abspath,
-                                         NULL, &local_sha1_checksum,
-                                         db, local_abspath,
-                                         scratch_pool, scratch_pool));
+      SVN_ERR(svn_wc__db_pristine_prepare_install(&new_pristine_stream,
+                                                  &new_pristine_tmp_abspath,
+                                                  NULL, &local_sha1_checksum,
+                                                  db, local_abspath,
+                                                  scratch_pool, scratch_pool));
       local_stream = copying_stream(local_stream, new_pristine_stream,
                                     scratch_pool);
     }

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.c?rev=1577109&r1=1577108&r2=1577109&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.c Thu Mar 13 11:06:20 2014
@@ -295,38 +295,6 @@ 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 *wri_abspath,
-                           apr_pool_t *result_pool,
-                           apr_pool_t *scratch_pool)
-{
-  const char *temp_dir_abspath;
-  SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
-
-  SVN_ERR(svn_wc__db_pristine_get_tempdir(&temp_dir_abspath, db, wri_abspath,
-                                          scratch_pool, scratch_pool));
-  SVN_ERR(svn_stream_open_unique(stream,
-                                 temp_base_abspath,
-                                 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;
-}
-
-
-
 /*** Checking for and creating administrative subdirs. ***/
 
 

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.h?rev=1577109&r1=1577108&r2=1577109&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.h (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.h Thu Mar 13 11:06:20 2014
@@ -112,30 +112,6 @@ svn_error_t *svn_wc__open_adm_stream(svn
                                      apr_pool_t *scratch_pool);
 
 
-/* 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.  The temporary file will have an arbitrary unique name, in contrast
-   to the deterministic name that svn_wc__text_base_deterministic_tmp_path()
-   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 *wri_abspath,
-                           apr_pool_t *result_pool,
-                           apr_pool_t *scratch_pool);
-
-
 /* Blow away the admistrative directory associated with DIR_ABSPATH.
    For single-db this doesn't perform actual work unless the wcroot is passed.
  */

Modified: subversion/trunk/subversion/libsvn_wc/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/externals.c?rev=1577109&r1=1577108&r2=1577109&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/externals.c (original)
+++ subversion/trunk/subversion/libsvn_wc/externals.c Thu Mar 13 11:06:20 2014
@@ -579,11 +579,12 @@ apply_textdelta(void *file_baton,
   else
     src_stream = svn_stream_empty(pool);
 
-  SVN_ERR(svn_wc__open_writable_base(&dest_stream, &eb->new_pristine_abspath,
-                                     &eb->new_md5_checksum,
-                                     &eb->new_sha1_checksum,
-                                     eb->db, eb->wri_abspath,
-                                     eb->pool, pool));
+  SVN_ERR(svn_wc__db_pristine_prepare_install(&dest_stream,
+                                              &eb->new_pristine_abspath,
+                                              &eb->new_md5_checksum,
+                                              &eb->new_sha1_checksum,
+                                              eb->db, eb->wri_abspath,
+                                              eb->pool, pool));
 
   svn_txdelta_apply(src_stream, dest_stream, NULL, eb->local_abspath, pool,
                     handler, handler_baton);

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1577109&r1=1577108&r2=1577109&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Thu Mar 13 11:06:20 2014
@@ -3616,12 +3616,6 @@ lazy_open_source(svn_stream_t **stream,
   return SVN_NO_ERROR;
 }
 
-struct lazy_target_baton {
-  struct file_baton *fb;
-  struct handler_baton *hb;
-  struct edit_baton *eb;
-};
-
 /* Implements svn_stream_lazyopen_func_t. */
 static svn_error_t *
 lazy_open_target(svn_stream_t **stream,
@@ -3629,13 +3623,15 @@ lazy_open_target(svn_stream_t **stream,
                  apr_pool_t *result_pool,
                  apr_pool_t *scratch_pool)
 {
-  struct lazy_target_baton *tb = baton;
+  struct handler_baton *hb = baton;
 
-  SVN_ERR(svn_wc__open_writable_base(stream, &tb->hb->new_text_base_tmp_abspath,
-                                     NULL, &tb->hb->new_text_base_sha1_checksum,
-                                     tb->fb->edit_baton->db,
-                                     tb->eb->wcroot_abspath,
-                                     result_pool, scratch_pool));
+  SVN_ERR(svn_wc__db_pristine_prepare_install(stream,
+                                              &hb->new_text_base_tmp_abspath,
+                                              NULL,
+                                              &hb->new_text_base_sha1_checksum,
+                                              hb->fb->edit_baton->db,
+                                              hb->fb->dir_baton->local_abspath,
+                                              result_pool, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -3655,7 +3651,6 @@ apply_textdelta(void *file_baton,
   const svn_checksum_t *recorded_base_checksum;
   svn_checksum_t *expected_base_checksum;
   svn_stream_t *source;
-  struct lazy_target_baton *tb;
   svn_stream_t *target;
 
   if (fb->skip_this)
@@ -3749,11 +3744,7 @@ apply_textdelta(void *file_baton,
       hb->source_checksum_stream = source;
     }
 
-  tb = apr_palloc(handler_pool, sizeof(struct lazy_target_baton));
-  tb->hb = hb;
-  tb->fb = fb;
-  tb->eb = eb;
-  target = svn_stream_lazyopen_create(lazy_open_target, tb, TRUE, handler_pool);
+  target = svn_stream_lazyopen_create(lazy_open_target, hb, TRUE, handler_pool);
 
   /* Prepare to apply the delta.  */
   svn_txdelta_apply(source, target,
@@ -5227,6 +5218,7 @@ svn_wc_add_repos_file4(svn_wc_context_t 
   svn_revnum_t changed_rev;
   apr_time_t changed_date;
   const char *changed_author;
+  svn_stream_t *tmp_base_contents;
   svn_error_t *err;
   apr_pool_t *pool = scratch_pool;
 
@@ -5348,18 +5340,14 @@ svn_wc_add_repos_file4(svn_wc_context_t 
   /* Copy NEW_BASE_CONTENTS into a temporary file so our log can refer to
      it, and set TMP_TEXT_BASE_ABSPATH to its path.  Compute its
      NEW_TEXT_BASE_MD5_CHECKSUM and NEW_TEXT_BASE_SHA1_CHECKSUM as we copy. */
-  {
-    svn_stream_t *tmp_base_contents;
-
-    SVN_ERR(svn_wc__open_writable_base(&tmp_base_contents,
-                                       &tmp_text_base_abspath,
-                                       &new_text_base_md5_checksum,
-                                       &new_text_base_sha1_checksum,
-                                       wc_ctx->db, local_abspath,
-                                       pool, pool));
-    SVN_ERR(svn_stream_copy3(new_base_contents, tmp_base_contents,
-                             cancel_func, cancel_baton, pool));
-  }
+  SVN_ERR(svn_wc__db_pristine_prepare_install(&tmp_base_contents,
+                                              &tmp_text_base_abspath,
+                                              &new_text_base_md5_checksum,
+                                              &new_text_base_sha1_checksum,
+                                              wc_ctx->db, local_abspath,
+                                              scratch_pool, scratch_pool));
+  SVN_ERR(svn_stream_copy3(new_base_contents, tmp_base_contents,
+                           cancel_func, cancel_baton, pool));
 
   /* If the caller gave us a new working file, copy it to a safe (temporary)
      location and set SOURCE_ABSPATH to that path. We'll then translate/copy

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1577109&r1=1577108&r2=1577109&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Thu Mar 13 11:06:20 2014
@@ -968,6 +968,26 @@ svn_wc__db_pristine_get_tempdir(const ch
                                 apr_pool_t *result_pool,
                                 apr_pool_t *scratch_pool);
 
+/* Open a writable stream to a temporary text base, ready for installing
+   into the pristine store.  Set *STREAM to the opened stream and
+   *TEMP_BASE_ABSPATH to the path to the temporary file.  The temporary
+   file will have an arbitrary unique name.
+
+   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__db_pristine_prepare_install(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 *wri_abspath,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool);
 
 /* Install the file TEMPFILE_ABSPATH (which is sitting in a directory given by
    svn_wc__db_pristine_get_tempdir()) into the pristine data store, to be

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c?rev=1577109&r1=1577108&r2=1577109&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c Thu Mar 13 11:06:20 2014
@@ -378,6 +378,35 @@ pristine_install_txn(svn_sqlite__db_t *s
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__db_pristine_prepare_install(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 *wri_abspath,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool)
+{
+  const char *temp_dir_abspath;
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
+
+  SVN_ERR(svn_wc__db_pristine_get_tempdir(&temp_dir_abspath, db, wri_abspath,
+                                          scratch_pool, scratch_pool));
+  SVN_ERR(svn_stream_open_unique(stream,
+                                 temp_base_abspath,
+                                 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;
+}
 
 svn_error_t *
 svn_wc__db_pristine_install(svn_wc__db_t *db,