You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2010/03/30 23:29:07 UTC

svn commit: r929302 - in /subversion/trunk/subversion/libsvn_wc: adm_crawler.c props.c wc-queries.sql wc_db.c wc_db.h workqueue.c

Author: gstein
Date: Tue Mar 30 21:29:07 2010
New Revision: 929302

URL: http://svn.apache.org/viewvc?rev=929302&view=rev
Log:
Use the new svn_wc__db_global_record_fileinfo() function where possible.
This obsoletes the db_op_set_last_mod_time() API.

In addition, to restore a file, use the new OP_FILE_INSTALL to do the work
(which records fileinfo properly).

* subversion/libsvn_wc/adm_crawler.c:
  (restore_file): gut this out, replacing the contents with building an
    OP_FILE_INSTALL work item, queueing it, and running it. retain the
    part that clears text conflicts.

* subversion/libsvn_wc/props.c:
  (svn_wc__internal_propset): invalidate the TRANSLATED_SIZE and the
    LAST_MOD_TIME upon certain prop changes. the old code only invalidated
    the time, but both should really be done. update the comments.

* subversion/libsvn_wc/workqueue.c:
  (log_do_committed): use the new API rather than entry_modify2(). tighten
    the scope of tmp_entry to the remaining place where it is used.
  (run_file_install): write code to use the new API, but leave it unused
    for now, as it breaks a merge test (some deep bad voodoo).

* subversion/libsvn_wc/wc_db.h:
* subversion/libsvn_wc/wc_db.c:
  (svn_wc__db_op_set_last_mod_time): removed

* subversion/libsvn_wc/wc-queries.sql:
  (STMT_UPDATE_BASE_LAST_MOD_TIME): removed

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_crawler.c
    subversion/trunk/subversion/libsvn_wc/props.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
    subversion/trunk/subversion/libsvn_wc/workqueue.c

Modified: subversion/trunk/subversion/libsvn_wc/adm_crawler.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_crawler.c?rev=929302&r1=929301&r2=929302&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_crawler.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_crawler.c Tue Mar 30 21:29:07 2010
@@ -47,6 +47,7 @@
 #include "translate.h"
 #include "entries.h"
 #include "lock.h"
+#include "workqueue.h"
 
 #include "svn_private_config.h"
 
@@ -66,108 +67,32 @@ static svn_error_t *
 restore_file(svn_wc__db_t *db,
              const char *local_abspath,
              svn_boolean_t use_commit_times,
-             apr_pool_t *pool)
+             apr_pool_t *scratch_pool)
 {
-  svn_stream_t *src_stream;
-  svn_boolean_t special;
-  apr_time_t text_time;
-
-  SVN_ERR(svn_wc__get_pristine_contents(&src_stream, db, local_abspath, pool,
-                                        pool));
-  if (src_stream == NULL)
-    /* Nothing to restore. */
-    return SVN_NO_ERROR;
-
-  SVN_ERR(svn_wc__get_special(&special, db, local_abspath, pool));
-  if (special)
-    {
-      svn_stream_t *dst_stream;
-
-      /* Copy the source into the destination to create the special file.
-         The creation wil happen atomically. */
-      SVN_ERR(svn_subst_create_specialfile(&dst_stream, local_abspath,
-                                           pool, pool));
-      /* ### need a cancel_func/baton */
-      SVN_ERR(svn_stream_copy3(src_stream, dst_stream, NULL, NULL, pool));
-    }
-  else
-    {
-      svn_subst_eol_style_t style;
-      const char *eol_str;
-      apr_hash_t *keywords;
-      const char *tmp_dir;
-      const char *tmp_file;
-      svn_stream_t *tmp_stream;
-
-      SVN_ERR(svn_wc__get_eol_style(&style, &eol_str, db, local_abspath,
-                                    pool, pool));
-      SVN_ERR(svn_wc__get_keywords(&keywords, db, local_abspath, NULL, pool,
-                                   pool));
-
-      /* Get a temporary destination so we can use a rename to create the
-         real destination atomically. */
-      SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmp_dir, db, local_abspath,
-                                             pool, pool));
-      SVN_ERR(svn_stream_open_unique(&tmp_stream, &tmp_file, tmp_dir,
-                                     svn_io_file_del_none, pool, pool));
-
-      /* Wrap the (temp) destination stream with a translating stream. */
-      if (svn_subst_translation_required(style, eol_str, keywords,
-                                         FALSE /* special */,
-                                         TRUE /* force_eol_check */))
-        {
-          tmp_stream = svn_subst_stream_translated(tmp_stream,
-                                                   eol_str,
-                                                   TRUE /* repair */,
-                                                   keywords,
-                                                   TRUE /* expand */,
-                                                   pool);
-        }
+  const svn_skel_t *work_item;
 
-      SVN_ERR(svn_stream_copy3(src_stream, tmp_stream, NULL, NULL, pool));
-      /* ### need a cancel_func/baton */
-      SVN_ERR(svn_io_file_rename(tmp_file, local_abspath, pool));
-    }
-
-  SVN_ERR(svn_wc__maybe_set_read_only(NULL, db, local_abspath, pool));
-
-  /* If necessary, tweak the new working file's executable bit. */
-  SVN_ERR(svn_wc__maybe_set_executable(NULL, db, local_abspath, pool));
+  SVN_ERR(svn_wc__wq_build_file_install(&work_item,
+                                        db, local_abspath,
+                                        use_commit_times,
+                                        TRUE /* record_fileinfo */,
+                                        scratch_pool, scratch_pool));
+  /* ### we need an existing path for wq_add. not entirely WRI_ABSPATH yet  */
+  SVN_ERR(svn_wc__db_wq_add(db,
+                            svn_dirent_dirname(local_abspath, scratch_pool),
+                            work_item, scratch_pool));
+
+  /* Run the work item immediately.  */
+  SVN_ERR(svn_wc__wq_run(db, local_abspath,
+                         NULL, NULL, /* ### nice to have cancel_func/baton */
+                         scratch_pool));
 
   /* Remove any text conflict */
   SVN_ERR(svn_wc__internal_resolved_conflict(
                     db, local_abspath, svn_depth_empty, TRUE, NULL, FALSE,
                     svn_wc_conflict_choose_merged, NULL, NULL, NULL, NULL,
-                    pool));
-
-  /* Possibly set timestamp to last-commit-time. */
-  if (use_commit_times && (! special))
-    {
-      apr_time_t changed_date;
+                    scratch_pool));
 
-      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL,
-                                   NULL, NULL, NULL,
-                                   NULL, &changed_date, NULL,
-                                   NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL,
-                                   NULL, NULL, NULL,
-                                   db, local_abspath,
-                                   pool, pool));
-
-      SVN_ERR(svn_io_set_file_affected_time(changed_date, local_abspath,
-                                            pool));
-
-      text_time = changed_date;
-    }
-  else
-    {
-      SVN_ERR(svn_io_file_affected_time(&text_time, local_abspath, pool));
-    }
-
-  /* Modify our entry's text-timestamp to match the working file. */
-  return svn_error_return(
-    svn_wc__db_op_set_last_mod_time(db, local_abspath, text_time, pool));
+  return SVN_NO_ERROR;
 }
 
 /* Try to restore LOCAL_ABSPATH of node type KIND and if successfull,

Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=929302&r1=929301&r2=929302&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Tue Mar 30 21:29:07 2010
@@ -2167,16 +2167,24 @@ svn_wc__internal_propset(svn_wc__db_t *d
       if (svn_subst_keywords_differ2(old_keywords, new_keywords, FALSE,
                                      scratch_pool))
         {
-          /* NOTE: this change is immediate. If the overall propset fails,
-             then we end up with an un-cached text_time. Big whoop.  */
-
-          /* If we changed the keywords or newlines, void the entry
-             timestamp for this file, so svn_wc_text_modified_p() does
-             a real (albeit slow) check later on. */
-          /* Setting the last mod time to zero will effectively invalidate
-             it's value. */
-          SVN_ERR(svn_wc__db_op_set_last_mod_time(db, local_abspath, 0,
-                                                  scratch_pool));
+          /* If the keywords have changed, then the translation of the file
+             may be different. We should invalidate the cached TRANSLATED_SIZE
+             and LAST_MOD_TIME on this node.
+
+             Note that we don't immediately re-translate the file. But a
+             "has it changed?" check in the future will do a translation
+             from the pristine, and it will want to compare the (new)
+             resulting TRANSLATED_SIZE against the working copy file.
+
+             Also, when this file is (de)translated with the new keywords,
+             then it could be different, relative to the pristine. We want
+             to ensure the LAST_MOD_TIME is different, to indicate that
+             a full detranslate/compare is performed.  */
+          /* ### we should be performing similar logic for changes to the
+             ### svn:eol-style property.  */
+          SVN_ERR(svn_wc__db_global_record_fileinfo(db, local_abspath,
+                                                    SVN_INVALID_FILESIZE, 0,
+                                                    scratch_pool));
         }
     }
 

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=929302&r1=929301&r2=929302&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Tue Mar 30 21:29:07 2010
@@ -186,10 +186,6 @@ where repos_id = ?1 and
   (repos_relpath = ?2 or
    repos_relpath like ?3 escape '#');
 
--- STMT_UPDATE_BASE_LAST_MOD_TIME
-update base_node set last_mod_time = ?3
-where wc_id = ?1 and local_relpath = ?2;
-
 -- STMT_UPDATE_BASE_FILEINFO
 UPDATE BASE_NODE SET translated_size = ?3, last_mod_time = ?4
 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=929302&r1=929301&r2=929302&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Mar 30 21:29:07 2010
@@ -3100,35 +3100,6 @@ svn_wc__db_op_revert(svn_wc__db_t *db,
   NOT_IMPLEMENTED();
 }
 
-svn_error_t *
-svn_wc__db_op_set_last_mod_time(svn_wc__db_t *db,
-                                const char *local_abspath,
-                                apr_time_t last_mod_time,
-                                apr_pool_t *scratch_pool)
-{
-  svn_wc__db_pdh_t *pdh;
-  const char *local_relpath;
-  svn_sqlite__stmt_t *stmt;
-
-  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_BASE_LAST_MOD_TIME));
-  SVN_ERR(svn_sqlite__bindf(stmt, "isi",
-                            pdh->wcroot->wc_id, local_relpath,
-                            last_mod_time));
-  SVN_ERR(svn_sqlite__step_done(stmt));
-
-  flush_entries(pdh);
-
-  return SVN_NO_ERROR;
-}
-
 
 svn_error_t *
 svn_wc__db_op_read_tree_conflict(

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=929302&r1=929301&r2=929302&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Tue Mar 30 21:29:07 2010
@@ -1039,18 +1039,6 @@ svn_wc__db_op_revert(svn_wc__db_t *db,
                      apr_pool_t *scratch_pool);
 
 
-/* Set the last mod time cache to LAST_MOD_TIME for the appropriate BASE
-   node for LOCAL_ABSPATH in DB.
-
-   Use SCRATCH_POOL for any temporary allocations.
-*/
-svn_error_t *
-svn_wc__db_op_set_last_mod_time(svn_wc__db_t *db,
-                                const char *local_abspath,
-                                apr_time_t last_mod_time,
-                                apr_pool_t *scratch_pool);
-
-
 /* Get any tree conflict associated with LOCAL_ABSPATH in DB, and put it
    in *TREE_CONFLICT, allocated in RESULT_POOL.
 

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=929302&r1=929301&r2=929302&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Tue Mar 30 21:29:07 2010
@@ -1263,7 +1263,6 @@ log_do_committed(svn_wc__db_t *db,
   svn_boolean_t set_read_write = FALSE;
   const svn_wc_entry_t *orig_entry;
   svn_boolean_t prop_mods;
-  svn_wc_entry_t tmp_entry;
 
   /*** Perform sanity checking operations ***/
 
@@ -1389,6 +1388,8 @@ log_do_committed(svn_wc__db_t *db,
     {
       svn_boolean_t overwrote_working;
       apr_finfo_t finfo;
+      svn_filesize_t translated_size;
+      apr_time_t last_mod_time;
 
       SVN_ERR(svn_wc__db_global_commit(db, local_abspath,
                                        new_revision, new_date, new_author,
@@ -1425,12 +1426,12 @@ log_do_committed(svn_wc__db_t *db,
 
       /* We will compute and modify the size and timestamp */
 
-      tmp_entry.working_size = finfo.size;
-
-      /* ### svn_wc__db_op_set_last_mod_time()  */
+      translated_size = finfo.size;
 
       if (overwrote_working)
-        tmp_entry.text_time = finfo.mtime;
+        {
+          last_mod_time = finfo.mtime;
+        }
       else
         {
           /* The working copy file hasn't been overwritten, meaning
@@ -1477,15 +1478,12 @@ log_do_committed(svn_wc__db_t *db,
             }
           /* If they are the same, use the working file's timestamp,
              else use the base file's timestamp. */
-          tmp_entry.text_time = modified ? basef_finfo.mtime : finfo.mtime;
+          last_mod_time = modified ? basef_finfo.mtime : finfo.mtime;
         }
 
-      return svn_error_return(svn_wc__entry_modify2(
+      return svn_error_return(svn_wc__db_global_record_fileinfo(
                                 db, local_abspath,
-                                svn_node_unknown, FALSE,
-                                &tmp_entry,
-                                SVN_WC__ENTRY_MODIFY_WORKING_SIZE
-                                | SVN_WC__ENTRY_MODIFY_TEXT_TIME,
+                                translated_size, last_mod_time,
                                 pool));
     }
 
@@ -1516,6 +1514,7 @@ log_do_committed(svn_wc__db_t *db,
   /* Make sure our entry exists in the parent. */
   {
     const svn_wc_entry_t *dir_entry;
+    svn_wc_entry_t tmp_entry;
 
     /* Check if we have a valid record in our parent */
     SVN_ERR(svn_wc__get_entry(&dir_entry, db, local_abspath,
@@ -2021,15 +2020,14 @@ run_file_install(svn_wc__db_t *db,
                                               scratch_pool));
     }
 
+  /* ### this should happen before we rename the file into place.  */
   if (record_fileinfo)
     {
-      /* ### ugh. switch this over to some new wc_db APIs.  */
-
-      svn_wc_entry_t tmp_entry;
+      apr_time_t last_mod_time;
       apr_finfo_t finfo;
 
       /* loggy_set_entry_timestamp_from_wc()  */
-      SVN_ERR(svn_io_file_affected_time(&tmp_entry.text_time,
+      SVN_ERR(svn_io_file_affected_time(&last_mod_time,
                                         local_abspath,
                                         scratch_pool));
 
@@ -2037,14 +2035,28 @@ run_file_install(svn_wc__db_t *db,
       SVN_ERR(svn_io_stat(&finfo, local_abspath,
                           APR_FINFO_MIN | APR_FINFO_LINK,
                           scratch_pool));
-      tmp_entry.working_size = finfo.size;
 
+      /* ### for now, stick to the entry_modify2(). there is something more
+         ### going on there. merge_tests 34 will fail if we switch to the
+         ### wc_db API.  */
+#if 0
+      SVN_ERR(svn_wc__db_global_record_fileinfo(db, local_abspath,
+                                                finfo.size, last_mod_time,
+                                                scratch_pool));
+#else
+      {
+        svn_wc_entry_t tmp_entry;
+
+        tmp_entry.text_time = last_mod_time;
+        tmp_entry.working_size = finfo.size;
       SVN_ERR(svn_wc__entry_modify2(db, local_abspath,
                                     svn_node_unknown, FALSE,
                                     &tmp_entry,
                                     SVN_WC__ENTRY_MODIFY_TEXT_TIME
                                       | SVN_WC__ENTRY_MODIFY_WORKING_SIZE,
                                     scratch_pool));
+      }
+#endif
     }
 
   return SVN_NO_ERROR;