subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1544719 - /subversion/trunk/subversion/libsvn_fs_fs/transaction.c
Date Sat, 23 Nov 2013 00:21:59 GMT
Author: stefan2
Date: Sat Nov 23 00:21:59 2013
New Revision: 1544719

URL: http://svn.apache.org/r1544719
Log:
When we create a FSFS transaction, we are the first ones to set revprops
on it.  So, let's write them directly to disk instead of trying to read
previous file contents.

The new code does not only avoid the creation of expensive error objects
but also introduces setter for revprops as a symmetric counterpart to
get_txn_proplist.

* subversion/libsvn_fs_fs/transaction.c
  (set_txn_proplist): new function with code taken from ...
  (svn_fs_fs__change_txn_props): ... this one; call new function
  (svn_fs_fs__begin_txn): set initial revprops instead of updating them

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1544719&r1=1544718&r2=1544719&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Sat Nov 23 00:21:59 2013
@@ -1133,6 +1133,31 @@ get_txn_proplist(apr_hash_t *proplist,
   return svn_stream_close(stream);
 }
 
+/* Save the property list PROPS as the revprops for transaction TXN_ID
+   in FS.  Perform temporary allocations in POOL. */
+static svn_error_t *
+set_txn_proplist(svn_fs_t *fs,
+                 const svn_fs_fs__id_part_t *txn_id,
+                 apr_hash_t *props,
+                 apr_pool_t *pool)
+{
+  svn_stringbuf_t *buf;
+  svn_stream_t *stream;
+
+  /* Write out the new file contents to BUF. */
+  buf = svn_stringbuf_create_ensure(1024, pool);
+  stream = svn_stream_from_stringbuf(buf, pool);
+  SVN_ERR(svn_hash_write2(props, stream, SVN_HASH_TERMINATOR, pool));
+  SVN_ERR(svn_stream_close(stream));
+
+  /* Open the transaction properties file and write new contents to it. */
+  SVN_ERR(svn_io_write_atomic(path_txn_props(fs, txn_id, pool),
+                              buf->data, buf->len,
+                              NULL /* copy_perms_path */, pool));
+  return SVN_NO_ERROR;
+}
+
+
 svn_error_t *
 svn_fs_fs__change_txn_prop(svn_fs_txn_t *txn,
                            const char *name,
@@ -1155,8 +1180,6 @@ svn_fs_fs__change_txn_props(svn_fs_txn_t
                             apr_pool_t *pool)
 {
   fs_txn_data_t *ftd = txn->fsap_data;
-  svn_stringbuf_t *buf;
-  svn_stream_t *stream;
   apr_hash_t *txn_prop = apr_hash_make(pool);
   int i;
   svn_error_t *err;
@@ -1180,13 +1203,8 @@ svn_fs_fs__change_txn_props(svn_fs_txn_t
 
   /* Create a new version of the file and write out the new props. */
   /* Open the transaction properties file. */
-  buf = svn_stringbuf_create_ensure(1024, pool);
-  stream = svn_stream_from_stringbuf(buf, pool);
-  SVN_ERR(svn_hash_write2(txn_prop, stream, SVN_HASH_TERMINATOR, pool));
-  SVN_ERR(svn_stream_close(stream));
-  SVN_ERR(svn_io_write_atomic(path_txn_props(txn->fs, &ftd->txn_id, pool),
-                              buf->data, buf->len,
-                              NULL /* copy_perms_path */, pool));
+  SVN_ERR(set_txn_proplist(txn->fs, &ftd->txn_id, txn_prop, pool));
+
   return SVN_NO_ERROR;
 }
 
@@ -3504,8 +3522,8 @@ svn_fs_fs__begin_txn(svn_fs_txn_t **txn_
                      apr_pool_t *pool)
 {
   svn_string_t date;
-  svn_prop_t prop;
-  apr_array_header_t *props = apr_array_make(pool, 3, sizeof(svn_prop_t));
+  fs_txn_data_t *ftd;
+  apr_hash_t *props = apr_hash_make(pool);
 
   SVN_ERR(svn_fs__check_fs(fs, TRUE));
 
@@ -3519,25 +3537,18 @@ svn_fs_fs__begin_txn(svn_fs_txn_t **txn_
   date.data = svn_time_to_cstring(apr_time_now(), pool);
   date.len = strlen(date.data);
 
-  prop.name = SVN_PROP_REVISION_DATE;
-  prop.value = &date;
-  APR_ARRAY_PUSH(props, svn_prop_t) = prop;
+  svn_hash_sets(props, SVN_PROP_REVISION_DATE, &date);
 
   /* Set temporary txn props that represent the requested 'flags'
      behaviors. */
   if (flags & SVN_FS_TXN_CHECK_OOD)
-    {
-      prop.name = SVN_FS__PROP_TXN_CHECK_OOD;
-      prop.value = svn_string_create("true", pool);
-      APR_ARRAY_PUSH(props, svn_prop_t) = prop;
-    }
+    svn_hash_sets(props, SVN_FS__PROP_TXN_CHECK_OOD,
+                  svn_string_create("true", pool));
 
   if (flags & SVN_FS_TXN_CHECK_LOCKS)
-    {
-      prop.name = SVN_FS__PROP_TXN_CHECK_LOCKS;
-      prop.value = svn_string_create("true", pool);
-      APR_ARRAY_PUSH(props, svn_prop_t) = prop;
-    }
+    svn_hash_sets(props, SVN_FS__PROP_TXN_CHECK_LOCKS,
+                  svn_string_create("true", pool));
 
-  return svn_fs_fs__change_txn_props(*txn_p, props, pool);
+  ftd = (*txn_p)->fsap_data;
+  return svn_error_trace(set_txn_proplist(fs, &ftd->txn_id, props, pool));
 }



Mime
View raw message