Author: gstein
Date: Fri Apr 23 22:45:13 2010
New Revision: 937546
URL: http://svn.apache.org/viewvc?rev=937546&view=rev
Log:
Alter the control flow in the prop merging functions. Just return a
boolean, CONFLICT_REMAINS, if an unresolved conflict remains on the
given property. We can generate a message for it later, so we don't
have to return it in a CONFLICT param any more.
Also eliminated the CANCEL_FUNC/BATON from the call stack, since only the
topmost function loops and the called funcs do not otherwise require the
cancellation. We can simply do it at the top-level.
* subversion/libsvn_wc/props.c:
(maybe_generate_propconflict): remove CANCEL_FUNC/BATON params and the
calling of that function
(apply_single_prop_add, apply_single_prop_delete,
apply_single_mergeinfo_prop_change,
apply_single_generic_prop_change): remove CONFLICT and
CANCEL_FUNC/BATON. add CONFLICT_REMAINS. update calls to
maybe_generate_propconflict accordingly. remove generation of
the conflict message.
(apply_single_prop_change): adjust params and the calls to
apply_single_*_prop_change.
(svn_wc__merge_props): toss CONFLICT in favor of CONFLICT_REMAINS.
update calls into prop merging functions. if a conflict remains, then
generate the message and stick it into the prop rej file. add a check
with the CANCEL_FUNC/BATON.
Modified:
subversion/trunk/subversion/libsvn_wc/props.c
Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=937546&r1=937545&r2=937546&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Fri Apr 23 22:45:13 2010
@@ -907,12 +907,11 @@ set_prop_merge_state(svn_wc_notify_state
* intent-to-delete.
*
* If the callback isn't available, or if it responds with
- * 'choose_postpone', then set *CONFLICT_REMAINS to true and return.
+ * 'choose_postpone', then set *CONFLICT_REMAINS to TRUE and return.
*
* If the callback responds with a choice of 'base', 'theirs', 'mine',
* or 'merged', then install the proper value into WORKING_PROPS and
- * set *CONFLICT_REMAINS to false.
- *
+ * set *CONFLICT_REMAINS to FALSE.
*/
static svn_error_t *
maybe_generate_propconflict(svn_boolean_t *conflict_remains,
@@ -929,8 +928,6 @@ maybe_generate_propconflict(svn_boolean_
const svn_string_t *working_val,
svn_wc_conflict_resolver_func_t conflict_func,
void *conflict_baton,
- svn_cancel_func_t cancel_func,
- void *cancel_baton,
svn_boolean_t dry_run,
apr_pool_t *scratch_pool)
{
@@ -940,9 +937,6 @@ maybe_generate_propconflict(svn_boolean_
svn_wc_conflict_description2_t *cdesc;
const char *dirpath = svn_dirent_dirname(local_abspath, filepool);
- if (cancel_func)
- SVN_ERR(cancel_func(cancel_baton));
-
if (! conflict_func || dry_run)
{
/* Just postpone the conflict. */
@@ -1147,7 +1141,7 @@ maybe_generate_propconflict(svn_boolean_
/* Add the property with name PROPNAME to the set of WORKING_PROPS on
- * PATH, setting *STATE or *CONFLICT according to merge outcomes.
+ * PATH, setting *STATE or *CONFLICT_REMAINS according to merge outcomes.
*
* *STATE is an input and output parameter, its value is to be
* set using set_merge_prop_state().
@@ -1162,7 +1156,7 @@ maybe_generate_propconflict(svn_boolean_
*/
static svn_error_t *
apply_single_prop_add(svn_wc_notify_state_t *state,
- svn_string_t **conflict,
+ svn_boolean_t *conflict_remains,
svn_wc__db_t *db,
const char *local_abspath,
const svn_wc_conflict_version_t *left_version,
@@ -1174,17 +1168,16 @@ apply_single_prop_add(svn_wc_notify_stat
const svn_string_t *new_val,
svn_wc_conflict_resolver_func_t conflict_func,
void *conflict_baton,
- svn_cancel_func_t cancel_func,
- void *cancel_baton,
svn_boolean_t dry_run,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- svn_boolean_t got_conflict = FALSE;
svn_string_t *working_val
= apr_hash_get(working_props, propname, APR_HASH_KEY_STRING);
+ *conflict_remains = FALSE;
+
if (working_val)
{
/* the property already exists in working_props... */
@@ -1210,41 +1203,29 @@ apply_single_prop_add(svn_wc_notify_stat
}
else
{
- SVN_ERR(maybe_generate_propconflict(&got_conflict, db,
- local_abspath,
+ SVN_ERR(maybe_generate_propconflict(conflict_remains,
+ db, local_abspath,
left_version, right_version,
is_dir,
propname, working_props,
NULL, new_val,
base_val, working_val,
- conflict_func,
conflict_baton,
- cancel_func, cancel_baton,
+ conflict_func,
+ conflict_baton,
dry_run, scratch_pool));
- if (got_conflict)
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to add new property '%s' with value "
- "'%s',\nbut property already exists with value '%s'."),
- propname, new_val->data, working_val->data);
}
}
}
else if (base_val)
{
- SVN_ERR(maybe_generate_propconflict(&got_conflict, db, local_abspath,
+ SVN_ERR(maybe_generate_propconflict(conflict_remains,
+ db, local_abspath,
left_version, right_version,
is_dir, propname,
working_props, NULL, new_val,
base_val, NULL,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
dry_run, scratch_pool));
- if (got_conflict)
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to create property '%s' with value '%s',\n"
- "but it has been locally deleted."),
- propname, new_val->data);
}
else /* property doesn't yet exist in working_props... */
/* so just set it */
@@ -1255,7 +1236,7 @@ apply_single_prop_add(svn_wc_notify_stat
/* Delete the property with name PROPNAME from the set of
- * WORKING_PROPS on PATH, setting *STATE or *CONFLICT according to
+ * WORKING_PROPS on PATH, setting *STATE or *CONFLICT_REMAINS according to
* merge outcomes.
*
* *STATE is an input and output parameter, its value is to be
@@ -1272,7 +1253,7 @@ apply_single_prop_add(svn_wc_notify_stat
*/
static svn_error_t *
apply_single_prop_delete(svn_wc_notify_state_t *state,
- svn_string_t **conflict,
+ svn_boolean_t *conflict_remains,
svn_wc__db_t *db,
const char *local_abspath,
const svn_wc_conflict_version_t *left_version,
@@ -1284,16 +1265,15 @@ apply_single_prop_delete(svn_wc_notify_s
const svn_string_t *old_val,
svn_wc_conflict_resolver_func_t conflict_func,
void *conflict_baton,
- svn_cancel_func_t cancel_func,
- void *cancel_baton,
svn_boolean_t dry_run,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- svn_boolean_t got_conflict = FALSE;
svn_string_t *working_val
= apr_hash_get(working_props, propname, APR_HASH_KEY_STRING);
+ *conflict_remains = FALSE;
+
if (! base_val)
{
/* ### what about working_val? what if we locally-added? */
@@ -1313,23 +1293,16 @@ apply_single_prop_delete(svn_wc_notify_s
apr_hash_set(working_props, propname, APR_HASH_KEY_STRING, NULL);
else
{
- SVN_ERR(maybe_generate_propconflict(&got_conflict, db,
- local_abspath,
+ SVN_ERR(maybe_generate_propconflict(conflict_remains,
+ db, local_abspath,
left_version, right_version,
is_dir,
propname, working_props,
old_val, NULL,
base_val, working_val,
- conflict_func,
conflict_baton,
- cancel_func, cancel_baton,
+ conflict_func,
+ conflict_baton,
dry_run, scratch_pool));
- if (got_conflict)
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to delete property '%s' with value '%s'\n"
- "but it has been modified from '%s' to '%s'."),
- propname, old_val->data,
- base_val->data, working_val->data);
}
}
else
@@ -1339,22 +1312,14 @@ apply_single_prop_delete(svn_wc_notify_s
else
{
- SVN_ERR(maybe_generate_propconflict(&got_conflict, db, local_abspath,
+ SVN_ERR(maybe_generate_propconflict(conflict_remains,
+ db, local_abspath,
left_version, right_version,
is_dir, propname,
working_props, old_val, NULL,
base_val, working_val,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
dry_run, scratch_pool));
- if (got_conflict)
- /* ### wait. what if we had a different property and locally
- ### deleted it? the statement below is gonna blow up. */
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to delete property '%s' with value '%s'\n"
- "but the local value is '%s'."),
- propname, old_val->data, working_val->data);
}
return SVN_NO_ERROR;
@@ -1370,7 +1335,7 @@ apply_single_prop_delete(svn_wc_notify_s
the remainder. */
static svn_error_t *
apply_single_mergeinfo_prop_change(svn_wc_notify_state_t *state,
- svn_string_t **conflict,
+ svn_boolean_t *conflict_remains,
svn_wc__db_t *db,
const char *local_abspath,
const svn_wc_conflict_version_t
*left_version,
@@ -1383,13 +1348,10 @@ apply_single_mergeinfo_prop_change(svn_w
const svn_string_t *new_val,
svn_wc_conflict_resolver_func_t
conflict_func,
void *conflict_baton,
- svn_cancel_func_t cancel_func,
- void *cancel_baton,
svn_boolean_t dry_run,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- svn_boolean_t got_conflict = FALSE;
svn_string_t *working_val
= apr_hash_get(working_props, propname, APR_HASH_KEY_STRING);
@@ -1412,7 +1374,8 @@ apply_single_mergeinfo_prop_change(svn_w
them to base to get the new value. */
SVN_ERR(combine_forked_mergeinfo_props(&new_val, old_val,
working_val,
- new_val,
result_pool));
+ new_val,
+ result_pool));
apr_hash_set(working_props, propname,
APR_HASH_KEY_STRING, new_val);
set_prop_merge_state(state, svn_wc_notify_state_merged);
@@ -1422,20 +1385,14 @@ apply_single_mergeinfo_prop_change(svn_w
else
{
/* There is a base_val but no working_val */
- SVN_ERR(maybe_generate_propconflict(&got_conflict, db, local_abspath,
+ SVN_ERR(maybe_generate_propconflict(conflict_remains,
+ db, local_abspath,
left_version, right_version,
is_dir, propname, working_props,
old_val, new_val,
base_val, working_val,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
dry_run, scratch_pool));
- if (got_conflict)
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to change property '%s' from '%s' to '%s',\n"
- "but it has been locally deleted."),
- propname, old_val->data, new_val->data);
}
}
@@ -1484,7 +1441,7 @@ apply_single_mergeinfo_prop_change(svn_w
apply_single_prop_change(). */
static svn_error_t *
apply_single_generic_prop_change(svn_wc_notify_state_t *state,
- svn_string_t **conflict,
+ svn_boolean_t *conflict_remains,
svn_wc__db_t *db,
const char *local_abspath,
const svn_wc_conflict_version_t *left_version,
@@ -1497,13 +1454,10 @@ apply_single_generic_prop_change(svn_wc_
const svn_string_t *new_val,
svn_wc_conflict_resolver_func_t conflict_func,
void *conflict_baton,
- svn_cancel_func_t cancel_func,
- void *cancel_baton,
svn_boolean_t dry_run,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- svn_boolean_t got_conflict = FALSE;
svn_string_t *working_val
= apr_hash_get(working_props, propname, APR_HASH_KEY_STRING);
@@ -1519,60 +1473,21 @@ apply_single_generic_prop_change(svn_wc_
else
{
/* Merge the change. */
- SVN_ERR(maybe_generate_propconflict(&got_conflict, db, local_abspath,
+ SVN_ERR(maybe_generate_propconflict(conflict_remains,
+ db, local_abspath,
left_version, right_version,
is_dir, propname, working_props,
old_val, new_val,
base_val, working_val,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
dry_run, scratch_pool));
- if (got_conflict)
- {
- /* Describe the conflict, referring to base_val as well as
- working_val for the user's convenience. */
- if (working_val && base_val
- && svn_string_compare(working_val, base_val))
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to change property '%s' from '%s' to '%s',\n"
- "but property already exists with value '%s'."),
- propname, old_val->data, new_val->data, working_val->data);
- else if (working_val && base_val)
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to change property '%s' from '%s' to '%s',\n"
- "but the property has been locally changed from '%s' to "
- "'%s'."),
- propname, old_val->data, new_val->data,
- base_val->data, working_val->data);
- else if (working_val)
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to change property '%s' from '%s' to '%s',\n"
- "but property has been locally added with value "
- "'%s'."),
- propname, old_val->data, new_val->data, working_val->data);
- else if (base_val)
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to change property '%s' from '%s' to '%s',\n"
- "but it has been locally deleted."),
- propname, old_val->data, new_val->data);
- else
- *conflict = svn_string_createf
- (result_pool,
- _("Trying to change property '%s' from '%s' to '%s',\n"
- "but the property does not exist."),
- propname, old_val->data, new_val->data);
- }
}
return SVN_NO_ERROR;
}
/* Change the property with name PROPNAME in the set of WORKING_PROPS
- * on PATH, setting *STATE or *CONFLICT according to the merge outcome.
+ * on PATH, setting *STATE or *CONFLICT_REMAINS according to the merge outcome.
*
* *STATE is an input and output parameter, its value is to be
* set using set_prop_merge_state(). (May be null.).
@@ -1590,7 +1505,7 @@ apply_single_generic_prop_change(svn_wc_
*/
static svn_error_t *
apply_single_prop_change(svn_wc_notify_state_t *state,
- svn_string_t **conflict,
+ svn_boolean_t *conflict_remains,
svn_wc__db_t *db,
const char *local_abspath,
const svn_wc_conflict_version_t *left_version,
@@ -1603,12 +1518,12 @@ apply_single_prop_change(svn_wc_notify_s
const svn_string_t *new_val,
svn_wc_conflict_resolver_func_t conflict_func,
void *conflict_baton,
- svn_cancel_func_t cancel_func,
- void *cancel_baton,
svn_boolean_t dry_run,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
+ *conflict_remains = FALSE;
+
/* Note: The purpose is to apply the change (old_val -> new_val) onto
(working_val). There is no need for base_val to be involved in the
process except as a bit of context to help the user understand and
@@ -1620,32 +1535,32 @@ apply_single_prop_change(svn_wc_notify_s
{
/* We know how to merge any mergeinfo property change. */
- SVN_ERR(apply_single_mergeinfo_prop_change(state, conflict, db,
- local_abspath,
+ SVN_ERR(apply_single_mergeinfo_prop_change(state, conflict_remains,
+ db, local_abspath,
left_version, right_version,
is_dir,
working_props,
propname, base_val, old_val,
new_val,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
- dry_run, result_pool,
scratch_pool));
+ dry_run,
+ result_pool, scratch_pool));
}
else
{
/* The standard method: perform a simple update automatically, but
pass any other kind of merge to maybe_generate_propconflict(). */
- SVN_ERR(apply_single_generic_prop_change(state, conflict, db,
- local_abspath,
+ SVN_ERR(apply_single_generic_prop_change(state, conflict_remains,
+ db, local_abspath,
left_version, right_version,
is_dir,
working_props,
propname, base_val, old_val,
new_val,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
- dry_run, result_pool,
scratch_pool));
+ dry_run,
+ result_pool, scratch_pool));
}
return SVN_NO_ERROR;
@@ -1712,13 +1627,17 @@ svn_wc__merge_props(svn_wc_notify_state_
for (i = 0; i < propchanges->nelts; i++)
{
const char *propname;
- svn_string_t *conflict = NULL;
+ svn_boolean_t conflict_remains;
const svn_prop_t *incoming_change;
const svn_string_t *from_val, *to_val, *base_val;
const svn_string_t *mine_val;
svn_pool_clear(iterpool);
+ /* Should we stop the prop merging process? */
+ if (cancel_func)
+ SVN_ERR(cancel_func(cancel_baton));
+
/* For the incoming propchange, figure out the TO and FROM values. */
incoming_change = &APR_ARRAY_IDX(propchanges, i, svn_prop_t);
propname = incoming_change->name;
@@ -1740,56 +1659,48 @@ svn_wc__merge_props(svn_wc_notify_state_
set_prop_merge_state(state, svn_wc_notify_state_changed);
if (! from_val) /* adding a new property */
- SVN_ERR(apply_single_prop_add(state, &conflict,
+ SVN_ERR(apply_single_prop_add(state, &conflict_remains,
db, local_abspath,
left_version, right_version,
is_dir, working_props,
propname, base_val, to_val,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
dry_run, result_pool, iterpool));
else if (! to_val) /* delete an existing property */
- SVN_ERR(apply_single_prop_delete(state, &conflict,
+ SVN_ERR(apply_single_prop_delete(state, &conflict_remains,
db, local_abspath,
left_version, right_version,
is_dir,
working_props,
propname, base_val, from_val,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
dry_run, result_pool, iterpool));
else /* changing an existing property */
- SVN_ERR(apply_single_prop_change(state, &conflict,
+ SVN_ERR(apply_single_prop_change(state, &conflict_remains,
db, local_abspath,
left_version, right_version,
is_dir,
working_props,
propname, base_val, from_val, to_val,
conflict_func, conflict_baton,
- cancel_func, cancel_baton,
dry_run, result_pool, iterpool));
/* merging logic complete, now we need to possibly log conflict
data to tmpfiles. */
- if (conflict)
+ if (conflict_remains)
{
- /* ### for now, just demonstrate we produce the correct
- ### messages. we'll be doing more interesting stuff later. */
- {
- const svn_string_t *message;
-
- message = generate_conflict_message(propname,
- base_val,
- mine_val,
- to_val,
- from_val,
- iterpool);
- SVN_ERR_ASSERT(svn_string_compare(conflict, message));
- }
+ const svn_string_t *message;
+
+ message = generate_conflict_message(propname,
+ base_val,
+ mine_val,
+ to_val,
+ from_val,
+ iterpool);
set_prop_merge_state(state, svn_wc_notify_state_conflicted);
@@ -1804,7 +1715,7 @@ svn_wc__merge_props(svn_wc_notify_state_
scratch_pool, iterpool));
/* Append the conflict to the open tmp/PROPS/---.prej file */
- SVN_ERR(append_prop_conflict(reject_tmp_stream, conflict,
+ SVN_ERR(append_prop_conflict(reject_tmp_stream, message,
iterpool));
}