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/01/29 18:24:40 UTC
svn commit: r1440008 - in /subversion/trunk/subversion: libsvn_wc/upgrade.c
libsvn_wc/wc_db.c libsvn_wc/wc_db.h libsvn_wc/wc_db_private.h
libsvn_wc/wc_db_wcroot.c tests/cmdline/upgrade_tests.py
tests/libsvn_wc/entries-compat.c
Author: rhuijben
Date: Tue Jan 29 17:24:40 2013
New Revision: 1440008
URL: http://svn.apache.org/viewvc?rev=1440008&view=rev
Log:
Following up on the explicit 'svn upgrade' requirement, reinstate the option of
opening a wc.db without upgrading for the upgrade process itself. This allows the
upgrade code to use a limited subset of the wc_db api to avoid having to
reimplement code just for upgrades.
* subversion/libsvn_wc/upgrade.c
(bump_to_30): Obtain wc_db without upgrading to allow creating conflicts.
* subversion/libsvn_wc/wc_db.c
(svn_wc__db_to_relpath,
svn_wc__db_from_relpath,
svn_wc__db_get_wcroot): Apply the same check for wcroots using a new macro.
* subversion/libsvn_wc/wc_db.h
(svn_wc__db_open): Rename argument. Update documentation.
(svn_wc__db_to_relpath
svn_wc__db_from_relpath,
svn_wc__db_get_wcroot): Document non-upgraded compatibility.
* subversion/libsvn_wc/wc_db_private.h
(svn_wc__db_t): Remove auto upgrade variable (always FALSE), and introduce
verify_format and exclusive.
(svn_wc__db_pdh_create_wcroot): Rename argument.
(CHECK_MINIMAL_WCROOT): New macro.
* subversion/libsvn_wc/wc_db_wcroot.c
(svn_wc__db_open): Initialize variables that affect opening db files.
(svn_wc__db_pdh_create_wcroot): Remove upgrade code. Only verify versions.
(svn_wc__db_wcroot_parse_local_abspath): Use config from db instead of
reparsing it from inside a loop. Update caller.
* subversion/tests/cmdline/upgrade_tests.py
(upgrade_from_1_7): Rename to ...
(upgrade_from_1_7_conflict): ... this, update comment and remove XFail.
(test_list): Update reference.
* subversion/tests/libsvn_wc/entries-compat.c
(create_open): Update comment.
Modified:
subversion/trunk/subversion/libsvn_wc/upgrade.c
subversion/trunk/subversion/libsvn_wc/wc_db.c
subversion/trunk/subversion/libsvn_wc/wc_db.h
subversion/trunk/subversion/libsvn_wc/wc_db_private.h
subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c
subversion/trunk/subversion/tests/cmdline/upgrade_tests.py
subversion/trunk/subversion/tests/libsvn_wc/entries-compat.c
Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1440008&r1=1440007&r2=1440008&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Tue Jan 29 17:24:40 2013
@@ -1551,7 +1551,7 @@ bump_to_30(void *baton, svn_sqlite__db_t
svn_sqlite__stmt_t *stmt;
svn_wc__db_t *db; /* Read only temp db */
- SVN_ERR(svn_wc__db_open(&db, NULL, FALSE, FALSE,
+ SVN_ERR(svn_wc__db_open(&db, NULL, TRUE /* open_without_upgrade */, FALSE,
scratch_pool, scratch_pool));
SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
@@ -2155,17 +2155,21 @@ svn_wc_upgrade(svn_wc_context_t *wc_ctx,
SVN_ERR(svn_wc__db_open(&db, NULL /* ### config */, TRUE, FALSE,
scratch_pool, scratch_pool));
+
err = svn_wc__db_bump_format(&result_format, local_abspath, db,
scratch_pool);
if (err)
{
- if (err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED) /* pre-1.7 WC */
+ if (err->apr_err != SVN_ERR_WC_UPGRADE_REQUIRED)
{
- svn_error_clear(err);
- SVN_ERR(svn_wc__db_close(db));
+ return svn_error_trace(
+ svn_error_compose_create(
+ err,
+ svn_wc__db_close(db)));
}
- else
- return svn_error_trace(err);
+
+ svn_error_clear(err);
+ /* Pre 1.7: Fall through */
}
else
{
@@ -2188,10 +2192,6 @@ svn_wc_upgrade(svn_wc_context_t *wc_ctx,
'cleanup' with a new client will complete any outstanding
upgrade. */
- SVN_ERR(svn_wc__db_open(&db,
- NULL /* ### config */, TRUE, FALSE,
- scratch_pool, scratch_pool));
-
SVN_ERR(svn_wc__read_entries_old(&entries, local_abspath,
scratch_pool, scratch_pool));
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1440008&r1=1440007&r2=1440008&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Jan 29 17:24:40 2013
@@ -1565,7 +1565,7 @@ svn_wc__db_to_relpath(const char **local
/* This function is indirectly called from the upgrade code, so we
can't verify the wcroot here. Just check that it is not NULL */
- SVN_ERR_ASSERT(wcroot != NULL);
+ CHECK_MINIMAL_WCROOT(wcroot, wri_abspath, scratch_pool);
if (svn_dirent_is_ancestor(wcroot->abspath, local_abspath))
{
@@ -1597,7 +1597,11 @@ svn_wc__db_from_relpath(const char **loc
SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &unused_relpath, db,
wri_abspath, scratch_pool, scratch_pool));
- VERIFY_USABLE_WCROOT(wcroot);
+
+ /* This function is indirectly called from the upgrade code, so we
+ can't verify the wcroot here. Just check that it is not NULL */
+ CHECK_MINIMAL_WCROOT(wcroot, wri_abspath, scratch_pool);
+
*local_abspath = svn_dirent_join(wcroot->abspath,
local_relpath,
@@ -1621,12 +1625,7 @@ svn_wc__db_get_wcroot(const char **wcroo
/* Can't use VERIFY_USABLE_WCROOT, as this should be usable to detect
where call upgrade */
-
- if (wcroot == NULL)
- return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
- _("The node '%s' is not in a working copy."),
- svn_dirent_local_style(wri_abspath,
- scratch_pool));
+ CHECK_MINIMAL_WCROOT(wcroot, wri_abspath, scratch_pool);
*wcroot_abspath = apr_pstrdup(result_pool, wcroot->abspath);
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1440008&r1=1440007&r2=1440008&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Tue Jan 29 17:24:40 2013
@@ -229,11 +229,12 @@ typedef struct svn_wc__db_lock_t {
the administrative operation. It should live at least as long as the
RESULT_POOL parameter.
- When AUTO_UPGRADE is TRUE, then the working copy databases will be
- upgraded when possible (when an old database is found/detected during
- the operation of a wc_db API). If it is detected that a manual upgrade is
- required, then SVN_ERR_WC_UPGRADE_REQUIRED will be returned from that API.
- Passing FALSE will allow a bare minimum of APIs to function (most notably,
+ When OPEN_WITHOUT_UPGRADE is TRUE, then the working copy databases will
+ be opened even when an old database format is found/detected during
+ the operation of a wc_db API). If open_without_upgrade is FALSE and an
+ upgrade is required, then SVN_ERR_WC_UPGRADE_REQUIRED will be returned
+ from that API.
+ Passing TRUE will allow a bare minimum of APIs to function (most notably,
the temp_get_format() function will always return a value) since most of
these APIs expect a current-format database to be present.
@@ -257,7 +258,7 @@ typedef struct svn_wc__db_lock_t {
svn_error_t *
svn_wc__db_open(svn_wc__db_t **db,
svn_config_t *config,
- svn_boolean_t auto_upgrade,
+ svn_boolean_t open_without_upgrade,
svn_boolean_t enforce_empty_wq,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
@@ -315,6 +316,9 @@ svn_wc__db_init(svn_wc__db_t *db,
LOCAL_RELPATH will be allocated in RESULT_POOL. All other (temporary)
allocations will be made in SCRATCH_POOL.
+
+ This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
+ option.
*/
svn_error_t *
svn_wc__db_to_relpath(const char **local_relpath,
@@ -333,7 +337,10 @@ svn_wc__db_to_relpath(const char **local
LOCAL_ABSPATH will be allocated in RESULT_POOL. All other (temporary)
allocations will be made in SCRATCH_POOL.
-*/
+
+ This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
+ option.
+ */
svn_error_t *
svn_wc__db_from_relpath(const char **local_abspath,
svn_wc__db_t *db,
@@ -343,6 +350,9 @@ svn_wc__db_from_relpath(const char **loc
apr_pool_t *scratch_pool);
/* Compute the working copy root WCROOT_ABSPATH for WRI_ABSPATH using DB.
+
+ This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
+ option.
*/
svn_error_t *
svn_wc__db_get_wcroot(const char **wcroot_abspath,
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_private.h?rev=1440008&r1=1440007&r2=1440008&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_private.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_private.h Tue Jan 29 17:24:40 2013
@@ -38,13 +38,16 @@ struct svn_wc__db_t {
to figure out where we should look for the corresponding datastore. */
svn_config_t *config;
- /* Should we attempt to automatically upgrade the database when it is
+ /* Should we fail with SVN_ERR_WC_UPGRADE_REQUIRED when it is
opened, and found to be not-current? */
- svn_boolean_t auto_upgrade;
+ svn_boolean_t verify_format;
/* Should we ensure the WORK_QUEUE is empty when a WCROOT is opened? */
svn_boolean_t enforce_empty_wq;
+ /* Should we open Sqlite databases EXCLUSIVE */
+ svn_boolean_t exclusive;
+
/* Map a given working copy directory to its relevant data.
const char *local_abspath -> svn_wc__db_wcroot_t *wcroot */
apr_hash_t *dir_data;
@@ -118,7 +121,7 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_
svn_sqlite__db_t *sdb,
apr_int64_t wc_id,
int format,
- svn_boolean_t auto_upgrade,
+ svn_boolean_t verify_format,
svn_boolean_t enforce_empty_wq,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
@@ -148,6 +151,19 @@ svn_wc__db_wcroot_parse_local_abspath(sv
#define VERIFY_USABLE_WCROOT(wcroot) SVN_ERR_ASSERT( \
(wcroot) != NULL && (wcroot)->format == SVN_WC__VERSION)
+/* Check if the WCROOT is usable for light db operations such as path
+ calculations */
+#define CHECK_MINIMAL_WCROOT(wcroot, abspath, scratch_pool) \
+ do \
+ { \
+ if (wcroot == NULL) \
+ return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL, \
+ _("The node '%s' is not in a working copy."), \
+ svn_dirent_local_style(wri_abspath, \
+ scratch_pool)); \
+ } \
+ while (0)
+
/* Calculates the depth of the relpath below "" */
APR_INLINE static int
relpath_depth(const char *relpath)
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c?rev=1440008&r1=1440007&r2=1440008&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c Tue Jan 29 17:24:40 2013
@@ -188,20 +188,36 @@ close_wcroot(void *data)
svn_error_t *
svn_wc__db_open(svn_wc__db_t **db,
svn_config_t *config,
- svn_boolean_t auto_upgrade,
+ svn_boolean_t open_without_upgrade,
svn_boolean_t enforce_empty_wq,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
*db = apr_pcalloc(result_pool, sizeof(**db));
(*db)->config = config;
- (*db)->auto_upgrade = auto_upgrade;
+ (*db)->verify_format = !open_without_upgrade;
(*db)->enforce_empty_wq = enforce_empty_wq;
(*db)->dir_data = apr_hash_make(result_pool);
+ (*db)->state_pool = result_pool;
+
/* Don't need to initialize (*db)->parse_cache, due to the calloc above */
+ if (config)
+ {
+ svn_error_t *err;
+ svn_boolean_t sqlite_exclusive = FALSE;
- (*db)->state_pool = result_pool;
+ err = svn_config_get_bool(config, &sqlite_exclusive,
+ SVN_CONFIG_SECTION_WORKING_COPY,
+ SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE,
+ FALSE);
+ if (err)
+ {
+ svn_error_clear(err);
+ }
+ else
+ (*db)->exclusive = sqlite_exclusive;
+ }
return SVN_NO_ERROR;
}
@@ -240,7 +256,7 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_
svn_sqlite__db_t *sdb,
apr_int64_t wc_id,
int format,
- svn_boolean_t auto_upgrade,
+ svn_boolean_t verify_format,
svn_boolean_t enforce_empty_wq,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
@@ -278,7 +294,7 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_
/* 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 || (format < SVN_WC__VERSION && auto_upgrade)))
+ && (enforce_empty_wq || (format < SVN_WC__VERSION && verify_format)))
{
svn_error_t *err = verify_no_work(sdb);
if (err)
@@ -286,7 +302,7 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_
/* Special message for attempts to upgrade a 1.7-dev wc with
outstanding workqueue items. */
if (err->apr_err == SVN_ERR_WC_CLEANUP_REQUIRED
- && format < SVN_WC__VERSION && auto_upgrade)
+ && format < SVN_WC__VERSION && verify_format)
err = svn_error_quick_wrap(err, _("Cleanup with an older 1.7 "
"client before upgrading with "
"this client"));
@@ -295,23 +311,16 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_
}
/* Auto-upgrade the SDB if possible. */
- if (format < SVN_WC__VERSION)
+ if (format < SVN_WC__VERSION && verify_format)
{
- if (auto_upgrade)
- {
- if (format >= SVN_WC__WC_NG_VERSION)
- SVN_ERR(svn_wc__upgrade_sdb(&format, wcroot_abspath, sdb, format,
- scratch_pool));
- }
- else
- return svn_error_createf(SVN_ERR_WC_UPGRADE_REQUIRED, NULL,
- _("The working copy at '%s'\nis too old "
- "(format %d) to work with client version "
- "'%s' (expects format %d). You need to "
- "upgrade the working copy first.\n"),
- svn_dirent_local_style(wcroot_abspath,
- scratch_pool), format, SVN_VERSION,
- SVN_WC__VERSION);
+ return svn_error_createf(SVN_ERR_WC_UPGRADE_REQUIRED, NULL,
+ _("The working copy at '%s'\nis too old "
+ "(format %d) to work with client version "
+ "'%s' (expects format %d). You need to "
+ "upgrade the working copy first.\n"),
+ svn_dirent_local_style(wcroot_abspath,
+ scratch_pool),
+ format, SVN_VERSION, SVN_WC__VERSION);
}
*wcroot = apr_palloc(result_pool, sizeof(**wcroot));
@@ -524,18 +533,6 @@ svn_wc__db_wcroot_parse_local_abspath(sv
if (adm_subdir_kind == svn_node_dir)
{
- svn_boolean_t sqlite_exclusive = FALSE;
-
- err = svn_config_get_bool(db->config, &sqlite_exclusive,
- SVN_CONFIG_SECTION_WORKING_COPY,
- SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE,
- FALSE);
- if (err)
- {
- svn_error_clear(err);
- sqlite_exclusive = FALSE;
- }
-
/* We always open the database in read/write mode. If the database
isn't writable in the filesystem, SQLite will internally open
it as read-only, and we'll get an error if we try to do a write
@@ -546,7 +543,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
as the filesystem allows. */
err = svn_wc__db_util_open_db(&sdb, local_abspath, SDB_FILE,
svn_sqlite__mode_readwrite,
- sqlite_exclusive, NULL,
+ db->exclusive, NULL,
db->state_pool, scratch_pool);
if (err == NULL)
{
@@ -668,7 +665,7 @@ try_symlink_as_dir:
err = svn_wc__db_pdh_create_wcroot(wcroot,
apr_pstrdup(db->state_pool, local_abspath),
sdb, wc_id, FORMAT_FROM_SDB,
- db->auto_upgrade, db->enforce_empty_wq,
+ db->verify_format, db->enforce_empty_wq,
db->state_pool, scratch_pool);
if (err && (err->apr_err == SVN_ERR_WC_UNSUPPORTED_FORMAT ||
err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED) &&
@@ -705,6 +702,7 @@ try_symlink_as_dir:
SVN_ERR_WC_CORRUPT, err,
_("The working copy at '%s' is corrupt."),
svn_dirent_local_style(local_abspath, scratch_pool));
+ svn_error_clear(err);
if (3 == info.size)
{
@@ -735,7 +733,7 @@ try_symlink_as_dir:
SVN_ERR(svn_wc__db_pdh_create_wcroot(wcroot,
apr_pstrdup(db->state_pool, local_abspath),
NULL, UNKNOWN_WC_ID, wc_format,
- db->auto_upgrade, db->enforce_empty_wq,
+ db->verify_format, db->enforce_empty_wq,
db->state_pool, scratch_pool));
}
Modified: subversion/trunk/subversion/tests/cmdline/upgrade_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/upgrade_tests.py?rev=1440008&r1=1440007&r2=1440008&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/upgrade_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/upgrade_tests.py Tue Jan 29 17:24:40 2013
@@ -1262,16 +1262,15 @@ def upgrade_not_present_replaced(sbox):
svntest.actions.run_and_verify_update(sbox.wc_dir, expected_output,
None, expected_status)
-@XFail()
@Issue(4307)
-def upgrade_from_1_7(sbox):
- "upgrade from 1.7 WC (format 29)"
+def upgrade_from_1_7_conflict(sbox):
+ "upgrade from 1.7 WC with conflict (format 29)"
sbox.build(create_wc=False)
replace_sbox_with_tarfile(sbox, 'upgrade_from_1_7_wc.tar.bz2')
# The working copy contains a text conflict, and upgrading such
- # a working copy currently causes a pointless 'upgrade required' error.
+ # a working copy used to cause a pointless 'upgrade required' error.
svntest.actions.run_and_verify_svn(None, None, [], 'upgrade', sbox.wc_dir)
########################################################################
@@ -1325,7 +1324,7 @@ test_list = [ None,
upgrade_file_externals,
upgrade_missing_replaced,
upgrade_not_present_replaced,
- upgrade_from_1_7,
+ upgrade_from_1_7_conflict,
]
Modified: subversion/trunk/subversion/tests/libsvn_wc/entries-compat.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/entries-compat.c?rev=1440008&r1=1440007&r2=1440008&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/entries-compat.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/entries-compat.c Tue Jan 29 17:24:40 2013
@@ -332,7 +332,7 @@ create_open(svn_wc__db_t **db,
pool));
SVN_ERR(svn_wc__db_open(db,
NULL /* config */,
- FALSE /* auto_upgrade */,
+ FALSE /* not_upgraded_ok */,
TRUE /* enforce_empty_wq */,
pool, pool));