Author: rhuijben
Date: Tue May  3 20:48:16 2011
New Revision: 1099236

URL: http://svn.apache.org/viewvc?rev=1099236&view=rev
Log:
When we update a text file from the update editor, but don't install a new file
we should keep its recorded size and time or the performance of svn status
suffers. This handles a case identified by looking into issue #3842, but not
this issue itself.

* subversion/libsvn_wc/update_editor.c
  (close_file): Ask svn_wc__db_base_add_file to keep the recorded information
    when we don't install a new file.

* subversion/libsvn_wc/wc_db.c
  (insert_base_baton_t): Remove translated_size. Add keep_recorded_info.
  (get_translated_size): Rename to ...
  (get_recorded_size): ... this.
  (blank_ibb): Update user.
  (insert_base_node): If necessary copy the recorded information from a
    previous record.
  (svn_wc__db_base_add_file): Remove translated_size argument and add
    keep_recorded_info.
  (base_get_info): Update caller.
  (read_info): Update caller.
  (read_children_info): Update caller.
* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_base_add_file): Remove translated_size argument and add
    keep_recorded_info. Update documentation.

* subversion/tests/libsvn_wc/db-test.c
  (test_inserting_nodes): Update caller.

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
    subversion/trunk/subversion/tests/libsvn_wc/db-test.c

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1099236&r1=1099235&r2=1099236&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue May  3 20:48:16 
2011
@@ -3571,6 +3571,7 @@ close_file(void *file_baton,
   apr_time_t new_changed_date;
   const char *new_changed_author;
   apr_pool_t *scratch_pool = fb->pool; /* Destroyed at function exit */
+  svn_boolean_t keep_recorded_info = FALSE;
 
   if (fb->skip_this)
     {
@@ -3833,6 +3834,8 @@ close_file(void *file_baton,
                                             scratch_pool);
         }
 
+      keep_recorded_info = (install_pristine == FALSE);
+
       /* Clean up any temporary files.  */
 
       /* Remove the INSTALL_FROM file, as long as it doesn't refer to the
@@ -3924,7 +3927,6 @@ close_file(void *file_baton,
                                      new_changed_date,
                                      new_changed_author,
                                      new_checksum,
-                                     SVN_INVALID_FILESIZE,
                                      (dav_prop_changes
                                       && dav_prop_changes->nelts > 0)
                                        ? prop_hash_from_array(dav_prop_changes,
@@ -3933,6 +3935,7 @@ close_file(void *file_baton,
                                      NULL /* conflict */,
                                      (! fb->shadowed) && new_base_props,
                                      new_actual_props,
+                                     keep_recorded_info,
                                      all_work_items,
                                      scratch_pool));
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1099236&r1=1099235&r2=1099236&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue May  3 20:48:16 2011
@@ -164,7 +164,6 @@ typedef struct insert_base_baton_t {
 
   /* for inserting files */
   const svn_checksum_t *checksum;
-  svn_filesize_t translated_size;
 
   /* for inserting symlinks */
   const char *target;
@@ -176,6 +175,9 @@ typedef struct insert_base_baton_t {
   svn_boolean_t update_actual_props;
   const apr_hash_t *new_actual_props;
 
+  /* maybe we should copy information from a previous record? */
+  svn_boolean_t keep_recorded_info;
+
   /* may have work items to queue in this transaction  */
   const svn_skel_t *work_items;
 
@@ -353,7 +355,7 @@ path_for_error_message(const svn_wc__db_
 /* Return a file size from column SLOT of the SQLITE statement STMT, or
    SVN_INVALID_FILESIZE if the column value is NULL.  */
 static svn_filesize_t
-get_translated_size(svn_sqlite__stmt_t *stmt, int slot)
+get_recorded_size(svn_sqlite__stmt_t *stmt, int slot)
 {
   if (svn_sqlite__column_is_null(stmt, slot))
     return SVN_INVALID_FILESIZE;
@@ -647,7 +649,6 @@ blank_ibb(insert_base_baton_t *pibb)
   pibb->revision = SVN_INVALID_REVNUM;
   pibb->changed_rev = SVN_INVALID_REVNUM;
   pibb->depth = svn_depth_infinity;
-  pibb->translated_size = SVN_INVALID_FILESIZE;
   pibb->repos_id = -1;
 }
 
@@ -761,6 +762,9 @@ insert_base_node(void *baton,
   const insert_base_baton_t *pibb = baton;
   apr_int64_t repos_id = pibb->repos_id;
   svn_sqlite__stmt_t *stmt;
+  svn_filesize_t recorded_size = SVN_INVALID_FILESIZE;
+  apr_int64_t recorded_mod_time;
+  
   /* The directory at the WCROOT has a NULL parent_relpath. Otherwise,
      bind the appropriate parent_relpath. */
   const char *parent_relpath =
@@ -777,6 +781,20 @@ insert_base_node(void *baton,
   /* ### we can't handle this right now  */
   SVN_ERR_ASSERT(pibb->conflict == NULL);
 
+  if (pibb->keep_recorded_info)
+    {
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                        STMT_SELECT_BASE_NODE));
+
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+      SVN_ERR(svn_sqlite__step_row(stmt));
+
+      recorded_size = get_recorded_size(stmt, 6);
+      recorded_mod_time = svn_sqlite__column_int64(stmt, 12);
+
+      SVN_ERR(svn_sqlite__reset(stmt));
+    }
+
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_INSERT_NODE));
   SVN_ERR(svn_sqlite__bindf(stmt, "isisisr"
                             "tstr"               /* 8 - 11 */
@@ -802,8 +820,12 @@ insert_base_node(void *baton,
     {
       SVN_ERR(svn_sqlite__bind_checksum(stmt, 14, pibb->checksum,
                                         scratch_pool));
-      if (pibb->translated_size != SVN_INVALID_FILESIZE)
-        SVN_ERR(svn_sqlite__bind_int64(stmt, 16, pibb->translated_size));
+
+      if (recorded_size != SVN_INVALID_FILESIZE)
+        {
+          SVN_ERR(svn_sqlite__bind_int64(stmt, 16, recorded_size));
+          SVN_ERR(svn_sqlite__bind_int64(stmt, 17, recorded_mod_time));
+        }
     }
 
   SVN_ERR(svn_sqlite__bind_properties(stmt, 15, pibb->props,
@@ -1572,11 +1594,11 @@ svn_wc__db_base_add_file(svn_wc__db_t *d
                          apr_time_t changed_date,
                          const char *changed_author,
                          const svn_checksum_t *checksum,
-                         svn_filesize_t translated_size,
                          apr_hash_t *dav_cache,
                          const svn_skel_t *conflict,
                          svn_boolean_t update_actual_props,
                          apr_hash_t *new_actual_props,
+                         svn_boolean_t keep_recorded_info,
                          const svn_skel_t *work_items,
                          apr_pool_t *scratch_pool)
 {
@@ -1614,7 +1636,6 @@ svn_wc__db_base_add_file(svn_wc__db_t *d
   ibb.changed_author = changed_author;
 
   ibb.checksum = checksum;
-  ibb.translated_size = translated_size;
 
   ibb.dav_cache = dav_cache;
   ibb.conflict = conflict;
@@ -1626,6 +1647,7 @@ svn_wc__db_base_add_file(svn_wc__db_t *d
       ibb.new_actual_props = new_actual_props;
     }
 
+  ibb.keep_recorded_info = keep_recorded_info;
 
   /* ### hmm. if this used to be a directory, we should remove children.
      ### or maybe let caller deal with that, if there is a possibility
@@ -1770,7 +1792,6 @@ add_absent_excluded_not_present_node(svn
   ibb.children = NULL;
   ibb.depth = svn_depth_unknown;
   ibb.checksum = NULL;
-  ibb.translated_size = SVN_INVALID_FILESIZE;
   ibb.target = NULL;
 
   ibb.conflict = conflict;
@@ -1997,7 +2018,7 @@ base_get_info(svn_wc__db_status_t *statu
         }
       if (recorded_size)
         {
-          *recorded_size = get_translated_size(stmt, 6);
+          *recorded_size = get_recorded_size(stmt, 6);
         }
       if (target)
         {
@@ -5401,7 +5422,7 @@ read_info(svn_wc__db_status_t *status,
         }
       if (recorded_size)
         {
-          *recorded_size = get_translated_size(stmt_info, 7);
+          *recorded_size = get_recorded_size(stmt_info, 7);
         }
       if (target)
         {
@@ -5772,7 +5793,7 @@ read_children_info(void *baton,
             }
 
           child->recorded_mod_time = svn_sqlite__column_int64(stmt, 13);
-          child->recorded_size = get_translated_size(stmt, 7);
+          child->recorded_size = get_recorded_size(stmt, 7);
           child->had_props = SQLITE_PROPERTIES_AVAILABLE(stmt, 14);
 #ifdef HAVE_SYMLINK
           if (child->had_props)

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1099236&r1=1099235&r2=1099236&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Tue May  3 20:48:16 2011
@@ -481,10 +481,6 @@ svn_wc__db_base_add_directory(svn_wc__db
    The checksum of the file contents is given in CHECKSUM. An entry in
    the pristine text base is NOT required when this API is called.
 
-   If the translated size of the file (its contents, translated as defined
-   by its properties) is known, then pass it as TRANSLATED_SIZE. Otherwise,
-   pass SVN_INVALID_FILESIZE.
-
    If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
    data.
 
@@ -499,6 +495,9 @@ svn_wc__db_base_add_directory(svn_wc__db
    Any work items that are necessary as part of this node construction may
    be passed in WORK_ITEMS.
 
+   Unless KEEP_RECORDED_INFO is set to TRUE, recorded size and timestamp values
+   will be cleared.
+
    All temporary allocations will be made in SCRATCH_POOL.
 */
 svn_error_t *
@@ -513,11 +512,11 @@ svn_wc__db_base_add_file(svn_wc__db_t *d
                          apr_time_t changed_date,
                          const char *changed_author,
                          const svn_checksum_t *checksum,
-                         svn_filesize_t translated_size,
                          apr_hash_t *dav_cache,
                          const svn_skel_t *conflict,
                          svn_boolean_t update_actual_props,
                          apr_hash_t *new_actual_props,
+                         svn_boolean_t keep_recorded_info,
                          const svn_skel_t *work_items,
                          apr_pool_t *scratch_pool);
 

Modified: subversion/trunk/subversion/tests/libsvn_wc/db-test.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/db-test.c?rev=1099236&r1=1099235&r2=1099236&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/db-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/db-test.c Tue May  3 20:48:16 
2011
@@ -700,8 +700,8 @@ test_inserting_nodes(apr_pool_t *pool)
             "N/N-a", ROOT_ONE, UUID_ONE, 3,
             props,
             1, TIME_1a, AUTHOR_1,
-            checksum, 10,
-            NULL, NULL, FALSE, NULL, NULL,
+            checksum,
+            NULL, NULL, FALSE, NULL, FALSE, NULL,
             pool));
 
   /* Create a new symlink node. */


Reply via email to