subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1058667 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c
Date Thu, 13 Jan 2011 17:13:51 GMT
Author: julianfoad
Date: Thu Jan 13 17:13:51 2011
New Revision: 1058667

URL: http://svn.apache.org/viewvc?rev=1058667&view=rev
Log:
Simplify checking for whether a pristine text is referenced, now that the
ref count is in use.

* subversion/libsvn_wc/wc_db.c
  (pristine_remove): Rename to pristine_remove_if_unreferenced(), and change
    to only remove the pristine if its ref count is zero.
  (svn_wc__db_pristine_remove): Don't perform a separate check for
    references, since pristine_remove_if_unreferenced() does that now.
  (pristine_cleanup_wcroot): Track the rename.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_ANY_PRISTINE_REFERENCE): Delete, as no longer needed.
  (STMT_SELECT_UNREFERENCED_PRISTINES): Simplify by checking the 'refcount'
    column instead of searching the 'nodes' table for references.
  (STMT_DELETE_PRISTINE): Rename to STMT_DELETE_PRISTINE_IF_UNREFERENCED and
    only delete the row if its 'refcount' column is zero.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1058667&r1=1058666&r2=1058667&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Thu Jan 13 17:13:51 2011
@@ -423,21 +423,14 @@ SELECT checksum
 FROM pristine
 WHERE md5_checksum = ?1
 
--- STMT_SELECT_ANY_PRISTINE_REFERENCE
-SELECT 1 FROM nodes
-  WHERE checksum = ?1 OR checksum = ?2
-LIMIT 1
-
 -- STMT_SELECT_UNREFERENCED_PRISTINES
 SELECT checksum
 FROM pristine
-EXCEPT
-SELECT checksum FROM nodes
-  WHERE checksum IS NOT NULL
+WHERE refcount = 0
 
--- STMT_DELETE_PRISTINE
+-- STMT_DELETE_PRISTINE_IF_UNREFERENCED
 DELETE FROM pristine
-WHERE checksum = ?1
+WHERE checksum = ?1 AND refcount = 0
 
 -- STMT_SELECT_ACTUAL_CONFLICT_VICTIMS
 SELECT local_relpath

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1058667&r1=1058666&r2=1058667&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Jan 13 17:13:51 2011
@@ -2489,28 +2489,33 @@ svn_wc__db_pristine_get_sha1(const svn_c
 }
 
 
-/* Delete the pristine text referenced by SHA1_CHECKSUM from the pristine
- * store of WCROOT.  Delete both the database row and the file on disk. */
+/* If the pristine text referenced by SHA1_CHECKSUM has a reference count
+ * of zero, delete it from the pristine store of WCROOT.  Delete both the
+ * database row and the file on disk. */
 static svn_error_t *
-pristine_remove(svn_wc__db_wcroot_t *wcroot,
+pristine_remove_if_unreferenced(svn_wc__db_wcroot_t *wcroot,
                 const svn_checksum_t *sha1_checksum,
                 apr_pool_t *scratch_pool)
 {
   svn_sqlite__stmt_t *stmt;
   const char *pristine_abspath;
+  int affected_rows;
 
-  /* Remove the DB row. */
+  /* Remove the DB row, if refcount is 0. */
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
-                                    STMT_DELETE_PRISTINE));
+                                    STMT_DELETE_PRISTINE_IF_UNREFERENCED));
   SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
-  SVN_ERR(svn_sqlite__update(NULL, stmt));
+  SVN_ERR(svn_sqlite__update(&affected_rows, stmt));
 
-  /* Remove the file */
-  SVN_ERR(get_pristine_fname(&pristine_abspath, wcroot->abspath,
-                             sha1_checksum, TRUE /* create_subdir */,
-                             scratch_pool, scratch_pool));
-  SVN_ERR(svn_io_remove_file2(pristine_abspath, TRUE /* ignore_enoent */,
-                              scratch_pool));
+  if (affected_rows > 0)
+    {
+      /* Remove the file. */
+      SVN_ERR(get_pristine_fname(&pristine_abspath, wcroot->abspath,
+                                 sha1_checksum, TRUE /* create_subdir */,
+                                 scratch_pool, scratch_pool));
+      SVN_ERR(svn_io_remove_file2(pristine_abspath, TRUE /* ignore_enoent */,
+                                  scratch_pool));
+    }
 
   return SVN_NO_ERROR;
 }
@@ -2555,30 +2560,9 @@ svn_wc__db_pristine_remove(svn_wc__db_t 
       return SVN_NO_ERROR;
   }
 
-  /* Find whether the SHA-1 (or the MD-5) is referenced; set IS_REFERENCED. */
-  {
-    const svn_checksum_t *md5_checksum;
-    svn_sqlite__stmt_t *stmt;
-
-    /* ### Transitional: look for references to its MD-5 as well. */
-    SVN_ERR(svn_wc__db_pristine_get_md5(&md5_checksum, db, wri_abspath,
-                                        sha1_checksum, scratch_pool,
-                                        scratch_pool));
-
-    SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                      STMT_SELECT_ANY_PRISTINE_REFERENCE));
-    SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
-    SVN_ERR(svn_sqlite__bind_checksum(stmt, 2, md5_checksum, scratch_pool));
-    SVN_ERR(svn_sqlite__step(&is_referenced, stmt));
-
-    SVN_ERR(svn_sqlite__reset(stmt));
-  }
-
   /* If not referenced, remove the PRISTINE table row and the file. */
-  if (! is_referenced)
-    {
-      SVN_ERR(pristine_remove(pdh->wcroot, sha1_checksum, scratch_pool));
-    }
+  SVN_ERR(pristine_remove_if_unreferenced(pdh->wcroot, sha1_checksum,
+                                          scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -2604,7 +2588,7 @@ pristine_cleanup_wcroot(svn_wc__db_wcroo
 
       SVN_ERR(svn_sqlite__column_checksum(&sha1_checksum, stmt, 0,
                                           scratch_pool));
-      SVN_ERR(pristine_remove(wcroot, sha1_checksum, scratch_pool));
+      SVN_ERR(pristine_remove_if_unreferenced(wcroot, sha1_checksum, scratch_pool));
     }
   SVN_ERR(svn_sqlite__reset(stmt));
 



Mime
View raw message