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 2010/10/18 14:03:36 UTC
svn commit: r1023754 - in /subversion/trunk/subversion: libsvn_wc/props.c
libsvn_wc/update_editor.c libsvn_wc/wc_db.c libsvn_wc/wc_db.h
tests/libsvn_wc/db-test.c
Author: julianfoad
Date: Mon Oct 18 12:03:36 2010
New Revision: 1023754
URL: http://svn.apache.org/viewvc?rev=1023754&view=rev
Log:
When setting ACTUAL_NODE properties, encapsulate in a transaction the
reading of pristine properties and the comparison of the new actual
properties with them. Previously, the caller had to know and pass the
correct pristine properties.
A follow-up to r1023708.
* subversion/libsvn_wc/wc_db.h
(svn_wc__db_op_set_props): Don't take a pristine props parameter.
* subversion/libsvn_wc/wc_db.c
(set_props_baton): Replace wc_id with pdh.
(set_actual_props): New function, extracted from set_props_txn.
(set_props_txn): Compare with pristine props before setting.
(svn_wc__db_op_set_props): Don't take pristine props or compare against
them; let set_props_txn() find them and compare against them.
(db_read_pristine_props): New function, extracted from ...
(svn_wc__db_read_pristine_props): ... here.
(svn_wc__db_upgrade_apply_props): Adjust for the above changes: call
set_actual_props() instead of set_props_txn().
* subversion/libsvn_wc/props.c
(immediate_install_props): Don't read or pass the pristine props here.
(svn_wc__perform_props_merge): Don't pass the pristine props.
* subversion/libsvn_wc/update_editor.c
(close_directory, close_file, svn_wc_add_repos_file4): Don't pass the
pristine props.
* subversion/tests/libsvn_wc/db-test.c
(validate_node): Don't pass the pristine props.
Modified:
subversion/trunk/subversion/libsvn_wc/props.c
subversion/trunk/subversion/libsvn_wc/update_editor.c
subversion/trunk/subversion/libsvn_wc/wc_db.c
subversion/trunk/subversion/libsvn_wc/wc_db.h
subversion/trunk/subversion/tests/libsvn_wc/db-test.c
Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=1023754&r1=1023753&r2=1023754&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Mon Oct 18 12:03:36 2010
@@ -142,15 +142,8 @@ immediate_install_props(svn_wc__db_t *db
apr_hash_t *working_props,
apr_pool_t *scratch_pool)
{
- apr_hash_t *base_props;
-
- /* ### no pristines should be okay. */
- SVN_ERR_W(svn_wc__db_read_pristine_props(&base_props, db, local_abspath,
- scratch_pool, scratch_pool),
- _("Failed to load pristine properties"));
-
SVN_ERR(svn_wc__db_op_set_props(db, local_abspath,
- working_props, base_props,
+ working_props,
NULL /* conflict */,
NULL, /* work_items */
scratch_pool));
@@ -351,7 +344,6 @@ svn_wc__perform_props_merge(svn_wc_notif
new_base_props, pool));
SVN_ERR(svn_wc__db_op_set_props(db, local_abspath, actual_props,
- new_base_props,
NULL, NULL, pool));
}
#else
@@ -360,7 +352,6 @@ svn_wc__perform_props_merge(svn_wc_notif
U_("base_merge=TRUE is no longer supported"));
SVN_ERR(svn_wc__db_op_set_props(db, local_abspath, new_actual_props,
- new_base_props,
NULL /* conflict */,
NULL /* work_item */,
pool));
Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1023754&r1=1023753&r2=1023754&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Mon Oct 18 12:03:36 2010
@@ -2928,7 +2928,7 @@ close_directory(void *dir_baton,
SVN_ERR_ASSERT(new_actual_props != NULL);
SVN_ERR(svn_wc__db_op_set_props(eb->db, db->local_abspath,
- new_actual_props, new_base_props,
+ new_actual_props,
NULL /* conflict */,
NULL /* work_items */,
pool));
@@ -4577,7 +4577,7 @@ close_file(void *file_baton,
SVN_ERR_ASSERT(new_actual_props != NULL);
SVN_ERR(svn_wc__db_op_set_props(eb->db, fb->local_abspath,
- new_actual_props, new_base_props,
+ new_actual_props,
NULL /* conflict */,
NULL /* work_item */,
pool));
@@ -5811,7 +5811,7 @@ svn_wc_add_repos_file4(svn_wc_context_t
/* ### if below fails, then the above db change would remain :-( */
SVN_ERR(svn_wc__db_op_set_props(db, local_abspath,
- new_props, new_base_props,
+ new_props,
NULL /* conflict */,
all_work_items,
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=1023754&r1=1023753&r2=1023754&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Mon Oct 18 12:03:36 2010
@@ -234,6 +234,13 @@ insert_incomplete_children(svn_sqlite__d
apr_int64_t op_depth,
apr_pool_t *scratch_pool);
+static svn_error_t *
+db_read_pristine_props(apr_hash_t **props,
+ svn_wc__db_pdh_t *pdh,
+ const char *local_relpath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
/* Return the absolute path, in local path style, of LOCAL_RELPATH in WCROOT. */
static const char *
@@ -3301,7 +3308,7 @@ struct set_props_baton
{
apr_hash_t *props;
- apr_int64_t wc_id;
+ svn_wc__db_pdh_t *pdh;
const char *local_relpath;
const svn_skel_t *conflict;
@@ -3309,6 +3316,38 @@ struct set_props_baton
};
+/* Set the ACTUAL_NODE properties column for (WC_ID, LOCAL_RELPATH) to
+ * PROPS. */
+static svn_error_t *
+set_actual_props(apr_int64_t wc_id,
+ const char *local_relpath,
+ apr_hash_t *props,
+ svn_sqlite__db_t *db,
+ apr_pool_t *scratch_pool)
+{
+ svn_sqlite__stmt_t *stmt;
+ int affected_rows;
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, db, STMT_UPDATE_ACTUAL_PROPS));
+ SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, local_relpath));
+ SVN_ERR(svn_sqlite__bind_properties(stmt, 3, props, scratch_pool));
+ SVN_ERR(svn_sqlite__update(&affected_rows, stmt));
+
+ if (affected_rows == 1 || !props)
+ return SVN_NO_ERROR; /* We are done */
+
+ /* We have to insert a row in ACTUAL */
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, db, STMT_INSERT_ACTUAL_PROPS));
+ SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, local_relpath));
+ if (*local_relpath != '\0')
+ SVN_ERR(svn_sqlite__bind_text(stmt, 3,
+ svn_relpath_dirname(local_relpath,
+ scratch_pool)));
+ SVN_ERR(svn_sqlite__bind_properties(stmt, 4, props, scratch_pool));
+ return svn_error_return(svn_sqlite__step_done(stmt));
+}
+
/* Set the 'properties' column in the 'ACTUAL_NODE' table to BATON->props.
Create an entry in the ACTUAL table for the node if it does not yet
have one.
@@ -3318,8 +3357,7 @@ static svn_error_t *
set_props_txn(void *baton, svn_sqlite__db_t *db, apr_pool_t *scratch_pool)
{
struct set_props_baton *spb = baton;
- svn_sqlite__stmt_t *stmt;
- int affected_rows;
+ apr_hash_t *pristine_props;
/* ### we dunno what to do with CONFLICT yet. */
SVN_ERR_ASSERT(spb->conflict == NULL);
@@ -3327,31 +3365,31 @@ set_props_txn(void *baton, svn_sqlite__d
/* First order of business: insert all the work items. */
SVN_ERR(add_work_items(db, spb->work_items, scratch_pool));
- SVN_ERR(svn_sqlite__get_statement(&stmt, db, STMT_UPDATE_ACTUAL_PROPS));
- SVN_ERR(svn_sqlite__bindf(stmt, "is", spb->wc_id, spb->local_relpath));
- SVN_ERR(svn_sqlite__bind_properties(stmt, 3, spb->props, scratch_pool));
- SVN_ERR(svn_sqlite__update(&affected_rows, stmt));
+ /* Check if the props are modified. If no changes, then wipe out the
+ ACTUAL props. PRISTINE_PROPS==NULL means that any
+ ACTUAL props are okay as provided, so go ahead and set them. */
+ SVN_ERR(db_read_pristine_props(&pristine_props, spb->pdh, spb->local_relpath,
+ scratch_pool, scratch_pool));
+ if (spb->props && pristine_props)
+ {
+ apr_array_header_t *prop_diffs;
- if (affected_rows == 1 || !spb->props)
- return SVN_NO_ERROR; /* We are done */
+ SVN_ERR(svn_prop_diffs(&prop_diffs, spb->props, pristine_props,
+ scratch_pool));
+ if (prop_diffs->nelts == 0)
+ spb->props = NULL;
+ }
- /* We have to insert a row in ACTUAL */
+ SVN_ERR(set_actual_props(spb->pdh->wcroot->wc_id, spb->local_relpath,
+ spb->props, db, scratch_pool));
- SVN_ERR(svn_sqlite__get_statement(&stmt, db, STMT_INSERT_ACTUAL_PROPS));
- SVN_ERR(svn_sqlite__bindf(stmt, "is", spb->wc_id, spb->local_relpath));
- if (*spb->local_relpath != '\0')
- SVN_ERR(svn_sqlite__bind_text(stmt, 3,
- svn_relpath_dirname(spb->local_relpath,
- scratch_pool)));
- SVN_ERR(svn_sqlite__bind_properties(stmt, 4, spb->props, scratch_pool));
- return svn_error_return(svn_sqlite__step_done(stmt));
+ return SVN_NO_ERROR;
}
svn_error_t *
svn_wc__db_op_set_props(svn_wc__db_t *db,
const char *local_abspath,
apr_hash_t *props,
- apr_hash_t *pristine_props,
const svn_skel_t *conflict,
const svn_skel_t *work_items,
apr_pool_t *scratch_pool)
@@ -3366,21 +3404,8 @@ svn_wc__db_op_set_props(svn_wc__db_t *db
scratch_pool, scratch_pool));
VERIFY_USABLE_PDH(pdh);
- /* Check if the props are modified. If no changes, then wipe out the
- ACTUAL props. PRISTINE_PROPS==NULL means the caller knows that any
- ACTUAL props are okay as provided, so go ahead and set them. */
- if (props && pristine_props)
- {
- apr_array_header_t *prop_diffs;
-
- SVN_ERR(svn_prop_diffs(&prop_diffs, props, pristine_props,
- scratch_pool));
- if (prop_diffs->nelts == 0)
- props = NULL;
- }
-
spb.props = props;
- spb.wc_id = pdh->wcroot->wc_id;
+ spb.pdh = pdh;
spb.conflict = conflict;
spb.work_items = work_items;
@@ -5035,19 +5060,20 @@ svn_wc__db_read_props(apr_hash_t **props
}
-svn_error_t *
-svn_wc__db_read_pristine_props(apr_hash_t **props,
- svn_wc__db_t *db,
- const char *local_abspath,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
+static svn_error_t *
+db_read_pristine_props(apr_hash_t **props,
+ svn_wc__db_pdh_t *pdh,
+ const char *local_relpath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
svn_sqlite__stmt_t *stmt;
svn_boolean_t have_row;
svn_wc__db_status_t presence;
- SVN_ERR(get_statement_for_path(&stmt, db, local_abspath,
- STMT_SELECT_NODE_PROPS, scratch_pool));
+ SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, STMT_SELECT_NODE_PROPS));
+ SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath));
+
SVN_ERR(svn_sqlite__step(&have_row, stmt));
if (!have_row)
@@ -5055,7 +5081,8 @@ svn_wc__db_read_pristine_props(apr_hash_
return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND,
svn_sqlite__reset(stmt),
_("The node '%s' was not found."),
- svn_dirent_local_style(local_abspath,
+ path_for_error_message(pdh->wcroot,
+ local_relpath,
scratch_pool));
}
@@ -5096,6 +5123,29 @@ svn_wc__db_read_pristine_props(apr_hash_
svn_error_t *
+svn_wc__db_read_pristine_props(apr_hash_t **props,
+ svn_wc__db_t *db,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ svn_wc__db_pdh_t *pdh;
+ const char *local_relpath;
+
+ SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+ SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+ local_abspath, svn_sqlite__mode_readwrite,
+ scratch_pool, scratch_pool));
+ VERIFY_USABLE_PDH(pdh);
+
+ SVN_ERR(db_read_pristine_props(props, pdh, local_relpath,
+ result_pool, scratch_pool));
+ return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
svn_wc__db_read_children(const apr_array_header_t **children,
svn_wc__db_t *db,
const char *local_abspath,
@@ -6514,13 +6564,8 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
if (working_props != NULL)
{
- struct set_props_baton spb = { 0 };
-
- spb.props = working_props;
- spb.wc_id = wc_id;
- spb.local_relpath = local_relpath;
- /* NULL for .conflict and .work_items */
- SVN_ERR(set_props_txn(&spb, sdb, scratch_pool));
+ SVN_ERR(set_actual_props(wc_id, local_relpath, working_props,
+ sdb, scratch_pool));
}
return SVN_NO_ERROR;
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1023754&r1=1023753&r2=1023754&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Mon Oct 18 12:03:36 2010
@@ -1125,14 +1125,6 @@ svn_wc__db_op_add_symlink(svn_wc__db_t *
If PROPS is NULL, set the properties to be the same as the pristine
properties.
- PRISTINE_PROPS must be the pristine props against which the actual props
- may be elided in the DB, or NULL if the caller knows that the actual
- props should not be elided.
-
- ### TODO: The caller should not have to provide PRISTINE_PROPS.
- Encapsulate this functionality, either at this level or in a higher-
- level API.
-
CONFLICT is used to register a conflict on this node at the same time
the properties are changed.
@@ -1151,7 +1143,6 @@ svn_error_t *
svn_wc__db_op_set_props(svn_wc__db_t *db,
const char *local_abspath,
apr_hash_t *props,
- apr_hash_t *pristine_props,
const svn_skel_t *conflict,
const svn_skel_t *work_items,
apr_pool_t *scratch_pool);
Modified: subversion/trunk/subversion/tests/libsvn_wc/db-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/db-test.c?rev=1023754&r1=1023753&r2=1023754&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/db-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/db-test.c Mon Oct 18 12:03:36 2010
@@ -607,7 +607,7 @@ validate_node(svn_wc__db_t *db,
{
apr_hash_t *actual_props = apr_hash_copy(scratch_pool, props);
apr_hash_set(actual_props, "p999", APR_HASH_KEY_STRING, value);
- SVN_ERR(svn_wc__db_op_set_props(db, path, actual_props, props,
+ SVN_ERR(svn_wc__db_op_set_props(db, path, actual_props,
NULL, NULL, scratch_pool));
SVN_ERR(svn_wc__db_read_props(&props, db, path,
scratch_pool, scratch_pool));