Author: rhuijben
Date: Sun Mar 14 16:13:43 2010
New Revision: 922884

URL: http://svn.apache.org/viewvc?rev=922884&view=rev
Log:
Following up on r922839, replace the temporary start_directory_update()
function with a new temporary wc_db operation.

* subversion/libsvn_wc/update_editor.c
  (start_directory_update): Remove function.
  (open_root, open_directory):
    Use svn_wc__db_temp_op_start_directory_update.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_UPDATE_BASE_PRESENCE_AND_REVNUM): New query.
  (STMT_UPDATE_BASE_PRESENCE_REVNUM_AND_REPOS_RELPATH): New query.

* subversion/libsvn_wc/wc_db.c
  (start_directory_update_baton): New struct.
  (start_directory_update_txn): New function.
  (svn_wc__db_temp_op_start_directory_update): New function.

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

Modified:
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    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=922884&r1=922883&r2=922884&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Sun Mar 14 16:13:43 
2010
@@ -1338,38 +1338,6 @@ set_target_revision(void *edit_baton,
   return SVN_NO_ERROR;
 }
 
-/* Mark directory as being NEW_RELPATH at NEW_REV, but incomplete. */
-static svn_error_t *
-start_directory_update(svn_wc__db_t *db,
-                       const char *local_dir_abspath,
-                       const char *new_relpath,
-                       svn_revnum_t new_rev,
-                       apr_pool_t *scratch_pool)
-{
-  svn_wc_entry_t tmp_entry;
-  const char *repos_root;
-
-  SVN_ERR(svn_wc__db_scan_base_repos(NULL, &repos_root, NULL, db,
-                                     local_dir_abspath, scratch_pool,
-                                     scratch_pool));
-
-  tmp_entry.revision = new_rev;
-  tmp_entry.url = svn_path_url_add_component2(repos_root, new_relpath,
-                                              scratch_pool);
-
-  SVN_ERR(svn_wc__entry_modify2(db, local_dir_abspath, svn_node_dir,
-                                FALSE, &tmp_entry,
-                                SVN_WC__ENTRY_MODIFY_REVISION
-                                | SVN_WC__ENTRY_MODIFY_URL,
-                                scratch_pool));
-
-  SVN_ERR(svn_wc__db_temp_op_set_base_incomplete(db, local_dir_abspath,
-                                                 TRUE, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-
 /* An svn_delta_editor_t function. */
 static svn_error_t *
 open_root(void *edit_baton,
@@ -1442,9 +1410,11 @@ open_root(void *edit_baton,
 
       /* ### TODO: Skip if inside a conflicted tree. */
 
-      SVN_ERR(start_directory_update(eb->db, db->local_abspath,
-                                     db->new_relpath, *eb->target_revision,
-                                     pool));
+      SVN_ERR(svn_wc__db_temp_op_start_directory_update(eb->db,
+                                                        db->local_abspath,
+                                                        db->new_relpath,
+                                                        *eb->target_revision,
+                                                        pool));
     }
 
   return SVN_NO_ERROR;
@@ -3122,8 +3092,10 @@ open_directory(const char *path,
     }
 
   /* Mark directory as being at target_revision and URL, but incomplete. */
-  SVN_ERR(start_directory_update(eb->db, db->local_abspath, db->new_relpath,
-                                 *eb->target_revision, pool));
+  SVN_ERR(svn_wc__db_temp_op_start_directory_update(eb->db, db->local_abspath,
+                                                    db->new_relpath,
+                                                    *eb->target_revision,
+                                                    pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=922884&r1=922883&r2=922884&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Sun Mar 14 16:13:43 
2010
@@ -243,6 +243,14 @@ where wc_id = ?1 and local_relpath = ?2;
 update working_node set presence = ?3
 where wc_id = ?1 and local_relpath =?2;
 
+-- STMT_UPDATE_BASE_PRESENCE_AND_REVNUM
+update base_node set presence = ?3, revnum = ?4
+where wc_id = ?1 and local_relpath = ?2;
+
+-- STMT_UPDATE_BASE_PRESENCE_REVNUM_AND_REPOS_RELPATH
+update base_node set presence = ?3, revnum = ?4, repos_relpath = ?5
+where wc_id = ?1 and local_relpath = ?2;
+
 -- STMT_LOOK_FOR_WORK
 SELECT id FROM WORK_QUEUE LIMIT 1;
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=922884&r1=922883&r2=922884&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sun Mar 14 16:13:43 2010
@@ -6350,3 +6350,91 @@ svn_wc__db_temp_op_set_working_last_chan
 
   return SVN_NO_ERROR;
 }
+
+struct start_directory_update_baton
+{
+  svn_wc__db_t *db;
+  const char *local_abspath;
+  apr_int64_t wc_id;
+  const char *local_relpath;
+  svn_revnum_t new_rev;
+  const char *new_repos_relpath;
+};
+
+static svn_error_t *
+start_directory_update_txn(void *baton,
+                           svn_sqlite__db_t *db,
+                           apr_pool_t *scratch_pool)
+{
+  struct start_directory_update_baton *du = baton;
+  const char *repos_relpath;
+  svn_sqlite__stmt_t *stmt;
+
+  SVN_ERR(svn_wc__db_scan_base_repos(&repos_relpath, NULL, NULL,
+                                     du->db, du->local_abspath,
+                                     scratch_pool, scratch_pool));
+
+  if (strcmp(du->new_repos_relpath, repos_relpath) == 0)
+    {
+      /* Just update revision and status */
+      SVN_ERR(svn_sqlite__get_statement(
+                        &stmt, db,
+                        STMT_UPDATE_BASE_PRESENCE_AND_REVNUM));
+
+      SVN_ERR(svn_sqlite__bindf(stmt, "isti",
+                                du->wc_id,
+                                du->local_relpath,
+                                presence_map, svn_wc__db_status_incomplete,
+                                (apr_int64_t)du->new_rev));
+    }
+  else
+    {
+      /* ### TODO: Maybe check if we can make repos_relpath NULL. */
+      SVN_ERR(svn_sqlite__get_statement(
+                        &stmt, db,
+                        STMT_UPDATE_BASE_PRESENCE_REVNUM_AND_REPOS_RELPATH));
+
+      SVN_ERR(svn_sqlite__bindf(stmt, "istis",
+                                du->wc_id,
+                                du->local_relpath,
+                                presence_map, svn_wc__db_status_incomplete,
+                                (apr_int64_t)du->new_rev,
+                                du->new_repos_relpath));
+    }
+
+  return svn_error_return(svn_sqlite__step_done(stmt));
+}
+
+svn_error_t *
+svn_wc__db_temp_op_start_directory_update(svn_wc__db_t *db,
+                                          const char *local_abspath,
+                                          const char* new_repos_relpath,
+                                          svn_revnum_t new_rev,
+                                          apr_pool_t *scratch_pool)
+{
+  svn_wc__db_pdh_t *pdh;
+  struct start_directory_update_baton du;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+  SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(new_rev));
+  SVN_ERR_ASSERT(svn_relpath_is_canonical(new_repos_relpath, scratch_pool));
+
+  SVN_ERR(parse_local_abspath(&pdh, &du.local_relpath, db, local_abspath,
+                              svn_sqlite__mode_readwrite,
+                              scratch_pool, scratch_pool));
+  VERIFY_USABLE_PDH(pdh);
+
+  du.db = db;
+  du.wc_id = pdh->wcroot->wc_id;
+  du.local_abspath = local_abspath;
+  du.new_rev = new_rev;
+  du.new_repos_relpath = new_repos_relpath;
+
+  SVN_ERR(svn_sqlite__with_transaction(pdh->wcroot->sdb,
+                                       start_directory_update_txn, &du,
+                                       scratch_pool));
+
+  flush_entries(pdh);
+
+  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=922884&r1=922883&r2=922884&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Sun Mar 14 16:13:43 2010
@@ -2048,6 +2048,15 @@ svn_wc__db_temp_op_set_working_last_chan
                                            const char *changed_author,
                                            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 *
+svn_wc__db_temp_op_start_directory_update(svn_wc__db_t *db,
+                                          const char *local_abspath,
+                                          const char* new_repos_relpath,
+                                          svn_revnum_t new_rev,
+                                          apr_pool_t *scratch_pool);
+
 /** @} */
 
 


Reply via email to