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 2011/04/08 16:00:22 UTC

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

Author: rhuijben
Date: Fri Apr  8 14:00:21 2011
New Revision: 1090253

URL: http://svn.apache.org/viewvc?rev=1090253&view=rev
Log:
Remove a tiny race condition and some disk io by using one transaction instead
of two. Remove always FALSE argument.

* subversion/libsvn_wc/update_editor.c
  (complete_directory): Update caller.

* subversion/libsvn_wc/wc_db.c
  (end_directory_update): New function extracted from ...
  (svn_wc__db_temp_op_set_base_incomplete): ... this, which was renamed to
  (svn_wc__db_temp_op_end_directory_update): ... this.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_temp_op_set_base_incomplete): Renamed this function to ...
  (svn_wc__db_temp_op_end_directory_update): ... this.

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

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1090253&r1=1090252&r2=1090253&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Fri Apr  8 14:00:21 2011
@@ -705,8 +705,8 @@ complete_directory(struct edit_baton *eb
     }
 
   /* Mark THIS_DIR complete. */
-  SVN_ERR(svn_wc__db_temp_op_set_base_incomplete(eb->db, local_abspath, FALSE,
-                                                 scratch_pool));
+  SVN_ERR(svn_wc__db_temp_op_end_directory_update(eb->db, local_abspath,
+                                                  scratch_pool));
 
   if (eb->depth_is_sticky)
     {

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1090253&r1=1090252&r2=1090253&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri Apr  8 14:00:21 2011
@@ -9384,25 +9384,15 @@ svn_wc__db_wclock_owns_lock(svn_boolean_
   return SVN_NO_ERROR;
 }
 
-
-svn_error_t *
-svn_wc__db_temp_op_set_base_incomplete(svn_wc__db_t *db,
-                                       const char *local_dir_abspath,
-                                       svn_boolean_t incomplete,
-                                       apr_pool_t *scratch_pool)
+/* Lock helper for svn_wc__db_temp_op_end_directory_update */
+static svn_error_t *
+end_directory_update(void *baton,
+                     svn_wc__db_wcroot_t *wcroot,
+                     const char *local_relpath,
+                     apr_pool_t *scratch_pool)
 {
   svn_sqlite__stmt_t *stmt;
-  int affected_rows;
-  int affected_node_rows;
   svn_wc__db_status_t base_status;
-  svn_wc__db_wcroot_t *wcroot;
-  const char *local_relpath;
-
-  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_dir_abspath));
-
-  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
-                              local_dir_abspath, scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(wcroot);
 
   SVN_ERR(base_get_info(&base_status, NULL, NULL, NULL, NULL, NULL,
                         NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -9413,14 +9403,31 @@ svn_wc__db_temp_op_set_base_incomplete(s
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_UPDATE_NODE_BASE_PRESENCE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "iss", wcroot->wc_id, local_relpath,
-                            incomplete ? "incomplete" : "normal"));
-  SVN_ERR(svn_sqlite__update(&affected_node_rows, stmt));
+  SVN_ERR(svn_sqlite__bindf(stmt, "ist", wcroot->wc_id, local_relpath,
+                            presence_map, svn_wc__db_status_normal));
+  SVN_ERR(svn_sqlite__step_done(stmt));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__db_temp_op_end_directory_update(svn_wc__db_t *db,
+                                        const char *local_dir_abspath,
+                                        apr_pool_t *scratch_pool)
+{
+  svn_wc__db_wcroot_t *wcroot;
+  const char *local_relpath;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_dir_abspath));
+
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
+                              local_dir_abspath, scratch_pool, scratch_pool));
+  VERIFY_USABLE_WCROOT(wcroot);
 
-  affected_rows = affected_node_rows;
+  SVN_ERR(svn_wc__db_with_txn(wcroot, local_relpath, end_directory_update,
+                              NULL, scratch_pool));
 
-  if (affected_rows > 0)
-    SVN_ERR(flush_entries(wcroot, local_dir_abspath, scratch_pool));
+  SVN_ERR(flush_entries(wcroot, local_dir_abspath, scratch_pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1090253&r1=1090252&r2=1090253&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Fri Apr  8 14:00:21 2011
@@ -2512,12 +2512,6 @@ svn_wc__db_temp_wcroot_tempdir(const cha
                                apr_pool_t *result_pool,
                                apr_pool_t *scratch_pool);
 
-svn_error_t *
-svn_wc__db_temp_op_set_base_incomplete(svn_wc__db_t *db,
-                                       const char *local_dir_abspath,
-                                       svn_boolean_t incomplete,
-                                       apr_pool_t *scratch_pool);
-
 /* Update the BASE_NODE of directory LOCAL_ABSPATH to be NEW_REPOS_RELPATH
    at revision NEW_REV with status incomplete. */
 svn_error_t *
@@ -2527,6 +2521,15 @@ svn_wc__db_temp_op_start_directory_updat
                                           svn_revnum_t new_rev,
                                           apr_pool_t *scratch_pool);
 
+/* Marks a directory update started with
+   svn_wc__db_temp_op_start_directory_update as completed, by removing
+   the incomplete status */
+svn_error_t *
+svn_wc__db_temp_op_end_directory_update(svn_wc__db_t *db,
+                                        const char *local_dir_abspath,
+                                        apr_pool_t *scratch_pool);
+
+
 /* Copy the base tree at LOCAL_ABSPATH into the working tree as copy,
    leaving any subtree additions and copies as-is.  This allows the
    base node tree to be removed. */