Author: rhuijben
Date: Fri Mar 18 11:53:24 2011
New Revision: 1082875

URL: http://svn.apache.org/viewvc?rev=1082875&view=rev
Log:
When retrieving the current set of properties in the db layer, just use one
read transaction instead of two in case the properties are not locally
modified.

* subversion/libsvn_wc/wc_db.c
  (db_read_props_baton_t): New struct.
  (svn_wc__db_read_props): Rename to ...
  (db_read_props): ... this and implement svn_wc__db_txn_callback_t.
  (svn_wc__db_read_props): New function around db_read_props.

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

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1082875&r1=1082874&r2=1082875&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri Mar 18 11:53:24 2011
@@ -5349,26 +5349,26 @@ svn_wc__db_read_url(const char **url,
                                    scratch_pool));
 }
 
+/* Baton for db_read_props */
+struct db_read_props_baton_t
+{
+  apr_hash_t *props;
+  apr_pool_t *result_pool;
+};
 
-svn_error_t *
-svn_wc__db_read_props(apr_hash_t **props,
-                      svn_wc__db_t *db,
-                      const char *local_abspath,
-                      apr_pool_t *result_pool,
-                      apr_pool_t *scratch_pool)
+
+/* Helper for svn_wc__db_read_props(). Implements svn_wc__db_txn_callback_t */
+static svn_error_t *
+db_read_props(void *baton,
+              svn_wc__db_wcroot_t *wcroot,
+              const char *local_relpath,
+              apr_pool_t *scratch_pool)
 {
-  svn_wc__db_wcroot_t *wcroot;
-  const char *local_relpath;
+  struct db_read_props_baton_t *rpb = baton;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
   svn_error_t *err = NULL;
 
-  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
-
-  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
-                              local_abspath, scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(wcroot);
-
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_SELECT_ACTUAL_PROPS));
   SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
@@ -5376,8 +5376,8 @@ svn_wc__db_read_props(apr_hash_t **props
 
   if (have_row && !svn_sqlite__column_is_null(stmt, 0))
     {
-      err = svn_sqlite__column_properties(props, stmt, 0, result_pool,
-                                          scratch_pool);
+      err = svn_sqlite__column_properties(&rpb->props, stmt, 0,
+                                          rpb->result_pool, scratch_pool);
     }
   else
     have_row = FALSE;
@@ -5388,21 +5388,49 @@ svn_wc__db_read_props(apr_hash_t **props
     return SVN_NO_ERROR;
 
   /* No local changes. Return the pristine props for this node.  */
-  SVN_ERR(db_read_pristine_props(props, wcroot, local_relpath,
-                                 result_pool, scratch_pool));
-  if (*props == NULL)
+  SVN_ERR(db_read_pristine_props(&rpb->props, wcroot, local_relpath,
+                                 rpb->result_pool, scratch_pool));
+  if (rpb->props == NULL)
     {
       /* Pristine properties are not defined for this node.
          ### we need to determine whether this node is in a state that
          ### allows for ACTUAL properties (ie. not deleted). for now,
          ### just say all nodes, no matter the state, have at least an
          ### empty set of props.  */
-      *props = apr_hash_make(result_pool);
+      rpb->props = apr_hash_make(rpb->result_pool);
     }
 
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__db_read_props(apr_hash_t **props,
+                      svn_wc__db_t *db,
+                      const char *local_abspath,
+                      apr_pool_t *result_pool,
+                      apr_pool_t *scratch_pool)
+{
+  svn_wc__db_wcroot_t *wcroot;
+  const char *local_relpath;
+  struct db_read_props_baton_t rpb;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
+                              local_abspath, scratch_pool, scratch_pool));
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  rpb.result_pool = result_pool;
+
+  SVN_ERR(svn_wc__db_with_txn(wcroot, local_relpath, db_read_props, &rpb,
+                              scratch_pool));
+
+  *props = rpb.props;
+
+  return SVN_NO_ERROR;
+}
+
+
 
 /* Call RECEIVER_FUNC, passing RECEIVER_BATON, an absolute path, and
    a hash table mapping <tt>char *</tt> names onto svn_string_t *


Reply via email to