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/18 21:41:26 UTC

svn commit: r1094707 - in /subversion/trunk/subversion: libsvn_wc/ tests/libsvn_wc/

Author: rhuijben
Date: Mon Apr 18 19:41:26 2011
New Revision: 1094707

URL: http://svn.apache.org/viewvc?rev=1094707&view=rev
Log:
In our pristine store we store the length (in bytes) of the pristine streams.
We can use this (and the new had_props boolean of _read_info()) to further
optimize the file comparison code below svn_wc__internal_file_modified_p(),
without additional IO.

* If a file doesn't have properties, it doesn't need translation, so
  don't perform DB queries to get the translation details from the properties.
* If a file doesn't need translation *and* doesn't match the pristine
  size, it is not equal to the pristine file.

* subversion/libsvn_wc/adm_crawler.c
  (read_and_checksum_pristine_text): Update caller.

* subversion/libsvn_wc/adm_files.c
  (svn_wc__get_pristine_contents): Add size argument.

* subversion/libsvn_wc/adm_files.h
  (svn_wc__get_pristine_contents): Add size argument.

* subversion/libsvn_wc/adm_ops.c
  (svn_wc_get_pristine_contents2): Update caller.

* subversion/libsvn_wc/copy.c
  (copy_pristine_text_if_necessary): Update caller.

* subversion/libsvn_wc/diff.c
  (apply_textdelta): Update caller.

* subversion/libsvn_wc/questions.c
  (compare_and_verify): Don't do work that we can avoid, by receiving a bit
    more information from the caller. If we don't translate and the filesize
    doesn't match, don't read the files.

  (svn_wc__internal_file_modified_p): Retrieve the filesize and whether we have
    properties and pass that to compare_and_verify.

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

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

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_pristine_read): Add argument.

* subversion/libsvn_wc/wc_db_pristine.c
  (pristine_read_baton_t): Add field.
  (pristine_read_txn): Use new query. Set size if requested; allow NULL
    contents.
  (svn_wc__db_pristine_read): Set new argument in baton.

* subversion/libsvn_wc/workqueue.c
  (process_commit_file_install): Don't force a sha1 comparison.

* subversion/tests/libsvn_wc/pristine-store-test.c
  (pristine_write_read,
   pristine_delete_while_open): Update caller.

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_crawler.c
    subversion/trunk/subversion/libsvn_wc/adm_files.c
    subversion/trunk/subversion/libsvn_wc/adm_files.h
    subversion/trunk/subversion/libsvn_wc/adm_ops.c
    subversion/trunk/subversion/libsvn_wc/copy.c
    subversion/trunk/subversion/libsvn_wc/diff.c
    subversion/trunk/subversion/libsvn_wc/questions.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.h
    subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c
    subversion/trunk/subversion/libsvn_wc/workqueue.c
    subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.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=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_crawler.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_crawler.c Mon Apr 18 19:41:26 2011
@@ -1072,7 +1072,7 @@ read_and_checksum_pristine_text(svn_stre
 {
   svn_stream_t *base_stream;
 
-  SVN_ERR(svn_wc__get_pristine_contents(&base_stream, db, local_abspath,
+  SVN_ERR(svn_wc__get_pristine_contents(&base_stream, NULL, db, local_abspath,
                                         result_pool, scratch_pool));
   if (base_stream == NULL)
     {

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.c Mon Apr 18 19:41:26 2011
@@ -217,6 +217,7 @@ svn_wc__text_base_path_to_read(const cha
 
 svn_error_t *
 svn_wc__get_pristine_contents(svn_stream_t **contents,
+                              svn_filesize_t *size,
                               svn_wc__db_t *db,
                               const char *local_abspath,
                               apr_pool_t *result_pool,
@@ -226,6 +227,9 @@ svn_wc__get_pristine_contents(svn_stream
   svn_wc__db_kind_t kind;
   const svn_checksum_t *sha1_checksum;
 
+  if (size)
+    *size = SVN_INVALID_FILESIZE;
+
   SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL,
                                NULL, NULL, NULL, NULL, &sha1_checksum, NULL,
                                NULL, NULL, NULL, NULL, NULL, NULL,
@@ -275,7 +279,7 @@ svn_wc__get_pristine_contents(svn_stream
                              svn_dirent_local_style(local_abspath,
                                                     scratch_pool));
   if (sha1_checksum)
-    SVN_ERR(svn_wc__db_pristine_read(contents, db, local_abspath,
+    SVN_ERR(svn_wc__db_pristine_read(contents, size, db, local_abspath,
                                      sha1_checksum,
                                      result_pool, scratch_pool));
   else

Modified: subversion/trunk/subversion/libsvn_wc/adm_files.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.h?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.h (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.h Mon Apr 18 19:41:26 2011
@@ -61,10 +61,15 @@ svn_boolean_t svn_wc__adm_area_exists(co
  * locally added (even if it replaces an existing base node).  Return an
  * error if there is no pristine text for any other reason.
  *
+ * If SIZE is not NULL, set *SIZE to the length of the pristine stream in
+ * BYTES or to SVN_INVALID_FILESIZE if no pristine is available for this
+ * file.
+ *
  * For more detail, see the description of svn_wc_get_pristine_contents2().
  */
 svn_error_t *
 svn_wc__get_pristine_contents(svn_stream_t **contents,
+                              svn_filesize_t *size,
                               svn_wc__db_t *db,
                               const char *local_abspath,
                               apr_pool_t *result_pool,

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Mon Apr 18 19:41:26 2011
@@ -1770,7 +1770,7 @@ svn_wc_get_pristine_contents2(svn_stream
                               apr_pool_t *result_pool,
                               apr_pool_t *scratch_pool)
 {
-  return svn_error_return(svn_wc__get_pristine_contents(contents,
+  return svn_error_return(svn_wc__get_pristine_contents(contents, NULL,
                                                         wc_ctx->db,
                                                         local_abspath,
                                                         result_pool,

Modified: subversion/trunk/subversion/libsvn_wc/copy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/copy.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/copy.c (original)
+++ subversion/trunk/subversion/libsvn_wc/copy.c Mon Apr 18 19:41:26 2011
@@ -173,7 +173,7 @@ copy_pristine_text_if_necessary(svn_wc__
       SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath, db, dst_abspath,
                                              scratch_pool, scratch_pool));
 
-      SVN_ERR(svn_wc__db_pristine_read(&src_pristine, db,
+      SVN_ERR(svn_wc__db_pristine_read(&src_pristine, NULL, db,
                                        src_abspath, sha1_checksum,
                                        scratch_pool, scratch_pool));
       SVN_ERR(svn_stream_open_unique(&tmp_pristine, &tmp_pristine_abspath,

Modified: subversion/trunk/subversion/libsvn_wc/diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/diff.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/diff.c (original)
+++ subversion/trunk/subversion/libsvn_wc/diff.c Mon Apr 18 19:41:26 2011
@@ -1541,7 +1541,8 @@ apply_textdelta(void *file_baton,
   else
     {
       /* The current text-base is the starting point if replacing */
-      SVN_ERR(svn_wc__get_pristine_contents(&source, eb->db, fb->local_abspath,
+      SVN_ERR(svn_wc__get_pristine_contents(&source, NULL,
+                                            eb->db, fb->local_abspath,
                                             fb->pool, fb->pool));
       if (source == NULL)
         source = svn_stream_empty(fb->pool);

Modified: subversion/trunk/subversion/libsvn_wc/questions.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/questions.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/questions.c (original)
+++ subversion/trunk/subversion/libsvn_wc/questions.c Mon Apr 18 19:41:26 2011
@@ -81,9 +81,12 @@
 
 
 /* Set *MODIFIED_P to TRUE if (after translation) VERSIONED_FILE_ABSPATH
- * differs from PRISTINE_STREAM, else to FALSE if not.  Also verify that
- * PRISTINE_STREAM matches the stored checksum for VERSIONED_FILE_ABSPATH,
- * if verify_checksum is TRUE. If checksum does not match, return the error
+ * (of VERSIONED_FILE_SIZE bytes) differs from PRISTINE_STREAM (of
+ * PRISTINE_SIZE bytes), else to FALSE if not.
+ *
+ * If VERIFY_CHECKSUM is not NULL, also verify that PRISTINE_STREAM matches
+ * this checksum (which should be the stored checksum for 
+ * VERSIONED_FILE_ABSPATH). If the checksum does not match, return the error
  * SVN_ERR_WC_CORRUPT_TEXT_BASE.
  *
  * If COMPARE_TEXTBASES is true, translate VERSIONED_FILE_ABSPATH's EOL
@@ -101,9 +104,12 @@ static svn_error_t *
 compare_and_verify(svn_boolean_t *modified_p,
                    svn_wc__db_t *db,
                    const char *versioned_file_abspath,
+                   svn_filesize_t versioned_file_size,
                    svn_stream_t *pristine_stream,
+                   svn_filesize_t pristine_size,
+                   svn_boolean_t has_props,
                    svn_boolean_t compare_textbases,
-                   svn_boolean_t verify_checksum,
+                   const svn_checksum_t *verify_checksum,
                    apr_pool_t *scratch_pool)
 {
   svn_boolean_t same;
@@ -115,43 +121,47 @@ compare_and_verify(svn_boolean_t *modifi
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(versioned_file_abspath));
 
-  SVN_ERR(svn_wc__get_translate_info(&eol_style, &eol_str,
-                                     &keywords,
-                                     &special,
-                                     db, versioned_file_abspath, NULL,
-                                     scratch_pool, scratch_pool));
+  if (has_props)
+    {
+      SVN_ERR(svn_wc__get_translate_info(&eol_style, &eol_str,
+                                         &keywords,
+                                         &special,
+                                         db, versioned_file_abspath, NULL,
+                                         scratch_pool, scratch_pool));
+
+      need_translation = svn_subst_translation_required(eol_style, eol_str,
+                                                        keywords, special,
+                                                        TRUE);
+    }
+  else
+    need_translation = FALSE;
 
-  need_translation = svn_subst_translation_required(eol_style, eol_str,
-                                                    keywords, special, TRUE);
+  if (! need_translation
+      && ! verify_checksum
+      && (versioned_file_size != pristine_size))
+    {
+      *modified_p = TRUE;
+
+      /* ### Why did we open the pristine? */
+      return svn_error_return(svn_stream_close(pristine_stream));
+    }
+
+  /* #### Can a file be smaller then its repository_normal form, or other
+          optimizations? */
 
   if (verify_checksum || need_translation)
     {
       /* Reading files is necessary. */
       svn_checksum_t *checksum;
       svn_stream_t *v_stream;  /* versioned_file */
-      const svn_checksum_t *node_checksum;
 
       if (verify_checksum)
         {
-          /* Need checksum verification, so read checksum from entries file
-           * and setup checksummed stream for base file. */
-          SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL,
-                                       &node_checksum, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL, NULL, NULL,
-                                       db, versioned_file_abspath,
-                                       scratch_pool, scratch_pool));
-          /* SVN_EXPERIMENTAL_PRISTINE:
-             node_checksum is originally MD-5 but will later be SHA-1.  To
-             allow for this, we calculate CHECKSUM as the same kind so that
-             we can compare them. */
-
-          if (node_checksum)
-            pristine_stream = svn_stream_checksummed2(pristine_stream,
-                                                      &checksum, NULL,
-                                                      node_checksum->kind, TRUE,
-                                                      scratch_pool);
+          pristine_stream = svn_stream_checksummed2(pristine_stream,
+                                                    &checksum, NULL,
+                                                    verify_checksum->kind,
+                                                    TRUE,
+                                                    scratch_pool);
         }
 
       if (special)
@@ -195,11 +205,11 @@ compare_and_verify(svn_boolean_t *modifi
       SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
                                         scratch_pool));
 
-      if (verify_checksum && node_checksum)
+      if (verify_checksum)
         {
-          if (checksum && !svn_checksum_match(checksum, node_checksum))
+          if (checksum && !svn_checksum_match(checksum, verify_checksum))
             return svn_error_create(SVN_ERR_WC_CORRUPT_TEXT_BASE,
-                    svn_checksum_mismatch_err(node_checksum, checksum,
+                    svn_checksum_mismatch_err(verify_checksum, checksum,
                                               scratch_pool,
                                 _("Checksum mismatch indicates corrupt "
                                   "text base for file: '%s'"),
@@ -236,8 +246,12 @@ svn_wc__internal_file_modified_p(svn_boo
                                  apr_pool_t *scratch_pool)
 {
   svn_stream_t *pristine_stream;
+  svn_filesize_t pristine_size;
+  svn_boolean_t has_props;
+  svn_boolean_t props_mod;
   svn_error_t *err;
   apr_finfo_t finfo;
+  const svn_checksum_t *verify_checksum = NULL;
   apr_int32_t wanted
     = APR_FINFO_SIZE | APR_FINFO_MTIME | APR_FINFO_TYPE | APR_FINFO_LINK;
 
@@ -305,22 +319,17 @@ svn_wc__internal_file_modified_p(svn_boo
       */
 
       /* Read the relevant info */
-      err = svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL,
-                                 &translated_size, &last_mod_time,
-                                 NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL,
-                                 db, local_abspath,
-                                 scratch_pool, scratch_pool);
-      if (err)
-        {
-          svn_error_clear(err);
-          goto compare_them;
-        }
+      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL,
+                                   &translated_size, &last_mod_time,
+                                   NULL, NULL, NULL, &has_props, &props_mod,
+                                   NULL, NULL, NULL,
+                                   db, local_abspath,
+                                   scratch_pool, scratch_pool));
 
       /* Compare the sizes, if applicable */
-      if (translated_size != SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN
+      if (translated_size != SVN_INVALID_FILESIZE
           && finfo.size != translated_size)
         goto compare_them;
 
@@ -332,10 +341,23 @@ svn_wc__internal_file_modified_p(svn_boo
       if (last_mod_time != finfo.mtime)
         goto compare_them;
 
-
       *modified_p = FALSE;
       return SVN_NO_ERROR;
     }
+  else
+    {
+      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, &verify_checksum, NULL,
+                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, &has_props, &props_mod,
+                                   NULL, NULL, NULL,
+                                   db, local_abspath,
+                                   scratch_pool, scratch_pool));
+    }
+
+  if (props_mod)
+    has_props = TRUE; /* Maybe it didn't have properties; but it has now */
+
 
  compare_them:
   /* If there's no text-base file, we have to assume the working file
@@ -343,7 +365,8 @@ svn_wc__internal_file_modified_p(svn_boo
      yet committed. */
   /* We used to stat for the working base here, but we just give
      compare_and_verify a try; we'll check for errors afterwards */
-  err = svn_wc__get_pristine_contents(&pristine_stream, db, local_abspath,
+  err = svn_wc__get_pristine_contents(&pristine_stream, &pristine_size,
+                                      db, local_abspath,
                                       scratch_pool, scratch_pool);
   if (err && APR_STATUS_IS_ENOENT(err->apr_err))
     {
@@ -361,10 +384,12 @@ svn_wc__internal_file_modified_p(svn_boo
     }
 
   /* Check all bytes, and verify checksum if requested. */
-  SVN_ERR(compare_and_verify(modified_p, db, local_abspath,
-                             pristine_stream,
+  SVN_ERR(compare_and_verify(modified_p, db,
+                             local_abspath, finfo.size,
+                             pristine_stream, pristine_size,
+                             has_props,
                              compare_textbases,
-                             force_comparison,
+                             verify_checksum,
                              scratch_pool));
 
   if (!*modified_p)

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Mon Apr 18 19:41:26 2011
@@ -3109,7 +3109,7 @@ apply_textdelta(void *file_baton,
       SVN_ERR_ASSERT(!fb->original_checksum
                      || fb->original_checksum->kind == svn_checksum_sha1);
 
-      SVN_ERR(svn_wc__db_pristine_read(&source, fb->edit_baton->db,
+      SVN_ERR(svn_wc__db_pristine_read(&source, NULL, fb->edit_baton->db,
                                        fb->local_abspath,
                                        fb->original_checksum,
                                        handler_pool, handler_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=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Mon Apr 18 19:41:26 2011
@@ -603,6 +603,11 @@ SELECT md5_checksum
 FROM pristine
 WHERE checksum = ?1
 
+-- STMT_SELECT_PRISTINE_SIZE
+SELECT size
+FROM pristine
+WHERE checksum = ?1 LIMIT 1
+
 -- STMT_SELECT_PRISTINE_BY_MD5
 SELECT checksum
 FROM pristine

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Mon Apr 18 19:41:26 2011
@@ -912,9 +912,11 @@ svn_wc__db_pristine_get_future_path(cons
                                     apr_pool_t *scratch_pool);
 
 
-/* Set *CONTENTS to a readable stream that will yield the pristine text
-   identified by SHA1_CHECKSUM (### which should/must be its SHA-1 checksum?)
-   within the WC identified by WRI_ABSPATH in DB.
+/* If requested set *CONTENTS to a readable stream that will yield the pristine
+   text identified by SHA1_CHECKSUM (must be a SHA-1 checksum) within the WC
+   identified by WRI_ABSPATH in DB.
+
+   If requested set *SIZE to the size of the pristine stream in bytes,
 
    Even if the pristine text is removed from the store while it is being
    read, the stream will remain valid and readable until it is closed.
@@ -922,6 +924,7 @@ svn_wc__db_pristine_get_future_path(cons
    Allocate the stream in RESULT_POOL. */
 svn_error_t *
 svn_wc__db_pristine_read(svn_stream_t **contents,
+                         svn_filesize_t *size,
                          svn_wc__db_t *db,
                          const char *wri_abspath,
                          const svn_checksum_t *sha1_checksum,

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c Mon Apr 18 19:41:26 2011
@@ -152,6 +152,10 @@ typedef struct pristine_read_baton_t
   const svn_checksum_t *sha1_checksum;
   /* The path to the pristine file (within the pristine store). */
   const char *pristine_abspath;
+
+  /* Pointer to where to place the size (if requested) */
+  svn_filesize_t *size;
+
   /* The pool from which to allocate the result stream. */
   apr_pool_t *result_pool;
 } pristine_read_baton_t;
@@ -181,9 +185,14 @@ pristine_read_txn(void *baton,
 
   /* Check that this pristine text is present in the store.  (The presence
    * of the file is not sufficient.) */
-  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_SELECT_PRISTINE));
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_SELECT_PRISTINE_SIZE));
   SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, b->sha1_checksum, scratch_pool));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+  if (b->size)
+    *b->size = svn_sqlite__column_int64(stmt, 0);
+
   SVN_ERR(svn_sqlite__reset(stmt));
   if (! have_row)
     {
@@ -195,13 +204,15 @@ pristine_read_txn(void *baton,
 
   /* Open the file as a readable stream.  It will remain readable even when
    * deleted from disk; APR guarantees that on Windows as well as Unix. */
-  SVN_ERR(svn_stream_open_readonly(b->contents, b->pristine_abspath,
-                                   b->result_pool, scratch_pool));
+  if (b->contents)
+    SVN_ERR(svn_stream_open_readonly(b->contents, b->pristine_abspath,
+                                     b->result_pool, scratch_pool));
   return SVN_NO_ERROR;
 }
 
 svn_error_t *
 svn_wc__db_pristine_read(svn_stream_t **contents,
+                         svn_filesize_t *size,
                          svn_wc__db_t *db,
                          const char *wri_abspath,
                          const svn_checksum_t *sha1_checksum,
@@ -223,6 +234,7 @@ svn_wc__db_pristine_read(svn_stream_t **
 
   b.contents = contents;
   b.sha1_checksum = sha1_checksum;
+  b.size = size;
   b.result_pool = result_pool;
   SVN_ERR(get_pristine_fname(&b.pristine_abspath, wcroot->abspath,
                              sha1_checksum,

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Mon Apr 18 19:41:26 2011
@@ -625,7 +625,7 @@ process_commit_file_install(svn_wc__db_t
        "repair" them if the file is unmodified */
       SVN_ERR(svn_wc__internal_file_modified_p(&modified, NULL, NULL,
                                                db, local_abspath,
-                                               TRUE, FALSE, scratch_pool));
+                                               FALSE, FALSE, scratch_pool));
     }
   return SVN_NO_ERROR;
 }
@@ -1691,7 +1691,7 @@ pristine_get_translated(svn_wc__db_t *db
 {
   svn_stream_t *src_stream, *dst_stream;
 
-  SVN_ERR(svn_wc__db_pristine_read(&src_stream, db, versioned_abspath,
+  SVN_ERR(svn_wc__db_pristine_read(&src_stream, NULL, db, versioned_abspath,
                                    pristine_sha1,
                                    scratch_pool, scratch_pool));
   SVN_ERR(svn_wc__internal_translated_stream(&dst_stream, db, new_abspath,

Modified: subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c?rev=1094707&r1=1094706&r2=1094707&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c Mon Apr 18 19:41:26 2011
@@ -171,7 +171,7 @@ pristine_write_read(const svn_test_opts_
     svn_stream_t *data_read_back;
     svn_boolean_t same;
 
-    SVN_ERR(svn_wc__db_pristine_read(&data_read_back, db, wc_abspath,
+    SVN_ERR(svn_wc__db_pristine_read(&data_read_back, NULL, db, wc_abspath,
                                      data_sha1, pool, pool));
     SVN_ERR(svn_stream_contents_same2(&same, data_read_back, data_stream,
                                       pool));
@@ -185,7 +185,7 @@ pristine_write_read(const svn_test_opts_
     svn_stream_t *data_read_back;
 
     SVN_ERR(svn_wc__db_pristine_remove(db, wc_abspath, data_sha1, pool));
-    err = svn_wc__db_pristine_read(&data_read_back, db, wc_abspath,
+    err = svn_wc__db_pristine_read(&data_read_back, NULL, db, wc_abspath,
                                    data_sha1, pool, pool);
     SVN_TEST_ASSERT(err != NULL);
     svn_error_clear(err);
@@ -313,7 +313,7 @@ pristine_delete_while_open(const svn_tes
   }
 
   /* Open it for reading */
-  SVN_ERR(svn_wc__db_pristine_read(&contents, db, wc_abspath, data_sha1,
+  SVN_ERR(svn_wc__db_pristine_read(&contents, NULL, db, wc_abspath, data_sha1,
                                    pool, pool));
 
   /* Delete it */



Re: svn commit: r1094707 - in /subversion/trunk/subversion: libsvn_wc/ tests/libsvn_wc/

Posted by Greg Stein <gs...@gmail.com>.
On Mon, Apr 18, 2011 at 15:41,  <rh...@apache.org> wrote:
>...
> +++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Mon Apr 18 19:41:26 2011
> @@ -603,6 +603,11 @@ SELECT md5_checksum
>  FROM pristine
>  WHERE checksum = ?1
>
> +-- STMT_SELECT_PRISTINE_SIZE
> +SELECT size
> +FROM pristine
> +WHERE checksum = ?1 LIMIT 1

checksum is the PRIMARY KEY. Thus, it is unique and will select just
one row. The LIMIT 1 is superfluous, and could even be construed as
misleading ("what? more than one row could get selected?")

>...
> +++ subversion/trunk/subversion/libsvn_wc/workqueue.c Mon Apr 18 19:41:26 2011
> @@ -625,7 +625,7 @@ process_commit_file_install(svn_wc__db_t
>        "repair" them if the file is unmodified */
>       SVN_ERR(svn_wc__internal_file_modified_p(&modified, NULL, NULL,
>                                                db, local_abspath,
> -                                               TRUE, FALSE, scratch_pool));
> +                                               FALSE, FALSE, scratch_pool));

I find this block of the 'if' statement to be very poor form. We don't
use the MODIFIED result, so why are we calling this function? Just for
its *side effects*? That sounds rather janky. Why don't we simply grab
the values and shove them into the db. In other words... just like the
true-block of the 'if' statement. Seems that we can just strike the
'if' and unconditionally grab new values to shove into the db with a
direct call to record_fileinfo().

>...

Cheers,
-g