Author: rhuijben
Date: Mon Feb 16 15:30:19 2015
New Revision: 1660140
URL: http://svn.apache.org/r1660140
Log:
Allow resolving property conflicts by just passing the new value, instead
of always requiring a tempfile operation.
* subversion/include/svn_wc.h
(svn_wc_conflict_result_t): Add merged_value member.
(svn_wc_create_conflict_result): Make it more explicit that
argument may be null.
* subversion/libsvn_wc/conflicts.c
(generate_propconflict): Handle merged_value.
(resolve_prop_conflict_on_node): Add argument. Handle merged value.
(svn_wc__mark_resolved_prop_conflicts): Update caller.
(conflict_status_walker): Update caller.
(svn_wc_create_conflict_result): Really document the merged_file
(as documented since 1.5)
Modified:
subversion/trunk/subversion/include/svn_wc.h
subversion/trunk/subversion/libsvn_wc/conflicts.c
Modified: subversion/trunk/subversion/include/svn_wc.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1660140&r1=1660139&r2=1660140&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Mon Feb 16 15:30:19 2015
@@ -2185,6 +2185,14 @@ typedef struct svn_wc_conflict_result_t
NULL) in the user's working copy. */
svn_boolean_t save_merged;
+ /** If not NULL, this is the new merged property, used when choosing
+ * #svn_wc_conflict_choose_merged. This value is prefered over using
+ * merged_file.
+ *
+ * @since New in 1.9.
+ */
+ const svn_string_t *merged_value;
+
} svn_wc_conflict_result_t;
@@ -2194,7 +2202,8 @@ typedef struct svn_wc_conflict_result_t
*
* Set the @c choice field of the structure to @a choice, @c merged_file
* to @a merged_file, and @c save_merged to false. Make only a shallow
- * copy of the pointer argument @a merged_file.
+ * copy of the pointer argument @a merged_file. @a merged_file may be
+ * NULL if setting merged_file is not needed.
*
* @since New in 1.5.
*/
Modified: subversion/trunk/subversion/libsvn_wc/conflicts.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/conflicts.c?rev=1660140&r1=1660139&r2=1660140&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_wc/conflicts.c Mon Feb 16 15:30:19 2015
@@ -1365,18 +1365,24 @@ generate_propconflict(svn_boolean_t *con
{
svn_stringbuf_t *merged_stringbuf;
- if (!cdesc->merged_file && !result->merged_file)
+ if (!cdesc->merged_file
+ && (!result->merged_file && !result->merged_value))
return svn_error_create
(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE,
NULL, _("Conflict callback violated API:"
" returned no merged file"));
- SVN_ERR(svn_stringbuf_from_file2(&merged_stringbuf,
- result->merged_file ?
- result->merged_file :
- cdesc->merged_file,
- scratch_pool));
- new_value = svn_stringbuf__morph_into_string(merged_stringbuf);
+ if (result->merged_value)
+ new_value = result->merged_value;
+ else
+ {
+ SVN_ERR(svn_stringbuf_from_file2(&merged_stringbuf,
+ result->merged_file ?
+ result->merged_file :
+ cdesc->merged_file,
+ scratch_pool));
+ new_value = svn_stringbuf__morph_into_string(merged_stringbuf);
+ }
*conflict_remains = FALSE;
break;
}
@@ -2336,6 +2342,7 @@ resolve_prop_conflict_on_node(svn_boolea
const char *conflicted_propname,
svn_wc_conflict_choice_t conflict_choice,
const char *merged_file,
+ const svn_string_t *merged_value,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *scratch_pool)
@@ -2396,21 +2403,27 @@ resolve_prop_conflict_on_node(svn_boolea
resolve_from = their_props;
break;
case svn_wc_conflict_choose_merged:
- if (merged_file && conflicted_propname[0] != '\0')
+ if ((merged_file || merged_value) && conflicted_propname[0] != '\0')
{
apr_hash_t *actual_props;
- svn_stream_t *stream;
- svn_string_t *merged_propval;
SVN_ERR(svn_wc__db_read_props(&actual_props, db, local_abspath,
scratch_pool, scratch_pool));
resolve_from = actual_props;
- SVN_ERR(svn_stream_open_readonly(&stream, merged_file,
- scratch_pool, scratch_pool));
- SVN_ERR(svn_string_from_stream(&merged_propval, stream,
- scratch_pool, scratch_pool));
- svn_hash_sets(resolve_from, conflicted_propname, merged_propval);
+ if (!merged_value)
+ {
+ svn_stream_t *stream;
+ svn_string_t *merged_propval;
+
+ SVN_ERR(svn_stream_open_readonly(&stream, merged_file,
+ scratch_pool, scratch_pool));
+ SVN_ERR(svn_string_from_stream(&merged_propval, stream,
+ scratch_pool, scratch_pool));
+
+ merged_value = merged_propval;
+ }
+ svn_hash_sets(resolve_from, conflicted_propname, merged_value);
}
else
resolve_from = NULL;
@@ -2734,7 +2747,8 @@ svn_wc__mark_resolved_prop_conflicts(svn
return svn_error_trace(resolve_prop_conflict_on_node(
&ignored_result,
db, local_abspath, conflicts, "",
- svn_wc_conflict_choose_merged, NULL,
+ svn_wc_conflict_choose_merged,
+ NULL, NULL,
NULL, NULL,
scratch_pool));
}
@@ -2904,6 +2918,9 @@ conflict_status_walker(void *baton,
result
? result->merged_file
: NULL,
+ result
+ ? result->merged_value
+ : NULL,
cswb->cancel_func,
cswb->cancel_baton,
iterpool));
@@ -3107,7 +3124,7 @@ svn_wc_create_conflict_result(svn_wc_con
{
svn_wc_conflict_result_t *result = apr_pcalloc(pool, sizeof(*result));
result->choice = choice;
- result->merged_file = merged_file;
+ result->merged_file = apr_pstrdup(pool, merged_file);
result->save_merged = FALSE;
/* If we add more fields to svn_wc_conflict_result_t, add them here. */