subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r931831 - /subversion/trunk/subversion/libsvn_wc/update_editor.c
Date Thu, 08 Apr 2010 08:33:30 GMT
Author: julianfoad
Date: Thu Apr  8 08:33:30 2010
New Revision: 931831

URL: http://svn.apache.org/viewvc?rev=931831&view=rev
Log:
Rename some file-scope variables to make their relationships clearer.  No
functional change.

Note: 'new_pristine_tmp_abspath' and 'new_text_base_tmp_abspath' mean the
same thing, but the former is a WC-NG equivalent of the latter, temporarily
existing in parallel inside '#ifdef SVN_EXPERIMENTAL'.

* subversion/libsvn_wc/update_editor.c
  (handler_baton): Move the SHA1 checksum to immediately after the
    corresponding MD5 checksum. Rename members:
                'work_abspath'              -> 'new_text_base_tmp_abspath',
                'temp_pristine_abspath'     -> 'new_pristine_tmp_abspath',
                'expected_source_checksum'  -> 'expected_source_md5_checksum',
                'md5_actual_source_checksum'-> 'actual_source_md5_checksum',
                'digest'                    -> 'new_text_base_md5_digest'.
                'sha1_actual_checksum'      -> 'new_text_base_sha1_checksum',
  (file_baton): 'new_text_base_abspath'     -> 'new_text_base_tmp_abspath',
                'temp_pristine_abspath'     -> 'new_pristine_tmp_abspath',
                'md5_actual_checksum'       -> 'new_text_base_md5_checksum',
                'sha1_actual_checksum'      -> 'new_text_base_sha1_checksum',
                'md5_copied_base_checksum'  -> 'copied_text_base_md5_checksum',
                'sha1_copied_base_checksum' -> 'copied_text_base_sha1_checksum'.
  (get_pristine_tee_stream):
                'temp_pristine_abspath'     -> 'new_pristine_tmp_abspath',
                'actual_checksum'           -> 'new_text_base_sha1_checksum'.
  (merge_file): 'new_text_base_abspath'     -> 'new_text_base_tmp_abspath'.
  (apply_textdelta): Also split a compound assignment into two simple ones.
  (): Adjust all uses accordingly, and update comments.

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

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=931831&r1=931830&r2=931831&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Thu Apr  8 08:33:30 2010
@@ -372,15 +372,15 @@ struct handler_baton
   struct file_baton *fb;
 
   /* Where we are assembling the new file. */
-  const char *work_abspath;
+  const char *new_text_base_tmp_abspath;
 #ifdef SVN_EXPERIMENTAL
-  /* Where the pristine is before we can copy it into the correct location. */
-  const char *temp_pristine_abspath;
+  /* The WC-NG equivalent of NEW_TEXT_BASE_TMP_ABSPATH. */
+  const char *new_pristine_tmp_abspath;
 #endif
 
-    /* The expected checksum of the text source or NULL if no base
+    /* The expected MD5 checksum of the text source or NULL if no base
      checksum is available */
-  svn_checksum_t *expected_source_checksum;
+  svn_checksum_t *expected_source_md5_checksum;
 
   /* Why two checksums?
      The editor currently provides an md5 which we use to detect corruption
@@ -391,20 +391,21 @@ struct handler_baton
 
   /* The calculated checksum of the text source or NULL if the acual
      checksum is not being calculated */
-  svn_checksum_t *md5_actual_source_checksum;
-
-  /* A calculated SHA-1, which we'll use for eventually writing the
-     pristine. */
-  svn_checksum_t *sha1_actual_checksum;
+  svn_checksum_t *actual_source_md5_checksum;
 
   /* The stream used to calculate the source checksums */
   svn_stream_t *source_checksum_stream;
 
-  /* This is initialized to all zeroes when the baton is created, then
+  /* A calculated MD5 digest of NEW_TEXT_BASE_TMP_ABSPATH.
+     This is initialized to all zeroes when the baton is created, then
      populated with the MD5 digest of the resultant fulltext after the
      last window is handled by the handler returned from
      apply_textdelta(). */
-  unsigned char digest[APR_MD5_DIGESTSIZE];
+  unsigned char new_text_base_md5_digest[APR_MD5_DIGESTSIZE];
+
+  /* A calculated SHA-1 of NEW_PRISTINE_TMP_ABSPATH, which we'll use for
+     eventually writing the pristine. */
+  svn_checksum_t * new_text_base_sha1_checksum;
 };
 
 
@@ -944,17 +945,17 @@ struct file_baton
   /* The path to the incoming text base (that is, to a text-base-file-
      in-progress in the tmp area).  This gets set if there are file
      content changes. */
-  const char *new_text_base_abspath;
+  const char *new_text_base_tmp_abspath;
 #ifdef SVN_EXPERIMENTAL
-  /* Where the pristine is before we can copy it into the correct location. */
-  const char *temp_pristine_abspath;
+  /* The WC-NG equivalent of NEW_TEXT_BASE_TMP_ABSPATH. */
+  const char *new_pristine_tmp_abspath;
 #endif
 
-  /* The checksum for the file located at NEW_TEXT_BASE_ABSPATH. */
-  svn_checksum_t *md5_actual_checksum;
+  /* The MD5 checksum of the incoming text base (pristine text). */
+  svn_checksum_t *new_text_base_md5_checksum;
 
-  /* The sha1 checksum of the pristine. */
-  svn_checksum_t *sha1_actual_checksum;
+  /* The SHA1 checksum of the incoming text base (pristine text). */
+  svn_checksum_t *new_text_base_sha1_checksum;
 
   /* If this file was added with history, this is the path to a copy
      of the text base of the copyfrom file (in the temporary area). */
@@ -962,11 +963,11 @@ struct file_baton
 
   /* If this file was added with history, this is the MD5 checksum of the
      text base (see copied_text_base_abspath). May be NULL if unknown. */
-  svn_checksum_t *md5_copied_base_checksum;
+  svn_checksum_t *copied_text_base_md5_checksum;
 
-  /* If this file was added with history, this is the SHA-1 checksum of
-     the text base (see copied_text_base_abspath). May be NULL if unknown. */
-  svn_checksum_t *sha1_copied_base_checksum;
+  /* If this file was added with history, this is the SHA-1 checksum of the
+     text base (see copied_text_base_abspath). May be NULL if unknown. */
+  svn_checksum_t *copied_text_base_sha1_checksum;
 
   /* If this file was added with history, and the copyfrom had local
      mods, this is the path to a copy of the user's version with local
@@ -1059,23 +1060,22 @@ window_handler(svn_txdelta_window_t *win
   if (window != NULL && !err)
     return SVN_NO_ERROR;
 
-  if (hb->expected_source_checksum)
+  if (hb->expected_source_md5_checksum)
     {
-      /* Close the stream to calculate the final checksum
-         (This also calculates the md5 as well.) */
+      /* Close the stream to calculate HB->actual_source_md5_checksum. */
       svn_error_t *err2 = svn_stream_close(hb->source_checksum_stream);
 
-      if (!err2 && !svn_checksum_match(hb->expected_source_checksum,
-                                       hb->md5_actual_source_checksum))
+      if (!err2 && !svn_checksum_match(hb->expected_source_md5_checksum,
+                                       hb->actual_source_md5_checksum))
         {
           err = svn_error_createf(SVN_ERR_WC_CORRUPT_TEXT_BASE, err,
                     _("Checksum mismatch while updating '%s':\n"
                       "   expected:  %s\n"
                       "     actual:  %s\n"),
                     svn_dirent_local_style(fb->local_abspath, hb->pool),
-                    svn_checksum_to_cstring(hb->expected_source_checksum,
+                    svn_checksum_to_cstring(hb->expected_source_md5_checksum,
                                             hb->pool),
-                    svn_checksum_to_cstring(hb->md5_actual_source_checksum,
+                    svn_checksum_to_cstring(hb->actual_source_md5_checksum,
                                             hb->pool));
         }
 
@@ -1085,26 +1085,29 @@ window_handler(svn_txdelta_window_t *win
   if (err)
     {
       /* We failed to apply the delta; clean up the temporary file.  */
-      svn_error_clear(svn_io_remove_file2(hb->work_abspath, TRUE, hb->pool));
+      svn_error_clear(svn_io_remove_file2(hb->new_text_base_tmp_abspath, TRUE,
+                                          hb->pool));
 #ifdef SVN_EXPERIMENTAL
-      svn_error_clear(svn_io_remove_file2(hb->temp_pristine_abspath, TRUE,
+      svn_error_clear(svn_io_remove_file2(hb->new_pristine_tmp_abspath, TRUE,
                                           hb->pool));
 #endif
     }
   else
     {
       /* Tell the file baton about the new text base. */
-      fb->new_text_base_abspath = apr_pstrdup(fb->pool, hb->work_abspath);
+      fb->new_text_base_tmp_abspath = apr_pstrdup(fb->pool,
+                                              hb->new_text_base_tmp_abspath);
 #ifdef SVN_EXPERIMENTAL
-      fb->temp_pristine_abspath = apr_pstrdup(fb->pool,
-                                              hb->temp_pristine_abspath);
+      fb->new_pristine_tmp_abspath = apr_pstrdup(fb->pool,
+                                              hb->new_pristine_tmp_abspath);
 #endif
 
       /* ... and its checksums. */
-      fb->md5_actual_checksum =
-        svn_checksum__from_digest(hb->digest, svn_checksum_md5, fb->pool);
-      fb->sha1_actual_checksum =
-        svn_checksum_dup(hb->sha1_actual_checksum, fb->pool);
+      fb->new_text_base_md5_checksum =
+        svn_checksum__from_digest(hb->new_text_base_md5_digest,
+                                  svn_checksum_md5, fb->pool);
+      fb->new_text_base_sha1_checksum =
+        svn_checksum_dup(hb->new_text_base_sha1_checksum, fb->pool);
     }
 
   svn_pool_destroy(hb->pool);
@@ -3145,14 +3148,14 @@ absent_directory(const char *path,
 #ifdef SVN_EXPERIMENTAL
 /* 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 *TEMP_PRISTINE_ABSPATH to the path of that file.
-   Arrange that, on stream closure, *ACTUAL_CHECKSUM will be set to the SHA-1
-   checksum of that file.
+   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 **temp_pristine_abspath,
-                        svn_checksum_t **actual_checksum,
+                        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,
@@ -3165,11 +3168,11 @@ get_pristine_tee_stream(svn_stream_t **t
   SVN_ERR(svn_wc__db_pristine_get_tempdir(&pristine_tempdir, db,
                                           local_abspath, scratch_pool,
                                           scratch_pool));
-  SVN_ERR(svn_stream_open_unique(&pristine_temp, temp_pristine_abspath,
+  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,
-                                          actual_checksum,
+                                          new_pristine_sha1_checksum,
                                           svn_checksum_sha1, TRUE,
                                           result_pool);
 
@@ -3437,8 +3440,8 @@ add_file_with_history(const char *path,
                                      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->temp_pristine_abspath,
-                                  &tfb->sha1_copied_base_checksum, db,
+  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,
                                   pool, subpool));
 #endif
@@ -3448,7 +3451,7 @@ add_file_with_history(const char *path,
      ### since it is a copy. */
   copied_stream = svn_stream_checksummed2(
                                 copied_stream,
-                                NULL, &tfb->md5_copied_base_checksum,
+                                NULL, &tfb->copied_text_base_md5_checksum,
                                 svn_checksum_md5, FALSE, pool);
 
   if (src_local_abspath != NULL) /* Found a file to copy */
@@ -4055,21 +4058,20 @@ apply_textdelta(void *file_baton,
   /* Checksum the text base while applying deltas */
   if (checksum)
     {
-      SVN_ERR(svn_checksum_parse_hex(&hb->expected_source_checksum,
+      SVN_ERR(svn_checksum_parse_hex(&hb->expected_source_md5_checksum,
                                      svn_checksum_md5, checksum,
                                      handler_pool));
 
       /* Wrap stream and store reference to allow calculating the md5 */
-      hb->source_checksum_stream =
-                 source = svn_stream_checksummed2(
-                                            source,
-                                            &hb->md5_actual_source_checksum,
-                                            NULL, svn_checksum_md5,
-                                            TRUE, handler_pool);
+      source = svn_stream_checksummed2(source,
+                                       &hb->actual_source_md5_checksum,
+                                       NULL, svn_checksum_md5,
+                                       TRUE, handler_pool);
+      hb->source_checksum_stream = source;
     }
 
   /* Open the text base for writing (this will get us a temporary file).  */
-  err = svn_wc__open_writable_base(&target, &hb->work_abspath,
+  err = svn_wc__open_writable_base(&target, &hb->new_text_base_tmp_abspath,
                                    fb->edit_baton->db, fb->local_abspath,
                                    handler_pool, pool);
   if (err)
@@ -4081,15 +4083,16 @@ apply_textdelta(void *file_baton,
 #ifdef SVN_EXPERIMENTAL
   /* 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->temp_pristine_abspath,
-                                  &hb->sha1_actual_checksum,
+  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
 
   /* Prepare to apply the delta.  */
   svn_txdelta_apply(source, target,
-                    hb->digest, hb->work_abspath /* error_info */,
+                    hb->new_text_base_md5_digest,
+                    hb->new_text_base_tmp_abspath /* error_info */,
                     handler_pool,
                     &hb->apply_handler, &hb->apply_baton);
 
@@ -4238,7 +4241,7 @@ install_text_base(svn_stringbuf_t **log_
  * sensitive to eol translation, keyword substitution, and performing
  * all actions accumulated the parent directory's work queue.
  *
- * If there's a new text base, NEW_TEXT_BASE_ABSPATH must be the full
+ * If there's a new text base, NEW_TEXT_BASE_TMP_ABSPATH must be the full
  * pathname of the new text base, somewhere in the administrative area
  * of the working file.  It will be installed as the new text base for
  * this file, and removed after a successful run of the generated log
@@ -4261,7 +4264,7 @@ merge_file(svn_stringbuf_t **log_accum,
            svn_wc_notify_state_t *content_state,
            const svn_wc_entry_t *entry,
            struct file_baton *fb,
-           const char *new_text_base_abspath,
+           const char *new_text_base_tmp_abspath,
            const svn_checksum_t *actual_checksum,
            apr_pool_t *pool)
 {
@@ -4279,7 +4282,7 @@ merge_file(svn_stringbuf_t **log_accum,
      things are true:
 
          - The new pristine text of F, if any, is present at
-           NEW_TEXT_BASE_ABSPATH
+           NEW_TEXT_BASE_TMP_ABSPATH
 
          - The .svn/entries file still reflects the old version of F.
 
@@ -4331,8 +4334,8 @@ merge_file(svn_stringbuf_t **log_accum,
          and a working file. Presumably, the working file is modified
          relative to the new pristine.
 
-         The new pristine is in NEW_TEXT_BASE_ABSPATH, which should also
-         be FB->COPIED_TEXT_BASE.  */
+         The new pristine is in NEW_TEXT_BASE_TMP_ABSPATH, which should also
+         be FB->COPIED_TEXT_BASE_ABSPATH.  */
       is_locally_modified = TRUE;
     }
   else if (entry && entry->file_external_path
@@ -4350,14 +4353,14 @@ merge_file(svn_stringbuf_t **log_accum,
                                                FALSE /* compare_textbases */,
                                                pool));
     }
-  else if (new_text_base_abspath)
+  else if (new_text_base_tmp_abspath)
     {
       /* We have a new pristine to install. Is the file modified relative
          to this new pristine?  */
       SVN_ERR(svn_wc__internal_versioned_file_modcheck(&is_locally_modified,
                                                        eb->db,
                                                        fb->local_abspath,
-                                                       new_text_base_abspath,
+                                                       new_text_base_tmp_abspath,
                                                        FALSE, pool));
     }
   else
@@ -4403,7 +4406,7 @@ merge_file(svn_stringbuf_t **log_accum,
    So the first thing we do is figure out where we are in the
    matrix. */
 
-  if (new_text_base_abspath)
+  if (new_text_base_tmp_abspath)
     {
       if (is_replaced)
         {
@@ -4527,7 +4530,7 @@ merge_file(svn_stringbuf_t **log_accum,
                         log_accum, &merge_outcome,
                         eb->db,
                         merge_left, NULL,
-                        new_text_base_abspath, NULL,
+                        new_text_base_tmp_abspath, NULL,
                         fb->local_abspath,
                         fb->copied_working_text,
                         oldrev_str, newrev_str, mine_str,
@@ -4617,10 +4620,10 @@ merge_file(svn_stringbuf_t **log_accum,
     }
 
   /* Deal with installation of the new textbase, if appropriate. */
-  if (new_text_base_abspath)
+  if (new_text_base_tmp_abspath)
     {
       SVN_ERR(install_text_base(log_accum, pb->local_abspath,
-                                new_text_base_abspath, fb->text_base_abspath,
+                                new_text_base_tmp_abspath, fb->text_base_abspath,
                                 pool, pool));
       tmp_entry.checksum = svn_checksum_to_cstring(actual_checksum, pool);
       flags |= SVN_WC__ENTRY_MODIFY_CHECKSUM;
@@ -4654,7 +4657,7 @@ merge_file(svn_stringbuf_t **log_accum,
                   fb->local_abspath, fb->last_changed_date,
                   pool, pool));
 
-      if ((new_text_base_abspath || magic_props_changed)
+      if ((new_text_base_tmp_abspath || magic_props_changed)
           && !fb->deleted)
         {
           /* Adjust entries file to match working file */
@@ -4680,7 +4683,7 @@ merge_file(svn_stringbuf_t **log_accum,
 
   if (merge_outcome == svn_wc_merge_conflict)
     *content_state = svn_wc_notify_state_conflicted;
-  else if (new_text_base_abspath)
+  else if (new_text_base_tmp_abspath)
     {
       if (is_locally_modified)
         *content_state = svn_wc_notify_state_merged;
@@ -4801,7 +4804,7 @@ close_file(void *file_baton,
   /* Was this an add-with-history, with no apply_textdelta? */
   if (fb->added_with_history && ! fb->received_textdelta)
     {
-      SVN_ERR_ASSERT(! fb->text_base_abspath && ! fb->new_text_base_abspath
+      SVN_ERR_ASSERT(! fb->text_base_abspath && ! fb->new_text_base_tmp_abspath
                      && fb->copied_text_base_abspath);
 
       /* Set up the base paths like apply_textdelta does. */
@@ -4810,8 +4813,8 @@ close_file(void *file_baton,
                                 eb->db, fb->local_abspath,
                                 fb->pool, pool));
 
-      md5_actual_checksum = fb->md5_copied_base_checksum;
-      sha1_actual_checksum = fb->sha1_copied_base_checksum;
+      md5_actual_checksum = fb->copied_text_base_md5_checksum;
+      sha1_actual_checksum = fb->copied_text_base_sha1_checksum;
       new_base_abspath = fb->copied_text_base_abspath;
       SVN_ERR_ASSERT(! new_base_abspath || svn_dirent_is_absolute(new_base_abspath));
     }
@@ -4819,9 +4822,9 @@ close_file(void *file_baton,
     {
       /* Pull the actual checksum from the file_baton, computed during
          the application of a text delta. */
-      md5_actual_checksum = fb->md5_actual_checksum;
-      sha1_actual_checksum = fb->sha1_actual_checksum;
-      new_base_abspath = fb->new_text_base_abspath;
+      md5_actual_checksum = fb->new_text_base_md5_checksum;
+      sha1_actual_checksum = fb->new_text_base_sha1_checksum;
+      new_base_abspath = fb->new_text_base_tmp_abspath;
     }
 
   /* window-handler assembles new pristine text in .svn/tmp/text-base/  */
@@ -4844,8 +4847,8 @@ close_file(void *file_baton,
      update all the BASE_NODE info to switch the file over and install a wq
      item to update the in-wc file. So in a few cases it is logical that the
      file operations are not side by side. */
-  if (fb->temp_pristine_abspath)
-    SVN_ERR(svn_wc__db_pristine_install(eb->db, fb->temp_pristine_abspath,
+  if (fb->new_pristine_tmp_abspath)
+    SVN_ERR(svn_wc__db_pristine_install(eb->db, fb->new_pristine_tmp_abspath,
                                         sha1_actual_checksum,
                                         md5_actual_checksum, pool));
 #endif



Mime
View raw message