You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/05/19 19:49:18 UTC
svn commit: r946306 - in /subversion/trunk/subversion/libsvn_wc: wc_db.c
wc_db_pdh.c wc_db_pdh.h
Author: hwright
Date: Wed May 19 17:49:18 2010
New Revision: 946306
URL: http://svn.apache.org/viewvc?rev=946306&view=rev
Log:
Shuffle more code from wc_db.c to wc_db_pdh.c.
* subversion/libsvn_wc/wc_db.c
(verify_no_work, close_wcroot, svn_wc__db_pdh_create_wcroot,
svn_wc__db_close_many_wcroots): Moved from here...
* subversion/libsvn_wc/wc_db_pdh.c
(verify_no_work, close_wcroot, svn_wc__db_pdh_create_wcroot,
svn_wc__db_close_many_wcroots): ...to here.
* subversion/libsvn_wc/wc_db_pdh.h
(svn_wc__db_pdh_create_wcroot): Add declaration.
Modified:
subversion/trunk/subversion/libsvn_wc/wc_db.c
subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c
subversion/trunk/subversion/libsvn_wc/wc_db_pdh.h
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=946306&r1=946305&r2=946306&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed May 19 17:49:18 2010
@@ -276,137 +276,6 @@ escape_sqlite_like(const char * const st
}
-/* */
-static svn_error_t *
-verify_no_work(svn_sqlite__db_t *sdb)
-{
- svn_sqlite__stmt_t *stmt;
- svn_boolean_t have_row;
-
- SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_LOOK_FOR_WORK));
- SVN_ERR(svn_sqlite__step(&have_row, stmt));
- SVN_ERR(svn_sqlite__reset(stmt));
-
- if (have_row)
- return svn_error_create(SVN_ERR_WC_CLEANUP_REQUIRED, NULL,
- NULL /* nothing to add. */);
-
- return SVN_NO_ERROR;
-}
-
-
-/* */
-static apr_status_t
-close_wcroot(void *data)
-{
- svn_wc__db_wcroot_t *wcroot = data;
- svn_error_t *err;
-
- SVN_ERR_ASSERT_NO_RETURN(wcroot->sdb != NULL);
-
- err = svn_sqlite__close(wcroot->sdb);
- wcroot->sdb = NULL;
- if (err)
- {
- apr_status_t result = err->apr_err;
- svn_error_clear(err);
- return result;
- }
-
- return APR_SUCCESS;
-}
-
-
-svn_error_t *
-svn_wc__db_close_many_wcroots(apr_hash_t *roots,
- apr_pool_t *state_pool,
- apr_pool_t *scratch_pool)
-{
- apr_hash_index_t *hi;
-
- for (hi = apr_hash_first(scratch_pool, roots); hi; hi = apr_hash_next(hi))
- {
- svn_wc__db_wcroot_t *wcroot = svn__apr_hash_index_val(hi);
- apr_status_t result;
-
- result = apr_pool_cleanup_run(state_pool, wcroot, close_wcroot);
- if (result != APR_SUCCESS)
- return svn_error_wrap_apr(result, NULL);
- }
-
- return SVN_NO_ERROR;
-}
-
-
-/* Construct a new svn_wc__db_wcroot_t. The WCROOT_ABSPATH and SDB parameters
- must have lifetime of at least RESULT_POOL. */
-static svn_error_t *
-svn_wc__db_pdh_create_wcroot(svn_wc__db_wcroot_t **wcroot,
- const char *wcroot_abspath,
- svn_sqlite__db_t *sdb,
- apr_int64_t wc_id,
- int format,
- svn_boolean_t auto_upgrade,
- svn_boolean_t enforce_empty_wq,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- if (sdb != NULL)
- SVN_ERR(svn_sqlite__read_schema_version(&format, sdb, scratch_pool));
-
- /* If we construct a wcroot, then we better have a format. */
- SVN_ERR_ASSERT(format >= 1);
-
- /* If this working copy is PRE-1.0, then simply bail out. */
- if (format < 4)
- {
- return svn_error_createf(
- SVN_ERR_WC_UNSUPPORTED_FORMAT, NULL,
- _("Working copy format of '%s' is too old (%d); "
- "please check out your working copy again"),
- svn_dirent_local_style(wcroot_abspath, scratch_pool), format);
- }
-
- /* If this working copy is from a future version, then bail out. */
- if (format > SVN_WC__VERSION)
- {
- return svn_error_createf(
- SVN_ERR_WC_UNSUPPORTED_FORMAT, NULL,
- _("This client is too old to work with the working copy at\n"
- "'%s' (format %d).\n"
- "You need to get a newer Subversion client. For more details, see\n"
- " http://subversion.apache.org/faq.html#working-copy-format-change\n"
- ),
- svn_dirent_local_style(wcroot_abspath, scratch_pool),
- format);
- }
-
- /* Auto-upgrade the SDB if possible. */
- if (format < SVN_WC__VERSION && auto_upgrade)
- SVN_ERR(svn_wc__upgrade_sdb(&format, wcroot_abspath, sdb, format,
- scratch_pool));
-
- /* Verify that no work items exists. If they do, then our integrity is
- suspect and, thus, we cannot use this database. */
- if (format >= SVN_WC__HAS_WORK_QUEUE && enforce_empty_wq)
- SVN_ERR(verify_no_work(sdb));
-
- *wcroot = apr_palloc(result_pool, sizeof(**wcroot));
-
- (*wcroot)->abspath = wcroot_abspath;
- (*wcroot)->sdb = sdb;
- (*wcroot)->wc_id = wc_id;
- (*wcroot)->format = format;
-
- /* SDB will be NULL for pre-NG working copies. We only need to run a
- cleanup when the SDB is present. */
- if (sdb != NULL)
- apr_pool_cleanup_register(result_pool, *wcroot, close_wcroot,
- apr_pool_cleanup_null);
- return SVN_NO_ERROR;
-}
-
-
/* Returns in PRISTINE_ABSPATH a new string allocated from RESULT_POOL,
holding the local absolute path to the file location that is dedicated
to hold CHECKSUM's pristine file, relating to the pristine store
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c?rev=946306&r1=946305&r2=946306&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c Wed May 19 17:49:18 2010
@@ -23,10 +23,60 @@
#define SVN_WC__I_AM_WC_DB
+#include "svn_dirent_uri.h"
+
+#include "wc.h"
#include "wc_db_pdh.h"
+#include "wc-queries.h"
+
+#include "svn_private_config.h"
+
+WC_QUERIES_SQL_DECLARE_STATEMENTS(statements);
+
+/* */
+static svn_error_t *
+verify_no_work(svn_sqlite__db_t *sdb)
+{
+ svn_sqlite__stmt_t *stmt;
+ svn_boolean_t have_row;
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_LOOK_FOR_WORK));
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+ SVN_ERR(svn_sqlite__reset(stmt));
+
+ if (have_row)
+ return svn_error_create(SVN_ERR_WC_CLEANUP_REQUIRED, NULL,
+ NULL /* nothing to add. */);
+
+ return SVN_NO_ERROR;
+}
+
+
+/* */
+static apr_status_t
+close_wcroot(void *data)
+{
+ svn_wc__db_wcroot_t *wcroot = data;
+ svn_error_t *err;
+
+ SVN_ERR_ASSERT_NO_RETURN(wcroot->sdb != NULL);
+
+ err = svn_sqlite__close(wcroot->sdb);
+ wcroot->sdb = NULL;
+ if (err)
+ {
+ apr_status_t result = err->apr_err;
+ svn_error_clear(err);
+ return result;
+ }
+
+ return APR_SUCCESS;
+}
+
+
svn_wc__db_pdh_t *
svn_wc__db_pdh_get_or_create(svn_wc__db_t *db,
const char *local_dir_abspath,
@@ -107,3 +157,91 @@ svn_wc__db_close(svn_wc__db_t *db)
return svn_error_return(svn_wc__db_close_many_wcroots(roots, db->state_pool,
scratch_pool));
}
+
+
+svn_error_t *
+svn_wc__db_pdh_create_wcroot(svn_wc__db_wcroot_t **wcroot,
+ const char *wcroot_abspath,
+ svn_sqlite__db_t *sdb,
+ apr_int64_t wc_id,
+ int format,
+ svn_boolean_t auto_upgrade,
+ svn_boolean_t enforce_empty_wq,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ if (sdb != NULL)
+ SVN_ERR(svn_sqlite__read_schema_version(&format, sdb, scratch_pool));
+
+ /* If we construct a wcroot, then we better have a format. */
+ SVN_ERR_ASSERT(format >= 1);
+
+ /* If this working copy is PRE-1.0, then simply bail out. */
+ if (format < 4)
+ {
+ return svn_error_createf(
+ SVN_ERR_WC_UNSUPPORTED_FORMAT, NULL,
+ _("Working copy format of '%s' is too old (%d); "
+ "please check out your working copy again"),
+ svn_dirent_local_style(wcroot_abspath, scratch_pool), format);
+ }
+
+ /* If this working copy is from a future version, then bail out. */
+ if (format > SVN_WC__VERSION)
+ {
+ return svn_error_createf(
+ SVN_ERR_WC_UNSUPPORTED_FORMAT, NULL,
+ _("This client is too old to work with the working copy at\n"
+ "'%s' (format %d).\n"
+ "You need to get a newer Subversion client. For more details, see\n"
+ " http://subversion.apache.org/faq.html#working-copy-format-change\n"
+ ),
+ svn_dirent_local_style(wcroot_abspath, scratch_pool),
+ format);
+ }
+
+ /* Auto-upgrade the SDB if possible. */
+ if (format < SVN_WC__VERSION && auto_upgrade)
+ SVN_ERR(svn_wc__upgrade_sdb(&format, wcroot_abspath, sdb, format,
+ scratch_pool));
+
+ /* Verify that no work items exists. If they do, then our integrity is
+ suspect and, thus, we cannot use this database. */
+ if (format >= SVN_WC__HAS_WORK_QUEUE && enforce_empty_wq)
+ SVN_ERR(verify_no_work(sdb));
+
+ *wcroot = apr_palloc(result_pool, sizeof(**wcroot));
+
+ (*wcroot)->abspath = wcroot_abspath;
+ (*wcroot)->sdb = sdb;
+ (*wcroot)->wc_id = wc_id;
+ (*wcroot)->format = format;
+
+ /* SDB will be NULL for pre-NG working copies. We only need to run a
+ cleanup when the SDB is present. */
+ if (sdb != NULL)
+ apr_pool_cleanup_register(result_pool, *wcroot, close_wcroot,
+ apr_pool_cleanup_null);
+ return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_wc__db_close_many_wcroots(apr_hash_t *roots,
+ apr_pool_t *state_pool,
+ apr_pool_t *scratch_pool)
+{
+ apr_hash_index_t *hi;
+
+ for (hi = apr_hash_first(scratch_pool, roots); hi; hi = apr_hash_next(hi))
+ {
+ svn_wc__db_wcroot_t *wcroot = svn__apr_hash_index_val(hi);
+ apr_status_t result;
+
+ result = apr_pool_cleanup_run(state_pool, wcroot, close_wcroot);
+ if (result != APR_SUCCESS)
+ return svn_error_wrap_apr(result, NULL);
+ }
+
+ return SVN_NO_ERROR;
+}
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pdh.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pdh.h?rev=946306&r1=946305&r2=946306&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pdh.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pdh.h Wed May 19 17:49:18 2010
@@ -122,4 +122,18 @@ svn_wc__db_close_many_wcroots(apr_hash_t
apr_pool_t *state_pool,
apr_pool_t *scratch_pool);
+
+/* Construct a new svn_wc__db_wcroot_t. The WCROOT_ABSPATH and SDB parameters
+ must have lifetime of at least RESULT_POOL. */
+svn_error_t *
+svn_wc__db_pdh_create_wcroot(svn_wc__db_wcroot_t **wcroot,
+ const char *wcroot_abspath,
+ svn_sqlite__db_t *sdb,
+ apr_int64_t wc_id,
+ int format,
+ svn_boolean_t auto_upgrade,
+ svn_boolean_t enforce_empty_wq,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
#endif /* WC_DB_PDH_H */