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 2010/07/21 18:57:18 UTC
svn commit: r966313 - in /subversion/trunk/subversion/libsvn_wc: upgrade.c
wc_db.c wc_db.h
Author: rhuijben
Date: Wed Jul 21 16:57:18 2010
New Revision: 966313
URL: http://svn.apache.org/viewvc?rev=966313&view=rev
Log:
Handle more corner cases of property upgrades, as found via our current
upgrade tests.
* subversion/libsvn_wc/upgrade.c
(read_propfile): Handle 0 byte files as an empty propery hash, just like
the code in props.c.
(wipe_obsolete_files): Always enable >= 17 checks and remove property file
directories when >= 18.
(migrate_node_props): Add wcroot path argument.
(upgrade_to_wcng): Move comment down to the right location (after
upgrade to 17).
* subversion/libsvn_wc/wc_db.c
(prop_upgrade_trees): Fetch base_presence, to allow determining the
replaced status.
(svn_wc__db_upgrade_apply_props): Accept dir_abspath, to enhance issue
#2530 error. Only show this error if the node is replaced; not when
we just have a not-present node. Handle incomplete in the same way
as normal. Compare working_props before storing them.
* subversion/libsvn_wc/wc_db.h
(svn_wc__db_upgrade_apply_props): Add dir_abspath argument.
Modified:
subversion/trunk/subversion/libsvn_wc/upgrade.c
subversion/trunk/subversion/libsvn_wc/wc_db.c
subversion/trunk/subversion/libsvn_wc/wc_db.h
Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=966313&r1=966312&r2=966313&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Wed Jul 21 16:57:18 2010
@@ -90,20 +90,33 @@ read_propfile(apr_hash_t **props,
{
svn_error_t *err;
svn_stream_t *stream;
+ apr_finfo_t finfo;
- err = svn_stream_open_readonly(&stream, propfile_abspath,
- scratch_pool, scratch_pool);
- if (err)
- {
- if (!APR_STATUS_IS_ENOENT(err->apr_err))
- return svn_error_return(err);
+ err = svn_io_stat(&finfo, propfile_abspath, APR_FINFO_SIZE, scratch_pool);
+ if (err
+ && (APR_STATUS_IS_ENOENT(err->apr_err)
+ || APR_STATUS_IS_ENOTDIR(err->apr_err)))
+ {
svn_error_clear(err);
/* The propfile was not there. Signal with a NULL. */
*props = NULL;
return SVN_NO_ERROR;
}
+ else
+ SVN_ERR(err);
+
+ /* A 0-bytes file signals an empty property list.
+ (mostly used for revert-props) */
+ if (finfo.size == 0)
+ {
+ *props = apr_hash_make(result_pool);
+ return SVN_NO_ERROR;
+ }
+
+ SVN_ERR(svn_stream_open_readonly(&stream, propfile_abspath,
+ scratch_pool, scratch_pool));
/* ### does this function need to be smarter? will we see zero-length
### files? see props.c::load_props(). there may be more work here.
@@ -468,16 +481,14 @@ wipe_obsolete_files(const char *wcroot_a
scratch_pool),
TRUE, scratch_pool));
-#if (SVN_WC__VERSION >= 17)
/* Remove the old text-base directory and the old text-base files. */
svn_error_clear(svn_io_remove_dir2(
svn_wc__adm_child(wcroot_abspath,
TEXT_BASE_SUBDIR,
scratch_pool),
FALSE, NULL, NULL, scratch_pool));
-#endif
-#if 0 /* ### NOT READY TO WIPE THESE FILES!! */
+#if (SVN_WC__VERSION >= 18)
/* Remove the old properties files... whole directories at a time. */
svn_error_clear(svn_io_remove_dir2(
svn_wc__adm_child(wcroot_abspath,
@@ -964,7 +975,7 @@ migrate_node_props(const char *wcroot_ab
scratch_pool, scratch_pool));
return svn_error_return(svn_wc__db_upgrade_apply_props(
- sdb, name,
+ sdb, wcroot_abspath, name,
base_props, revert_props, working_props,
original_format,
scratch_pool));
@@ -1338,21 +1349,14 @@ upgrade_to_wcng(svn_wc__db_t *db,
SVN_ERR(svn_wc__db_upgrade_apply_dav_cache(sdb, all_wcprops, iterpool));
}
+ SVN_ERR(migrate_text_bases(dir_abspath, sdb, iterpool));
+
+#if (SVN_WC__VERSION >= 18)
/* Upgrade all the properties (including "this dir").
Note: this must come AFTER the entries have been migrated into the
database. The upgrade process needs the children in BASE_NODE and
WORKING_NODE, and to examine the resultant WORKING state. */
-#if 0
- /* ### not quite yet */
- SVN_ERR(migrate_props(dir_abspath, sdb, old_format, iterpool));
-#endif
-
-#if (SVN_WC__VERSION >= 17)
- SVN_ERR(migrate_text_bases(dir_abspath, sdb, iterpool));
-#endif
-
-#if (SVN_WC__VERSION >= 18)
SVN_ERR(migrate_props(dir_abspath, sdb, old_format, iterpool));
#endif
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=966313&r1=966312&r2=966313&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Jul 21 16:57:18 2010
@@ -1275,6 +1275,7 @@ which_trees_exist(svn_boolean_t *base_ex
we return a WC_ID and verify some additional constraints. */
static svn_error_t *
prop_upgrade_trees(svn_boolean_t *base_exists,
+ svn_wc__db_status_t *base_presence,
svn_boolean_t *working_exists,
svn_wc__db_status_t *work_presence,
apr_int64_t *wc_id,
@@ -1306,6 +1307,7 @@ prop_upgrade_trees(svn_boolean_t *base_e
else
{
*base_exists = TRUE; /* value == 0 */
+ *base_presence = svn_sqlite__column_token(stmt, 1, presence_map);
}
/* Return the WC_ID that was assigned. */
@@ -1322,6 +1324,8 @@ prop_upgrade_trees(svn_boolean_t *base_e
fetch the 'presence' column value. */
if (svn_sqlite__column_int(stmt, 0))
*work_presence = svn_sqlite__column_token(stmt, 1, presence_map);
+ else
+ *base_presence = svn_sqlite__column_token(stmt, 1, presence_map);
/* During an upgrade, there should be just one working copy, so both
rows should refer to the same value. */
@@ -6805,6 +6809,7 @@ svn_wc__db_upgrade_apply_dav_cache(svn_s
svn_error_t *
svn_wc__db_upgrade_apply_props(svn_sqlite__db_t *sdb,
+ const char *dir_abspath,
const char *local_relpath,
apr_hash_t *base_props,
apr_hash_t *revert_props,
@@ -6813,6 +6818,7 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
apr_pool_t *scratch_pool)
{
svn_boolean_t have_base;
+ svn_wc__db_status_t base_presence;
svn_boolean_t have_work;
svn_wc__db_status_t work_presence;
apr_int64_t wc_id;
@@ -6847,15 +6853,18 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
*/
/* Collect information about this node. */
- SVN_ERR(prop_upgrade_trees(&have_base, &have_work, &work_presence, &wc_id,
- sdb, local_relpath));
+ SVN_ERR(prop_upgrade_trees(&have_base, &base_presence,
+ &have_work, &work_presence,
+ &wc_id, sdb, local_relpath));
/* Detect the buggy scenario described above. We cannot upgrade this
working copy if we have no idea where BASE_PROPS should go. */
if (original_format > SVN_WC__NO_REVERT_FILES
&& revert_props == NULL
&& have_work
- && work_presence == svn_wc__db_status_normal)
+ && work_presence == svn_wc__db_status_normal
+ && have_base
+ && base_presence != svn_wc__db_status_not_present)
{
/* There should be REVERT_PROPS, so it appears that we just ran into
the described bug. Sigh. */
@@ -6863,10 +6872,14 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
_("The properties of '%s' are in an "
"indeterminate state and cannot be "
"upgraded. See issue #2530."),
- local_relpath);
+ svn_dirent_local_style(
+ svn_dirent_join(dir_abspath, local_relpath,
+ scratch_pool), scratch_pool));
}
- if (have_base)
+ if (have_base
+ && (base_presence == svn_wc__db_status_normal
+ || base_presence == svn_wc__db_status_incomplete))
{
apr_hash_t *props = revert_props ? revert_props : base_props;
@@ -6889,8 +6902,9 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
/* Do we have a replaced node? It has properties: an empty set for
adds, and a non-empty set for copies/moves. */
- if (work_presence == svn_wc__db_status_normal
- && original_format > SVN_WC__NO_REVERT_FILES)
+ if (original_format > SVN_WC__NO_REVERT_FILES
+ && (work_presence == svn_wc__db_status_normal
+ || work_presence == svn_wc__db_status_incomplete))
{
SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
STMT_UPDATE_WORKING_PROPS));
@@ -6907,6 +6921,17 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
}
/* If there are WORKING_PROPS, then they always go into ACTUAL_NODE. */
+ if (working_props != NULL
+ && base_props != NULL)
+ {
+ apr_array_header_t *diffs;
+
+ SVN_ERR(svn_prop_diffs(&diffs, working_props, base_props, scratch_pool));
+
+ if (diffs->nelts == 0)
+ working_props = NULL; /* No differences */
+ }
+
if (working_props != NULL)
{
struct set_props_baton spb = { 0 };
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=966313&r1=966312&r2=966313&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Wed Jul 21 16:57:18 2010
@@ -2099,6 +2099,7 @@ svn_wc__db_upgrade_apply_dav_cache(svn_s
*/
svn_error_t *
svn_wc__db_upgrade_apply_props(svn_sqlite__db_t *sdb,
+ const char *dir_abspath,
const char *local_relpath,
apr_hash_t *base_props,
apr_hash_t *revert_props,