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 2013/02/25 00:18:32 UTC

svn commit: r1449564 - /subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c

Author: rhuijben
Date: Sun Feb 24 23:18:32 2013
New Revision: 1449564

URL: http://svn.apache.org/r1449564
Log:
Serf now uses one big update request for legacy servers, so the local fetch via
sha1 is only used for new servers. So now is the time to disable the MD5
fallback to avoid possible MD5 collisions.

* subversion/libsvn_wc/wc_db_pristine.c
  (svn_wc__db_pristine_check): Report non-sha1 checksum as missing. Use a
    filestat to avoid an unneeded db transaction for every file on a checkout,
    when using serf with separate requests.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c

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=1449564&r1=1449563&r2=1449564&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c Sun Feb 24 23:18:32 2013
@@ -881,46 +881,42 @@ svn_wc__db_pristine_check(svn_boolean_t 
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
 
-  SVN_ERR_ASSERT(present != NULL);
   SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
   SVN_ERR_ASSERT(sha1_checksum != NULL);
-  /* ### Transitional: accept MD-5 and look up the SHA-1.  Return an error
-   * if the pristine text is not in the store. */
+
   if (sha1_checksum->kind != svn_checksum_sha1)
-    SVN_ERR(svn_wc__db_pristine_get_sha1(&sha1_checksum, db, wri_abspath,
-                                         sha1_checksum,
-                                         scratch_pool, scratch_pool));
-  SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
+    {
+      *present = FALSE;
+      return SVN_NO_ERROR;
+    }
 
   SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, scratch_pool, scratch_pool));
   VERIFY_USABLE_WCROOT(wcroot);
 
+  /* A filestat is much cheaper than a sqlite transaction especially on NFS,
+     so first check if there is a pristine file and then if we are allowed
+     to use it. */
+  {
+    const char *pristine_abspath;
+    svn_node_kind_t kind_on_disk;
+
+    SVN_ERR(get_pristine_fname(&pristine_abspath, wcroot->abspath,
+                               sha1_checksum, scratch_pool, scratch_pool));
+    SVN_ERR(svn_io_check_path(pristine_abspath, &kind_on_disk, scratch_pool));
+    if (kind_on_disk != svn_node_file)
+      {
+        *present = FALSE;
+        return SVN_NO_ERROR;
+      }
+  }
+
   /* Check that there is an entry in the PRISTINE table. */
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_SELECT_PRISTINE));
   SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   SVN_ERR(svn_sqlite__reset(stmt));
 
-#ifdef SVN_DEBUG
-  /* Check that the pristine text file exists iff the DB says it does. */
-  if (have_row)
-    {
-      const char *pristine_abspath;
-      svn_node_kind_t kind_on_disk;
-      SVN_ERR(get_pristine_fname(&pristine_abspath, wcroot->abspath,
-                                 sha1_checksum, scratch_pool, scratch_pool));
-      SVN_ERR(svn_io_check_path(pristine_abspath, &kind_on_disk, scratch_pool));
-
-      if (kind_on_disk != svn_node_file)
-        return svn_error_createf(SVN_ERR_WC_DB_ERROR, svn_sqlite__reset(stmt),
-                                 _("The pristine text with checksum '%s' was "
-                                   "found in the DB but not on disk"),
-                                 svn_checksum_to_cstring_display(sha1_checksum,
-                                                                 scratch_pool));
-    }
-#endif
-
   *present = have_row;
   return SVN_NO_ERROR;
 }



Re: svn commit: r1449564 - /subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c

Posted by Ivan Zhakov <iv...@visualsvn.com>.
On Mon, Feb 25, 2013 at 3:18 AM,  <rh...@apache.org> wrote:
> Author: rhuijben
> Date: Sun Feb 24 23:18:32 2013
> New Revision: 1449564
>
> URL: http://svn.apache.org/r1449564
> Log:
> Serf now uses one big update request for legacy servers, so the local fetch via
> sha1 is only used for new servers. So now is the time to disable the MD5
> fallback to avoid possible MD5 collisions.
>
It may be worth to remove fallback code for handling MD5 in
subversion/ra_serf/update.c if we would like to avoid MD5 collisions.

-- 
Ivan Zhakov