You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/03/29 11:52:57 UTC

svn commit: r1462440 - /subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c

Author: stefan2
Date: Fri Mar 29 10:52:57 2013
New Revision: 1462440

URL: http://svn.apache.org/r1462440
Log:
On the fsfs-format7 branch:  Do a bit of refactoring by moving common
code into a separate function.

* subversion/libsvn_fs_fs/transaction.c
  (digests_final): new utility function
  (rep_write_contents_close,
   write_hash_rep,
   write_hash_delta_rep): use the new utility

Modified:
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c?rev=1462440&r1=1462439&r2=1462440&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c Fri Mar 29 10:52:57 2013
@@ -2090,6 +2090,21 @@ get_shared_rep(representation_t **old_re
   return SVN_NO_ERROR;
 }
 
+/* Copy the hash sum calculation results from MD5_CTX, SHA1_CTX into REP.
+ * Use POOL for allocations.
+ */
+static svn_error_t *
+digests_final(representation_t *rep,
+              const svn_checksum_ctx_t *md5_ctx,
+              const svn_checksum_ctx_t *sha1_ctx,
+              apr_pool_t *pool)
+{
+  SVN_ERR(svn_checksum_final(&rep->md5_checksum, md5_ctx, pool));
+  SVN_ERR(svn_checksum_final(&rep->sha1_checksum, sha1_ctx, pool));
+
+  return SVN_NO_ERROR;
+}
+
 /* Close handler for the representation write stream.  BATON is a
    rep_write_baton.  Writes out a new node-rev that correctly
    references the representation we just finished writing. */
@@ -2119,10 +2134,8 @@ rep_write_contents_close(void *baton)
   rep->revision = SVN_INVALID_REVNUM;
 
   /* Finalize the checksum. */
-  SVN_ERR(svn_checksum_final(&rep->md5_checksum, b->md5_checksum_ctx,
-                              b->parent_pool));
-  SVN_ERR(svn_checksum_final(&rep->sha1_checksum, b->sha1_checksum_ctx,
-                              b->parent_pool));
+  SVN_ERR(digests_final(rep, b->md5_checksum_ctx, b->sha1_checksum_ctx,
+                        b->parent_pool));
 
   /* Check and see if we already have a representation somewhere that's
      identical to the one we just wrote out. */
@@ -2388,8 +2401,7 @@ write_hash_rep(representation_t *rep,
   SVN_ERR(svn_hash_write2(hash, stream, SVN_HASH_TERMINATOR, pool));
 
   /* Store the results. */
-  SVN_ERR(svn_checksum_final(&rep->md5_checksum, whb->md5_ctx, pool));
-  SVN_ERR(svn_checksum_final(&rep->sha1_checksum, whb->sha1_ctx, pool));
+  SVN_ERR(digests_final(rep, whb->md5_ctx, whb->sha1_ctx, pool));
 
   /* Check and see if we already have a representation somewhere that's
      identical to the one we just wrote out. */
@@ -2516,8 +2528,7 @@ write_hash_delta_rep(representation_t *r
   SVN_ERR(svn_stream_close(whb->stream));
 
   /* Store the results. */
-  SVN_ERR(svn_checksum_final(&rep->md5_checksum, whb->md5_ctx, pool));
-  SVN_ERR(svn_checksum_final(&rep->sha1_checksum, whb->sha1_ctx, pool));
+  SVN_ERR(digests_final(rep, whb->md5_ctx, whb->sha1_ctx, pool));
 
   /* Check and see if we already have a representation somewhere that's
      identical to the one we just wrote out. */