Author: stsp
Date: Thu Dec 6 23:43:42 2012
New Revision: 1418133
URL: http://svn.apache.org/viewvc?rev=1418133&view=rev
Log:
* subversion/libsvn_wc/upgrade.c
(svn_wc_upgrade): Don't scan upwards for a wcroot during 'svn upgrade'
to prevent accidental automatic upgrades of working copies at parent
paths when ugprading nested WCs.
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=1418133&r1=1418132&r2=1418133&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Dec 6 23:43:42 2012
@@ -14611,29 +14611,46 @@ svn_wc__db_bump_format(int *result_forma
svn_wc__db_t *db,
apr_pool_t *scratch_pool)
{
+ svn_sqlite__db_t *sdb;
+ svn_error_t *err;
+ int format;
- svn_wc__db_wcroot_t *wcroot;
- const char *local_relpath;
+ /* Do not scan upwards for a working copy root here to prevent accidental
+ * upgrades of any working copies the WCROOT might be nested in.
+ * Just try to open a DB at the specified path instead. */
+ err = svn_wc__db_util_open_db(&sdb, wcroot_abspath, SDB_FILE,
+ svn_sqlite__mode_readwrite,
+ TRUE, /* exclusive */
+ NULL, /* my statements */
+ scratch_pool, scratch_pool);
+ if (err)
+ {
+ svn_error_t *err2;
+ apr_hash_t *entries;
- SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath,
- db, wcroot_abspath,
- scratch_pool, scratch_pool));
+ /* Could not open an sdb. Check for an entries file instead. */
+ err2 = svn_wc__read_entries_old(&entries, wcroot_abspath,
+ scratch_pool, scratch_pool);
+ if (err2 || apr_hash_count(entries) == 0)
+ return svn_error_createf(SVN_ERR_WC_INVALID_OP_ON_CWD,
+ svn_error_compose_create(err, err2),
+ _("Can't upgrade '%s' as it is not a working copy root"),
+ svn_dirent_local_style(wcroot_abspath, scratch_pool));
- /* 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);
+ /* An entries file was found. This is a pre-wc-ng working copy
+ * so suggest an upgrade. */
+ return svn_error_createf(SVN_ERR_WC_UPGRADE_REQUIRED, err,
+ _("Working copy '%s' is too old and must be upgraded to "
+ "at least format %d, as created by Subversion %s"),
+ svn_dirent_local_style(wcroot_abspath, scratch_pool),
+ SVN_WC__WC_NG_VERSION,
+ svn_wc__version_string_from_format(SVN_WC__WC_NG_VERSION));
+ }
- /* Reject attempts to upgrade subdirectories of a working copy. */
- if (strcmp(wcroot_abspath, wcroot->abspath) != 0)
- return svn_error_createf(
- SVN_ERR_WC_INVALID_OP_ON_CWD, NULL,
- _("Can't upgrade '%s' as it is not a working copy root,"
- " the root is '%s'"),
- svn_dirent_local_style(wcroot_abspath, scratch_pool),
- svn_dirent_local_style(wcroot->abspath, scratch_pool));
+ SVN_ERR(svn_sqlite__read_schema_version(&format, sdb, scratch_pool));
+ SVN_ERR(svn_wc__upgrade_sdb(result_format, wcroot_abspath,
+ sdb, format, scratch_pool));
+ SVN_ERR(svn_sqlite__close(sdb));
- SVN_ERR(svn_wc__upgrade_sdb(result_format, wcroot->abspath,
- wcroot->sdb, wcroot->format,
- scratch_pool));
return SVN_NO_ERROR;
}