You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2010/05/10 17:39:53 UTC

svn commit: r942792 - in /subversion/trunk/subversion/libsvn_wc: update_editor.c wc-queries.sql wc_db.c wc_db.h

Author: julianfoad
Date: Mon May 10 15:39:53 2010
New Revision: 942792

URL: http://svn.apache.org/viewvc?rev=942792&view=rev
Log:
Replace a use of svn_wc_entry_t with a new WC-NG function.  This fixes an
as-yet-unnoticed bug whereby the checksum of a file 'foo' that is copied
over an existing file 'bar' was written into both the WORKING_NODE (correct)
and the BASE_NODE.  The BASE_NODE checksum should be left unchanged, and now
is.

* subversion/libsvn_wc/update_editor.c
  (svn_wc_add_repos_file4): Use svn_wc__db_temp_op_set_working_checksum()
    instead of svn_wc__loggy_entry_modify().

* subversion/libsvn_wc/wc_db.h,
  subversion/libsvn_wc/wc_db.c
  (svn_wc__db_temp_op_set_working_checksum): New function.

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

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=942792&r1=942791&r2=942792&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Mon May 10 15:39:53 2010
@@ -6055,7 +6055,6 @@ svn_wc_add_repos_file4(svn_wc_context_t 
   if (copyfrom_url != NULL)
     {
       const char *text_base_abspath;
-      svn_wc_entry_t tmp_entry;
 
       /* Write out log commands to set up the new text base and its checksum.
          (Install it as the normal text base, not the 'revert base'.) */
@@ -6066,13 +6065,14 @@ svn_wc_add_repos_file4(svn_wc_context_t 
                                  pool));
       SVN_ERR(svn_wc__db_wq_add(db, dir_abspath, work_item, pool));
 
-      tmp_entry.checksum = svn_checksum_to_cstring(base_checksum, pool);
-
-      SVN_ERR(svn_wc__loggy_entry_modify(&work_item, db, dir_abspath,
-                                         local_abspath, &tmp_entry,
-                                         SVN_WC__ENTRY_MODIFY_CHECKSUM,
-                                         pool));
-      SVN_ERR(svn_wc__db_wq_add(db, dir_abspath, work_item, pool));
+      /* ### execute the work items which construct the node, allowing the
+         ### wc_db operation to tweak the WORKING_NODE row. these values
+         ### should be set some other way.  */
+      SVN_ERR(svn_wc__wq_run(db, dir_abspath,
+                             cancel_func, cancel_baton,
+                             pool));
+      SVN_ERR(svn_wc__db_temp_op_set_working_checksum(db, local_abspath,
+                                                      base_checksum, pool));
     }
 
   /* ### HACK: The following code should be performed in the same transaction as the install */

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=942792&r1=942791&r2=942792&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Mon May 10 15:39:53 2010
@@ -468,6 +468,10 @@ where wc_id = ?1 and local_relpath = ?2;
 update working_node set changed_rev = ?3, changed_date = ?4, changed_author = ?5
 where wc_id = ?1 and local_relpath = ?2;
 
+-- STMT_UPDATE_WORKING_CHECKSUM
+update working_node set checksum = ?3
+where wc_id = ?1 and local_relpath = ?2;
+
 
 /* ------------------------------------------------------------------------- */
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=942792&r1=942791&r2=942792&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Mon May 10 15:39:53 2010
@@ -6912,6 +6912,44 @@ svn_wc__db_temp_op_set_working_last_chan
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__db_temp_op_set_working_checksum(svn_wc__db_t *db,
+                                        const char *local_abspath,
+                                        const svn_checksum_t *checksum,
+                                        apr_pool_t *scratch_pool)
+{
+  svn_wc__db_pdh_t *pdh;
+  svn_sqlite__stmt_t *stmt;
+  const char *local_relpath;
+  int affected;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+  SVN_ERR(parse_local_abspath(&pdh, &local_relpath, db, local_abspath,
+                              svn_sqlite__mode_readwrite,
+                              scratch_pool, scratch_pool));
+  VERIFY_USABLE_PDH(pdh);
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+                                    STMT_UPDATE_WORKING_CHECKSUM));
+
+  SVN_ERR(svn_sqlite__bindf(stmt, "is",
+                            pdh->wcroot->wc_id, local_relpath));
+  SVN_ERR(svn_sqlite__bind_checksum(stmt, 3, checksum, scratch_pool));
+
+  SVN_ERR(svn_sqlite__update(&affected, stmt));
+
+  if (affected != 1)
+    return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                             _("'%s' has no WORKING_NODE"),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+
+  flush_entries(pdh);
+
+  return SVN_NO_ERROR;
+}
+
 struct start_directory_update_baton
 {
   svn_wc__db_t *db;

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=942792&r1=942791&r2=942792&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Mon May 10 15:39:53 2010
@@ -2249,6 +2249,14 @@ svn_wc__db_temp_op_set_working_last_chan
                                            const char *changed_author,
                                            apr_pool_t *scratch_pool);
 
+/* Set the pristine text checksum of the WORKING_NODE of LOCAL_ABSPATH in DB
+   to CHECKSUM. */
+svn_error_t *
+svn_wc__db_temp_op_set_working_checksum(svn_wc__db_t *db,
+                                        const char *local_abspath,
+                                        const svn_checksum_t *checksum,
+                                        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 *