You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/01/04 16:32:52 UTC
svn commit: r1055080 - /subversion/trunk/subversion/libsvn_wc/wc_db.c
Author: julianfoad
Date: Tue Jan 4 15:32:52 2011
New Revision: 1055080
URL: http://svn.apache.org/viewvc?rev=1055080&view=rev
Log:
Split svn_wc__db_pristine_cleanup() into a wrapper and a lower-level body
that takes a 'wcroot'. This distinction is logical in itself and also helps
me to experiment with automatically cleaning up when closing a WC root.
* subversion/libsvn_wc/wc_db.c
(pristine_remove): Take a 'wcroot' instead of a 'pdh'.
(svn_wc__db_pristine_remove): Adjust the call to pristine_remove().
(pristine_cleanup_wcroot): New function, extracted from ...
(svn_wc__db_pristine_cleanup): ... this, which is now just a wrapper.
Modified:
subversion/trunk/subversion/libsvn_wc/wc_db.c
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1055080&r1=1055079&r2=1055080&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Jan 4 15:32:52 2011
@@ -2489,10 +2489,10 @@ svn_wc__db_pristine_get_sha1(const svn_c
}
-/* Delete the pristine text referenced by SHA1_CHECKSUM in the database
- * referenced by PDH. */
+/* Delete the pristine text referenced by SHA1_CHECKSUM 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_pdh_t *pdh,
+pristine_remove(svn_wc__db_wcroot_t *wcroot,
const svn_checksum_t *sha1_checksum,
apr_pool_t *scratch_pool)
{
@@ -2500,13 +2500,13 @@ pristine_remove(svn_wc__db_pdh_t *pdh,
const char *pristine_abspath;
/* Remove the DB row. */
- SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+ SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
STMT_DELETE_PRISTINE));
SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
SVN_ERR(svn_sqlite__update(NULL, stmt));
/* Remove the file */
- SVN_ERR(get_pristine_fname(&pristine_abspath, pdh->wcroot->abspath,
+ 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 */,
@@ -2577,31 +2577,21 @@ svn_wc__db_pristine_remove(svn_wc__db_t
/* If not referenced, remove the PRISTINE table row and the file. */
if (! is_referenced)
{
- SVN_ERR(pristine_remove(pdh, sha1_checksum, scratch_pool));
+ SVN_ERR(pristine_remove(pdh->wcroot, sha1_checksum, scratch_pool));
}
return SVN_NO_ERROR;
}
-svn_error_t *
-svn_wc__db_pristine_cleanup(svn_wc__db_t *db,
- const char *wri_abspath,
- apr_pool_t *scratch_pool)
+static svn_error_t *
+pristine_cleanup_wcroot(svn_wc__db_wcroot_t *wcroot,
+ 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(wri_abspath));
-
- SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
- wri_abspath, svn_sqlite__mode_readonly,
- scratch_pool, scratch_pool));
- VERIFY_USABLE_PDH(pdh);
-
/* Find each unreferenced pristine in the DB and remove it. */
- SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+ SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
STMT_SELECT_UNREFERENCED_PRISTINES));
while (1)
{
@@ -2614,7 +2604,7 @@ svn_wc__db_pristine_cleanup(svn_wc__db_t
SVN_ERR(svn_sqlite__column_checksum(&sha1_checksum, stmt, 0,
scratch_pool));
- SVN_ERR(pristine_remove(pdh, sha1_checksum, scratch_pool));
+ SVN_ERR(pristine_remove(wcroot, sha1_checksum, scratch_pool));
}
SVN_ERR(svn_sqlite__reset(stmt));
@@ -2623,6 +2613,27 @@ svn_wc__db_pristine_cleanup(svn_wc__db_t
svn_error_t *
+svn_wc__db_pristine_cleanup(svn_wc__db_t *db,
+ const char *wri_abspath,
+ apr_pool_t *scratch_pool)
+{
+ svn_wc__db_pdh_t *pdh;
+ const char *local_relpath;
+
+ SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
+
+ SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+ wri_abspath, svn_sqlite__mode_readonly,
+ scratch_pool, scratch_pool));
+ VERIFY_USABLE_PDH(pdh);
+
+ SVN_ERR(pristine_cleanup_wcroot(pdh->wcroot, scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
svn_wc__db_pristine_check(svn_boolean_t *present,
svn_wc__db_t *db,
const char *wri_abspath,