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 2013/02/24 21:26:42 UTC

svn commit: r1449545 - in /subversion/trunk/subversion/libsvn_wc: wc_db.c wc_db.h

Author: rhuijben
Date: Sun Feb 24 20:26:42 2013
New Revision: 1449545

URL: http://svn.apache.org/r1449545
Log:
Add a special variant of svn_wc__db_wq_fetch_next() which not only retrieves
the next workqueue item, but also records the timestamp and size of one or
more files.

A second commit will start using this from the workqueue for the install wq
items, to combine the two most common db transactions during update and
checkout.

* subversion/libsvn_wc/wc_db.c
  (record_baton_t): Remove struct.
  (db_record_fileinfo): Use arguments for record values.
  (svn_wc__db_global_record_fileinfo): Update caller.
  (set_props_txn): Update caller.

  (wq_record): New function.
  (svn_wc__db_wq_record_and_fetch_next): New function.

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

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1449545&r1=1449544&r2=1449545&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sun Feb 24 20:26:42 2013
@@ -5569,28 +5569,21 @@ svn_wc__db_op_add_symlink(svn_wc__db_t *
   return SVN_NO_ERROR;
 }
 
-/* Baton for passing args to db_record_fileinfo(). */
-struct record_baton_t {
-  svn_filesize_t recorded_size;
-  apr_time_t recorded_time;
-};
-
-
 /* Record RECORDED_SIZE and RECORDED_TIME into top layer in NODES */
 static svn_error_t *
-db_record_fileinfo(void *baton,
-                   svn_wc__db_wcroot_t *wcroot,
+db_record_fileinfo(svn_wc__db_wcroot_t *wcroot,
                    const char *local_relpath,
+                   apr_int64_t recorded_size,
+                   apr_int64_t recorded_time,
                    apr_pool_t *scratch_pool)
 {
-  struct record_baton_t *rb = baton;
   svn_sqlite__stmt_t *stmt;
   int affected_rows;
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_UPDATE_NODE_FILEINFO));
   SVN_ERR(svn_sqlite__bindf(stmt, "isii", wcroot->wc_id, local_relpath,
-                            rb->recorded_size, rb->recorded_time));
+                            recorded_size, recorded_time));
   SVN_ERR(svn_sqlite__update(&affected_rows, stmt));
 
   SVN_ERR_ASSERT(affected_rows == 1);
@@ -5608,7 +5601,6 @@ svn_wc__db_global_record_fileinfo(svn_wc
 {
   svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
-  struct record_baton_t rb;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
@@ -5616,10 +5608,8 @@ svn_wc__db_global_record_fileinfo(svn_wc
                               local_abspath, scratch_pool, scratch_pool));
   VERIFY_USABLE_WCROOT(wcroot);
 
-  rb.recorded_size = recorded_size;
-  rb.recorded_time = recorded_time;
-
-  SVN_ERR(db_record_fileinfo(&rb, wcroot, local_relpath, scratch_pool));
+  SVN_ERR(db_record_fileinfo(wcroot, local_relpath,
+                             recorded_size, recorded_time, scratch_pool));
 
   /* We *totally* monkeyed the entries. Toss 'em.  */
   SVN_ERR(flush_entries(wcroot, local_abspath, svn_depth_empty, scratch_pool));
@@ -5704,10 +5694,9 @@ set_props_txn(svn_wc__db_wcroot_t *wcroo
 
   if (clear_recorded_info)
     {
-      struct record_baton_t rb;
-      rb.recorded_size = SVN_INVALID_FILESIZE;
-      rb.recorded_time = 0;
-      SVN_ERR(db_record_fileinfo(&rb, wcroot, local_relpath, scratch_pool));
+      SVN_ERR(db_record_fileinfo(wcroot, local_relpath,
+                                 SVN_INVALID_FILESIZE, 0,
+                                 scratch_pool));
     }
 
   /* And finally.  */
@@ -12550,6 +12539,70 @@ svn_wc__db_wq_fetch_next(apr_uint64_t *i
   return SVN_NO_ERROR;
 }
 
+/* Records timestamp and date for one or more files in wcroot */
+static svn_error_t *
+wq_record(svn_wc__db_wcroot_t *wcroot,
+          apr_hash_t *record_map,
+          apr_pool_t *scratch_pool)
+{
+  apr_hash_index_t *hi;
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+
+  for (hi = apr_hash_first(scratch_pool, record_map); hi;
+       hi = apr_hash_next(hi))
+    {
+      const char *local_abspath = svn__apr_hash_index_key(hi);
+      const svn_io_dirent2_t *dirent = svn__apr_hash_index_val(hi);
+      const char *local_relpath = svn_dirent_skip_ancestor(wcroot->abspath,
+                                                           local_abspath);
+
+      svn_pool_clear(iterpool);
+
+      if (! local_relpath)
+        continue;
+
+      SVN_ERR(db_record_fileinfo(wcroot, local_relpath,
+                                 dirent->filesize, dirent->mtime,
+                                 iterpool));
+    }
+
+  svn_pool_destroy(iterpool);
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__db_wq_record_and_fetch_next(apr_uint64_t *id,
+                                    svn_skel_t **work_item,
+                                    svn_wc__db_t *db,
+                                    const char *wri_abspath,
+                                    apr_uint64_t completed_id,
+                                    apr_hash_t *record_map,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool)
+{
+  svn_wc__db_wcroot_t *wcroot;
+  const char *local_relpath;
+
+  SVN_ERR_ASSERT(id != NULL);
+  SVN_ERR_ASSERT(work_item != NULL);
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
+
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
+                              wri_abspath, scratch_pool, scratch_pool));
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  SVN_WC__DB_WITH_TXN(
+    svn_error_compose_create(
+            wq_fetch_next(id, work_item,
+                          wcroot, local_relpath, completed_id,
+                          result_pool, scratch_pool),
+            wq_record(wcroot, record_map, scratch_pool)),
+    wcroot);
+
+  return SVN_NO_ERROR;
+}
+
+
 
 /* ### temporary API. remove before release.  */
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1449545&r1=1449544&r2=1449545&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Sun Feb 24 20:26:42 2013
@@ -2926,6 +2926,19 @@ svn_wc__db_wq_fetch_next(apr_uint64_t *i
                          apr_pool_t *result_pool,
                          apr_pool_t *scratch_pool);
 
+/* Special variant of svn_wc__db_wq_fetch_next(), which in the same transaction
+   also records timestamps and sizes for one or more nodes */
+svn_error_t *
+svn_wc__db_wq_record_and_fetch_next(apr_uint64_t *id,
+                                    svn_skel_t **work_item,
+                                    svn_wc__db_t *db,
+                                    const char *wri_abspath,
+                                    apr_uint64_t completed_id,
+                                    apr_hash_t *record_map,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool);
+
+
 /* @} */