You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2010/07/29 21:38:49 UTC
svn commit: r980551 [3/10] - in /subversion/branches/issue-2779-dev: ./
build/generator/ notes/tree-conflicts/
subversion/bindings/javahl/src/org/apache/subversion/javahl/
subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/
subversion...
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_client/patch.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_client/patch.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_client/patch.c Thu Jul 29 19:38:44 2010
@@ -65,6 +65,8 @@ typedef struct hunk_info_t {
int fuzz;
} hunk_info_t;
+/* A struct carrying the information related to the content of a target, be it
+ * a property or the the text of a file. */
typedef struct target_content_info_t {
/* A stream to read lines form the target file. This is NULL in case
* the target file did not exist prior to patch application. */
@@ -110,10 +112,27 @@ typedef struct target_content_info_t {
apr_pool_t *pool;
} target_content_info_t;
-typedef struct patch_target_t {
- /* The patch being applied. */
- const svn_patch_t *patch;
+typedef struct prop_patch_target_t {
+
+ /* The name of the property */
+ const char *name;
+
+ /* All the information that is specific to the content of the property. */
+ target_content_info_t *content_info;
+ /* Path to the temporary file underlying the result stream. */
+ const char *patched_path;
+
+ /* Represents the operation performed on the property. It can be added,
+ * deleted or modified.
+ * ### Should we use flags instead since we're not using all enum values? */
+ svn_diff_operation_kind_t operation;
+
+ /* ### Here we'll add flags telling if the prop was added, deleted,
+ * ### had_rejects, had_local_mods prior to patching and so on. */
+} prop_patch_target_t;
+
+typedef struct patch_target_t {
/* The target path as it appeared in the patch file,
* but in canonicalised form. */
const char *canon_path_from_patchfile;
@@ -157,6 +176,9 @@ typedef struct patch_target_t {
/* True if at least one hunk was rejected. */
svn_boolean_t had_rejects;
+ /* True if atleast one property hunk was rejected. */
+ svn_boolean_t had_prop_rejects;
+
/* True if the target file had local modifications before the
* patch was applied to it. */
svn_boolean_t local_mods;
@@ -175,15 +197,17 @@ typedef struct patch_target_t {
/* True if the target has the executable bit set. */
svn_boolean_t executable;
- /* All the information that is specifict to the content of the target. */
- target_content_info_t *content_info;
+ /* True if the patch changes the text of the target */
+ svn_boolean_t has_text_changes;
- /* A hash table of target_content_info_t keyed property names. */
- apr_hash_t *prop_content_info;
+ /* True if the patch changes any of the properties of the target */
+ svn_boolean_t has_prop_changes;
- /* A hash table of paths to temporary files underlying the result streams
- * for the properties. The property names act as keys. */
- apr_hash_t *prop_patched_paths;
+ /* All the information that is specific to the content of the target. */
+ target_content_info_t *content_info;
+
+ /* A hash table of prop_patch_target_t objects keyed by property names. */
+ apr_hash_t *prop_targets;
/* The pool the target is allocated in. */
apr_pool_t *pool;
@@ -298,8 +322,8 @@ obtain_eol_and_keywords_for_file(apr_has
* Indicate in TARGET->SKIPPED whether the target should be skipped.
* STRIP_COUNT specifies the number of leading path components
* which should be stripped from target paths in the patch.
- * If the path is not skipped also obtain eol-style and keywords
- * information and store this in *TARGET.
+ * PROP_CHANGES_ONLY is used for determining if the target path is allowed
+ * to be a dir.
* Use RESULT_POOL for allocations of fields in TARGET.
* Use SCRATCH_POOL for all other allocations. */
static svn_error_t *
@@ -307,6 +331,7 @@ resolve_target_path(patch_target_t *targ
const char *path_from_patchfile,
const char *local_abspath,
int strip_count,
+ svn_boolean_t prop_changes_only,
svn_wc_context_t *wc_ctx,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
@@ -336,6 +361,8 @@ resolve_target_path(patch_target_t *targ
{
target->local_relpath = svn_dirent_is_child(local_abspath, stripped_path,
result_pool);
+
+ /* ### We need to allow setting props on the wc root dir */
if (! target->local_relpath)
{
/* The target path is either outside of the working copy
@@ -364,7 +391,7 @@ resolve_target_path(patch_target_t *targ
/* Skip things we should not be messing with. */
err = svn_wc_status3(&status, wc_ctx, target->local_abspath,
- result_pool, scratch_pool);
+ result_pool, scratch_pool);
if (err)
{
if (err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
@@ -398,7 +425,11 @@ resolve_target_path(patch_target_t *targ
}
SVN_ERR(svn_wc_read_kind(&target->db_kind, wc_ctx, target->local_abspath,
FALSE, scratch_pool));
- if (target->db_kind == svn_node_dir)
+
+ /* If the target is a version directory not missing from disk,
+ * and there are only property changes in the patch, we accept
+ * a directory target. Else, we skip directories. */
+ if (target->db_kind == svn_node_dir && ! prop_changes_only)
{
/* ### We cannot yet replace a locally deleted dir with a file,
* ### but some day we might want to allow it. */
@@ -416,23 +447,26 @@ resolve_target_path(patch_target_t *targ
return SVN_NO_ERROR;
}
-/* Initialize a PROP_CONTENT_INFO structure for PROP_NAME. Use working copy
+/* Initialize a PROP_TARGET structure for PROP_NAME. Use working copy
* context WC_CTX. Use the REJECT stream that is shared with all content
* info structures.
* REMOVE_TEMPFILES as in svn_client_patch().
*/
static svn_error_t *
-init_prop_content_info(target_content_info_t **prop_content_info,
- const char **patched_path,
- const char *prop_name,
- svn_stream_t *reject,
- svn_boolean_t remove_tempfiles,
- svn_wc_context_t *wc_ctx,
- const char *local_abspath,
- apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+init_prop_target(prop_patch_target_t **prop_target,
+ const char *prop_name,
+ svn_diff_operation_kind_t operation,
+ svn_stream_t *reject,
+ svn_boolean_t remove_tempfiles,
+ svn_wc_context_t *wc_ctx,
+ const char *local_abspath,
+ apr_pool_t *result_pool, apr_pool_t *scratch_pool)
{
+ prop_patch_target_t *new_prop_target;
target_content_info_t *content_info;
const svn_string_t *value;
+ const char *patched_path;
+
content_info = apr_pcalloc(result_pool, sizeof(*content_info));
@@ -440,29 +474,38 @@ init_prop_content_info(target_content_in
content_info->current_line = 1;
content_info->eol_style = svn_subst_eol_style_none;
content_info->lines = apr_array_make(result_pool, 0,
- sizeof(svn_stream_mark_t *));
+ sizeof(svn_stream_mark_t *));
content_info->hunks = apr_array_make(result_pool, 0, sizeof(hunk_info_t *));
content_info->keywords = apr_hash_make(result_pool);
content_info->reject = reject;
content_info->pool = result_pool;
+ new_prop_target = apr_palloc(result_pool, sizeof(*new_prop_target));
+ new_prop_target->name = apr_pstrdup(result_pool, prop_name);
+ new_prop_target->operation = operation;
+ new_prop_target->content_info = content_info;
+
SVN_ERR(svn_wc_prop_get2(&value, wc_ctx, local_abspath, prop_name,
result_pool, scratch_pool));
- /* We assume that a property is small enough to be kept in memory during
- * the patch process. */
- content_info->stream = svn_stream_from_string(value, result_pool);
+ if (value)
+ {
+ /* We assume that a property is small enough to be kept in memory during
+ * the patch process. */
+ content_info->stream = svn_stream_from_string(value, result_pool);
+ }
/* Create a temporary file to write the patched result to. For properties,
* we don't have to worrry about different eol-style. */
SVN_ERR(svn_stream_open_unique(&content_info->patched,
- patched_path, NULL,
+ &patched_path, NULL,
remove_tempfiles ?
svn_io_file_del_on_pool_cleanup :
svn_io_file_del_none,
result_pool, scratch_pool));
- *prop_content_info = content_info;
+ new_prop_target->patched_path = patched_path;
+ *prop_target = new_prop_target;
return SVN_NO_ERROR;
}
@@ -471,8 +514,10 @@ init_prop_content_info(target_content_in
* described by PATCH. Use working copy context WC_CTX.
* STRIP_COUNT specifies the number of leading path components
* which should be stripped from target paths in the patch.
- * Upon success, allocate the patch target structure in RESULT_POOL.
- * Else, set *target to NULL.
+ * The patch target structure is allocated in RESULT_POOL, but if the target
+ * should be skipped, PATCH_TARGET->SKIPPED is set and the target should be
+ * treated as not fully initialized, e.g. the caller should not not do any
+ * further operations on the target if it is marked to be skipped.
* REMOVE_TEMPFILES as in svn_client_patch().
* Use SCRATCH_POOL for all other allocations. */
static svn_error_t *
@@ -485,6 +530,26 @@ init_patch_target(patch_target_t **patch
{
patch_target_t *target;
target_content_info_t *content_info;
+ svn_boolean_t has_prop_changes = FALSE;
+ svn_boolean_t prop_changes_only = FALSE;
+
+ {
+ apr_hash_index_t *hi;
+
+ /* ### Should we use an iterpool here? */
+ for (hi = apr_hash_first(scratch_pool, patch->prop_patches);
+ hi;
+ hi = apr_hash_next(hi))
+ {
+ svn_prop_patch_t *prop_patch = svn__apr_hash_index_val(hi);
+ if (! has_prop_changes)
+ has_prop_changes = prop_patch->hunks->nelts > 0;
+ else
+ break;
+ }
+ }
+
+ prop_changes_only = has_prop_changes && patch->hunks->nelts == 0;
content_info = apr_pcalloc(result_pool, sizeof(*content_info));
@@ -492,7 +557,7 @@ init_patch_target(patch_target_t **patch
content_info->current_line = 1;
content_info->eol_style = svn_subst_eol_style_none;
content_info->lines = apr_array_make(result_pool, 0,
- sizeof(svn_stream_mark_t *));
+ sizeof(svn_stream_mark_t *));
content_info->hunks = apr_array_make(result_pool, 0, sizeof(hunk_info_t *));
content_info->keywords = apr_hash_make(result_pool);
content_info->pool = result_pool;
@@ -500,17 +565,15 @@ init_patch_target(patch_target_t **patch
target = apr_pcalloc(result_pool, sizeof(*target));
/* All other fields in target are FALSE or NULL due to apr_pcalloc(). */
- target->patch = patch;
target->db_kind = svn_node_none;
target->kind_on_disk = svn_node_none;
target->content_info = content_info;
- target->prop_content_info = apr_hash_make(result_pool);
- target->prop_patched_paths = apr_hash_make(result_pool);
+ target->prop_targets = apr_hash_make(result_pool);
target->pool = result_pool;
SVN_ERR(resolve_target_path(target, patch->new_filename,
- base_dir, strip_count, wc_ctx,
- result_pool, scratch_pool));
+ base_dir, strip_count, prop_changes_only,
+ wc_ctx, result_pool, scratch_pool));
if (! target->skipped)
{
const char *diff_header;
@@ -527,7 +590,7 @@ init_patch_target(patch_target_t **patch
/* Create a stream to read from the target. */
content_info->stream = svn_stream_from_aprfile2(target->file,
- FALSE, result_pool);
+ FALSE, result_pool);
/* Also check the file for local mods and the Xbit. */
SVN_ERR(svn_wc_text_modified_p2(&target->local_mods, wc_ctx,
@@ -591,30 +654,21 @@ init_patch_target(patch_target_t **patch
hi = apr_hash_next(hi))
{
const char *prop_name = svn__apr_hash_index_key(hi);
- target_content_info_t *prop_content_info;
- const char *patched_path;
+ svn_prop_patch_t *prop_patch = svn__apr_hash_index_val(hi);
+ prop_patch_target_t *prop_target;
/* Obtain info about this property */
- SVN_ERR(init_prop_content_info(&prop_content_info,
- &patched_path,
- prop_name,
- content_info->reject,
- remove_tempfiles,
- wc_ctx, target->local_abspath,
- result_pool, scratch_pool));
-
- /* Store information about the content of prop_name */
- apr_hash_set(target->prop_content_info, prop_name,
- APR_HASH_KEY_STRING, prop_content_info);
-
- /* Record the path to the temporary file underlying the
- * patched version of prop_name.
- *
- * ### Two hash tables keyed by prop_name? We're doing it this
- * ### way since the path is not part of the content, but it
- * ### would be nice if we could just use one table. */
- apr_hash_set(target->prop_patched_paths, prop_name,
- APR_HASH_KEY_STRING, patched_path);
+ SVN_ERR(init_prop_target(&prop_target,
+ prop_name,
+ prop_patch->operation,
+ content_info->reject,
+ remove_tempfiles,
+ wc_ctx, target->local_abspath,
+ result_pool, scratch_pool));
+
+ /* Store the info */
+ apr_hash_set(target->prop_targets, prop_name,
+ APR_HASH_KEY_STRING, prop_target);
}
}
}
@@ -919,27 +973,22 @@ scan_for_match(svn_linenum_t *matched_li
return SVN_NO_ERROR;
}
-/* Indicate in *MATCH whether the file at TARGET->abspath matches the
- * modified text of HUNK. Use SCRATCH_POOL for temporary allocations. */
+/* Indicate in *MATCH whether the STREAM matches the modified text of HUNK.
+ * Use CONTENT_INFO for retrieving information on eol and keywords that is
+ * needed for the comparison.
+ * Use SCRATCH_POOL for temporary allocations. */
static svn_error_t *
-match_existing_file(svn_boolean_t *match,
- patch_target_t *target,
- const svn_hunk_t *hunk,
- apr_pool_t *scratch_pool)
+match_existing_target(svn_boolean_t *match,
+ target_content_info_t *content_info,
+ const svn_hunk_t *hunk,
+ svn_stream_t *stream,
+ apr_pool_t *scratch_pool)
{
- apr_file_t *file;
- svn_stream_t *stream;
svn_boolean_t lines_matched;
apr_pool_t *iterpool;
svn_boolean_t eof;
svn_boolean_t hunk_eof;
- SVN_ERR(svn_io_file_open(&file, target->local_abspath,
- APR_READ | APR_BINARY, APR_OS_DEFAULT,
- scratch_pool));
- stream = svn_stream_from_aprfile2(file, FALSE, scratch_pool);
-
-
SVN_ERR(svn_diff_hunk_reset_modified_text(hunk));
iterpool = svn_pool_create(scratch_pool);
@@ -960,19 +1009,18 @@ match_existing_file(svn_boolean_t *match
/* Contract keywords. */
SVN_ERR(svn_subst_translate_cstring2(line->data, &line_translated,
NULL, FALSE,
- target->content_info->keywords,
+ content_info->keywords,
FALSE, iterpool));
SVN_ERR(svn_subst_translate_cstring2(hunk_line->data,
&hunk_line_translated,
NULL, FALSE,
- target->content_info->keywords,
+ content_info->keywords,
FALSE, iterpool));
lines_matched = ! strcmp(line_translated, hunk_line_translated);
if (eof != hunk_eof)
{
svn_pool_destroy(iterpool);
*match = FALSE;
- svn_stream_close(stream);
return SVN_NO_ERROR;
}
}
@@ -980,7 +1028,6 @@ match_existing_file(svn_boolean_t *match
svn_pool_destroy(iterpool);
*match = (lines_matched && eof == hunk_eof);
- svn_stream_close(stream);
return SVN_NO_ERROR;
}
@@ -998,6 +1045,7 @@ get_hunk_info(hunk_info_t **hi, patch_ta
target_content_info_t *content_info,
const svn_hunk_t *hunk, int fuzz,
svn_boolean_t ignore_whitespace,
+ svn_boolean_t is_prop_hunk,
svn_cancel_func_t cancel_func, void *cancel_baton,
apr_pool_t *result_pool, apr_pool_t *scratch_pool)
{
@@ -1012,17 +1060,27 @@ get_hunk_info(hunk_info_t **hi, patch_ta
* a new file. Don't bother matching hunks in that case, since
* the hunk applies at line 1. If the file already exists, the hunk
* is rejected, unless the file is versioned and its content matches
- * the file the patch wants to create. */
- if (original_start == 0)
+ * the file the patch wants to create. */
+ if (original_start == 0 && ! is_prop_hunk)
{
if (target->kind_on_disk == svn_node_file)
{
if (target->db_kind == svn_node_file)
{
svn_boolean_t file_matches;
+ apr_file_t *file;
+ svn_stream_t *stream;
+
+ /* ### dannas: Why not use content_info-stream here? */
+ SVN_ERR(svn_io_file_open(&file, target->local_abspath,
+ APR_READ | APR_BINARY, APR_OS_DEFAULT,
+ scratch_pool));
+ stream = svn_stream_from_aprfile2(file, FALSE, scratch_pool);
+
+ SVN_ERR(match_existing_target(&file_matches, content_info, hunk,
+ stream, scratch_pool));
+ svn_stream_close(stream);
- SVN_ERR(match_existing_file(&file_matches, target, hunk,
- scratch_pool));
if (file_matches)
{
matched_line = 1;
@@ -1037,7 +1095,36 @@ get_hunk_info(hunk_info_t **hi, patch_ta
else
matched_line = 1;
}
- else if (original_start > 0 && target->kind_on_disk == svn_node_file)
+ /* Same conditions apply as for the file case above.
+ *
+ * ### Since the hunk says the prop should be added we just assume so for
+ * ### now and don't bother with storing the previous lines and such. When
+ * ### we have the diff operation available we can just check for adds. */
+ else if (original_start == 0 && is_prop_hunk)
+ {
+ if (content_info->stream)
+ {
+ svn_boolean_t prop_matches;
+
+ SVN_ERR(match_existing_target(&prop_matches, content_info, hunk,
+ content_info->stream, scratch_pool));
+
+ if (prop_matches)
+ {
+ matched_line = 1;
+ already_applied = TRUE;
+ }
+ else
+ matched_line = 0; /* reject */
+ }
+ else
+ matched_line = 1;
+ }
+ /* ### We previously checked for target->kind_on_disk == svn_node_file
+ * ### here. But that wasn't generic enough to cope with properties. How
+ * ### better describe that content_info->stream is only set if we have an
+ * ### existing target? */
+ else if (original_start > 0 && content_info->stream)
{
svn_linenum_t saved_line = content_info->current_line;
svn_linenum_t modified_start;
@@ -1187,19 +1274,38 @@ copy_lines_to_target(target_content_info
* Do temporary allocations in POOL. */
static svn_error_t *
reject_hunk(patch_target_t *target, target_content_info_t *content_info,
- hunk_info_t *hi, apr_pool_t *pool)
+ hunk_info_t *hi, const char *prop_name, apr_pool_t *pool)
{
const char *hunk_header;
apr_size_t len;
svn_boolean_t eof;
apr_pool_t *iterpool;
- hunk_header = apr_psprintf(pool, "@@ -%lu,%lu +%lu,%lu @@%s",
- svn_diff_hunk_get_original_start(hi->hunk),
- svn_diff_hunk_get_original_length(hi->hunk),
- svn_diff_hunk_get_modified_start(hi->hunk),
- svn_diff_hunk_get_modified_length(hi->hunk),
- APR_EOL_STR);
+ if (prop_name)
+ {
+ const char *prop_header;
+
+ /* ### Print 'Added', 'Deleted' or 'Modified' instead of 'Propperty'.
+ */
+ prop_header = apr_psprintf(pool, "Property: %s\n", prop_name);
+ len = strlen(prop_header);
+
+ SVN_ERR(svn_stream_write(content_info->reject, prop_header, &len));
+
+ hunk_header = apr_psprintf(pool, "## -%lu,%lu +%lu,%lu ##%s",
+ svn_diff_hunk_get_original_start(hi->hunk),
+ svn_diff_hunk_get_original_length(hi->hunk),
+ svn_diff_hunk_get_modified_start(hi->hunk),
+ svn_diff_hunk_get_modified_length(hi->hunk),
+ APR_EOL_STR);
+ }
+ else
+ hunk_header = apr_psprintf(pool, "@@ -%lu,%lu +%lu,%lu @@%s",
+ svn_diff_hunk_get_original_start(hi->hunk),
+ svn_diff_hunk_get_original_length(hi->hunk),
+ svn_diff_hunk_get_modified_start(hi->hunk),
+ svn_diff_hunk_get_modified_length(hi->hunk),
+ APR_EOL_STR);
len = strlen(hunk_header);
SVN_ERR(svn_stream_write(content_info->reject, hunk_header, &len));
@@ -1227,7 +1333,10 @@ reject_hunk(patch_target_t *target, targ
while (! eof);
svn_pool_destroy(iterpool);
- target->had_rejects = TRUE;
+ if (prop_name)
+ target->had_prop_rejects = TRUE;
+ else
+ target->had_rejects = TRUE;
return SVN_NO_ERROR;
}
@@ -1236,13 +1345,15 @@ reject_hunk(patch_target_t *target, targ
* stream of CONTENT_INFO. Do temporary allocations in POOL. */
static svn_error_t *
apply_hunk(patch_target_t *target, target_content_info_t *content_info,
- hunk_info_t *hi, apr_pool_t *pool)
+ hunk_info_t *hi, const char *prop_name, apr_pool_t *pool)
{
svn_linenum_t lines_read;
svn_boolean_t eof;
apr_pool_t *iterpool;
- if (target->kind_on_disk == svn_node_file)
+ /* ### Is there a cleaner way to describe if we have an existing target?
+ */
+ if (target->kind_on_disk == svn_node_file || prop_name)
{
svn_linenum_t line;
@@ -1262,7 +1373,7 @@ apply_hunk(patch_target_t *target, targe
{
/* Seek failed, reject this hunk. */
hi->rejected = TRUE;
- SVN_ERR(reject_hunk(target, content_info, hi, pool));
+ SVN_ERR(reject_hunk(target, content_info, hi, prop_name, pool));
return SVN_NO_ERROR;
}
}
@@ -1307,6 +1418,11 @@ apply_hunk(patch_target_t *target, targe
while (! eof);
svn_pool_destroy(iterpool);
+ if (prop_name)
+ target->has_prop_changes = TRUE;
+ else
+ target->has_text_changes = TRUE;
+
return SVN_NO_ERROR;
}
@@ -1353,8 +1469,16 @@ send_patch_notification(const patch_targ
notify->content_state = svn_wc_notify_state_conflicted;
else if (target->local_mods)
notify->content_state = svn_wc_notify_state_merged;
- else
+ else if (target->has_text_changes)
notify->content_state = svn_wc_notify_state_changed;
+
+ /* ### We need to decide on how we want prop notifications to work.
+ * ### At the moment we're not reporting property hunks and what about
+ * ### added paths with props and paths scheduled for deletion? */
+ if (target->had_prop_rejects)
+ notify->prop_state = svn_wc_notify_state_conflicted;
+ else if (target->has_prop_changes)
+ notify->prop_state = svn_wc_notify_state_changed;
}
(*ctx->notify_func2)(ctx->notify_baton2, notify, pool);
@@ -1363,6 +1487,7 @@ send_patch_notification(const patch_targ
{
int i;
apr_pool_t *iterpool;
+ apr_hash_index_t *hash_index;
iterpool = svn_pool_create(pool);
for (i = 0; i < target->content_info->hunks->nelts; i++)
@@ -1394,9 +1519,56 @@ send_patch_notification(const patch_targ
svn_diff_hunk_get_modified_length(hi->hunk);
notify->hunk_matched_line = hi->matched_line;
notify->hunk_fuzz = hi->fuzz;
+ /* ### Should is_prop_hunk be a field in hunk_info_t? */
+ notify->is_prop_hunk = FALSE;
(*ctx->notify_func2)(ctx->notify_baton2, notify, pool);
}
+
+ for (hash_index = apr_hash_first(pool, target->prop_targets);
+ hash_index;
+ hash_index = apr_hash_next(hash_index))
+ {
+ prop_patch_target_t *prop_target;
+
+ prop_target = svn__apr_hash_index_val(hash_index);
+
+ for (i = 0; i < prop_target->content_info->hunks->nelts; i++)
+ {
+ hunk_info_t *hi;
+
+ svn_pool_clear(iterpool);
+
+ hi = APR_ARRAY_IDX(prop_target->content_info->hunks, i,
+ hunk_info_t *);
+
+ if (hi->already_applied)
+ action = svn_wc_notify_patch_hunk_already_applied;
+ else if (hi->rejected)
+ action = svn_wc_notify_patch_rejected_hunk;
+ else
+ action = svn_wc_notify_patch_applied_hunk;
+
+ notify = svn_wc_create_notify(target->local_abspath
+ ? target->local_abspath
+ : target->local_relpath,
+ action, pool);
+ notify->hunk_original_start =
+ svn_diff_hunk_get_original_start(hi->hunk);
+ notify->hunk_original_length =
+ svn_diff_hunk_get_original_length(hi->hunk);
+ notify->hunk_modified_start =
+ svn_diff_hunk_get_modified_start(hi->hunk);
+ notify->hunk_modified_length =
+ svn_diff_hunk_get_modified_length(hi->hunk);
+ notify->hunk_matched_line = hi->matched_line;
+ notify->hunk_fuzz = hi->fuzz;
+ /* ### Should is_prop_hunk be a field in hunk_info_t? */
+ notify->is_prop_hunk = TRUE;
+
+ (*ctx->notify_func2)(ctx->notify_baton2, notify, pool);
+ }
+ }
svn_pool_destroy(iterpool);
}
@@ -1430,6 +1602,7 @@ apply_one_patch(patch_target_t **patch_t
apr_pool_t *iterpool;
int i;
static const int MAX_FUZZ = 2;
+ apr_hash_index_t *hash_index;
SVN_ERR(init_patch_target(&target, patch, abs_wc_path, wc_ctx, strip_count,
remove_tempfiles, result_pool, scratch_pool));
@@ -1473,6 +1646,7 @@ apply_one_patch(patch_target_t **patch_t
{
SVN_ERR(get_hunk_info(&hi, target, target->content_info, hunk, fuzz,
ignore_whitespace,
+ FALSE /* is_prop_hunk */,
cancel_func, cancel_baton,
result_pool, iterpool));
fuzz++;
@@ -1493,11 +1667,13 @@ apply_one_patch(patch_target_t **patch_t
if (hi->already_applied)
continue;
else if (hi->rejected)
- SVN_ERR(reject_hunk(target, target->content_info, hi, iterpool));
+ SVN_ERR(reject_hunk(target, target->content_info, hi,
+ NULL /* prop_name */,
+ iterpool));
else
- SVN_ERR(apply_hunk(target, target->content_info, hi, iterpool));
+ SVN_ERR(apply_hunk(target, target->content_info, hi,
+ NULL /* prop_name */, iterpool));
}
- svn_pool_destroy(iterpool);
if (target->kind_on_disk == svn_node_file)
{
@@ -1513,6 +1689,110 @@ apply_one_patch(patch_target_t **patch_t
}
}
+ /* Match property hunks. */
+ for (hash_index = apr_hash_first(result_pool, patch->prop_patches);
+ hash_index;
+ hash_index = apr_hash_next(hash_index))
+ {
+ svn_prop_patch_t *prop_patch;
+ const char *prop_name;
+ prop_patch_target_t *prop_target;
+ target_content_info_t *prop_content_info;
+
+ /* Fetching the parsed info for one property */
+ prop_name = svn__apr_hash_index_key(hash_index);
+ prop_patch = svn__apr_hash_index_val(hash_index);
+
+ /* Fetch the prop_content_info we'll use to store the matched hunks
+ * in. */
+ prop_target = apr_hash_get(target->prop_targets, prop_name,
+ APR_HASH_KEY_STRING);
+ prop_content_info = prop_target->content_info;
+
+ for (i = 0; i < prop_patch->hunks->nelts; i++)
+ {
+ svn_hunk_t *hunk;
+ hunk_info_t *hi;
+ int fuzz = 0;
+
+ svn_pool_clear(iterpool);
+
+ if (cancel_func)
+ SVN_ERR((cancel_func)(cancel_baton));
+
+ hunk = APR_ARRAY_IDX(prop_patch->hunks, i, svn_hunk_t *);
+
+ /* Determine the line the hunk should be applied at.
+ * If no match is found initially, try with fuzz. */
+ do
+ {
+ SVN_ERR(get_hunk_info(&hi, target, prop_content_info, hunk, fuzz,
+ ignore_whitespace,
+ TRUE /* is_prop_hunk */,
+ cancel_func, cancel_baton,
+ result_pool, iterpool));
+ fuzz++;
+ }
+ while (hi->rejected && fuzz <= MAX_FUZZ && ! hi->already_applied);
+
+ APR_ARRAY_PUSH(prop_content_info->hunks, hunk_info_t *) = hi;
+ }
+ }
+
+ /* Apply or reject property hunks. */
+ for (hash_index = apr_hash_first(result_pool, target->prop_targets);
+ hash_index;
+ hash_index = apr_hash_next(hash_index))
+ {
+ prop_patch_target_t *prop_target;
+ target_content_info_t *prop_content_info;
+ const char *prop_patched_path;
+
+ prop_target = svn__apr_hash_index_val(hash_index);
+ prop_content_info = prop_target->content_info;
+ prop_patched_path = prop_target->patched_path;
+
+ for (i = 0; i < prop_content_info->hunks->nelts; i++)
+ {
+ hunk_info_t *hi;
+
+ svn_pool_clear(iterpool);
+
+ hi = APR_ARRAY_IDX(prop_content_info->hunks, i, hunk_info_t *);
+ if (hi->already_applied)
+ continue;
+ else if (hi->rejected)
+ SVN_ERR(reject_hunk(target, prop_content_info, hi,
+ prop_target->name,
+ iterpool));
+ else
+ SVN_ERR(apply_hunk(target, prop_content_info, hi,
+ prop_target->name,
+ iterpool));
+ }
+
+ if (prop_content_info->stream)
+ {
+ /* Copy any remaining lines to target. */
+ SVN_ERR(copy_lines_to_target(prop_content_info, 0,
+ prop_patched_path, scratch_pool));
+ if (! prop_content_info->eof)
+ {
+ /* We could not copy the entire target property to the
+ * temporary file, and would truncate the target if we
+ * copied the temporary file on top of it. Skip this target.
+ *
+ * ### dannas: Do we really want to skip an entire target
+ * ### if one of the properties does not apply cleanly,
+ * ### e.g. both text changes and all prop changes will not be
+ * ### installed. */
+ target->skipped = TRUE;
+ }
+ }
+ }
+
+ svn_pool_destroy(iterpool);
+
{
apr_hash_index_t *hi;
target_content_info_t *prop_content_info;
@@ -1520,12 +1800,20 @@ apply_one_patch(patch_target_t **patch_t
/* Close the streams of the target so that their content is flushed
* to disk. This will also close underlying streams and files.
* First the streams belonging to properties .. */
- for (hi = apr_hash_first(result_pool, target->prop_content_info);
+ for (hi = apr_hash_first(result_pool, target->prop_targets);
hi;
hi = apr_hash_next(hi))
{
- prop_content_info = svn__apr_hash_index_val(hi);
- svn_stream_close(prop_content_info->stream);
+ prop_patch_target_t *prop_target;
+ prop_target = svn__apr_hash_index_val(hi);
+ prop_content_info = prop_target->content_info;
+
+ /* ### If the prop did not exist pre-patching we'll not have a
+ * ### stream to read from. Find a better way to store info on
+ * ### the existence of the target prop. */
+ if (prop_content_info->stream)
+ svn_stream_close(prop_content_info->stream);
+
svn_stream_close(prop_content_info->patched);
}
@@ -1607,14 +1895,15 @@ create_missing_parents(patch_target_t *t
apr_pool_t *iterpool;
/* Check if we can safely create the target's parent. */
- local_abspath = apr_pstrdup(scratch_pool, abs_wc_path);
+ local_abspath = abs_wc_path;
components = svn_path_decompose(target->local_relpath, scratch_pool);
present_components = 0;
iterpool = svn_pool_create(scratch_pool);
for (i = 0; i < components->nelts - 1; i++)
{
const char *component;
- svn_node_kind_t kind;
+ svn_node_kind_t wc_kind, disk_kind;
+ svn_boolean_t is_deleted;
svn_pool_clear(iterpool);
@@ -1622,49 +1911,45 @@ create_missing_parents(patch_target_t *t
const char *);
local_abspath = svn_dirent_join(local_abspath, component, scratch_pool);
- SVN_ERR(svn_wc_read_kind(&kind, ctx->wc_ctx, local_abspath, TRUE,
+ SVN_ERR(svn_wc_read_kind(&wc_kind, ctx->wc_ctx, local_abspath, TRUE,
iterpool));
- if (kind == svn_node_file)
+
+ SVN_ERR(svn_io_check_path(local_abspath, &disk_kind, iterpool));
+
+ if (wc_kind != svn_node_none)
+ SVN_ERR(svn_wc__node_is_status_deleted(&is_deleted,
+ ctx->wc_ctx,
+ local_abspath,
+ iterpool));
+ else
+ is_deleted = FALSE;
+
+ if (disk_kind == svn_node_file
+ || (wc_kind == svn_node_file && !is_deleted))
{
- /* Obstructed. */
+ /* on-disk files and missing files are obstructions */
target->skipped = TRUE;
break;
}
- else if (kind == svn_node_dir)
+ else if (wc_kind == svn_node_dir)
{
- /* ### wc-ng should eventually be able to replace
- * directories in-place, so this schedule conflict
- * check will go away. We could then also make the
- * svn_wc_read_kind() call above ignore hidden
- * nodes.*/
- svn_boolean_t is_deleted;
-
- SVN_ERR(svn_wc__node_is_status_deleted(&is_deleted,
- ctx->wc_ctx,
- local_abspath,
- iterpool));
if (is_deleted)
- {
- target->skipped = TRUE;
- break;
- }
+ break;
+ /* continue one level deeper */
present_components++;
}
+ else if (disk_kind == svn_node_dir)
+ {
+ /* Obstructed. ### BH: why? We can just add a directory */
+ target->skipped = TRUE;
+ break;
+ }
else
{
- /* The WC_DB doesn't know much about this node.
- * Check what's on disk. */
- svn_node_kind_t disk_kind;
-
- SVN_ERR(svn_io_check_path(local_abspath, &disk_kind,
- iterpool));
- if (disk_kind != svn_node_none)
- {
- /* An unversioned item is in the way. */
- target->skipped = TRUE;
- break;
- }
+ /* It's not a file, it's not a dir..
+ Let's add a dir */
+ break;
}
}
@@ -1680,6 +1965,15 @@ create_missing_parents(patch_target_t *t
component, scratch_pool);
}
+ if (!dry_run && present_components < components->nelts - 1)
+ SVN_ERR(svn_io_make_dir_recursively(
+ svn_dirent_join(
+ abs_wc_path,
+ svn_relpath_dirname(target->local_relpath,
+ scratch_pool),
+ scratch_pool),
+ scratch_pool));
+
for (i = present_components; i < components->nelts - 1; i++)
{
const char *component;
@@ -1710,8 +2004,6 @@ create_missing_parents(patch_target_t *t
* to version control. Allow cancellation since we
* have not modified the working copy yet for this
* target. */
- SVN_ERR(svn_io_dir_make(local_abspath, APR_OS_DEFAULT,
- iterpool));
SVN_ERR(svn_wc_add4(ctx->wc_ctx, local_abspath,
svn_depth_infinity,
NULL, SVN_INVALID_REVNUM,
@@ -1794,15 +2086,111 @@ install_patched_target(patch_target_t *t
}
}
- /* Write out rejected hunks, if any. */
- if (! dry_run && ! target->skipped && target->had_rejects)
+ return SVN_NO_ERROR;
+}
+
+/* Write out rejected hunks, if any, to TARGET->REJECT_PATH. If DRY_RUN is
+ * TRUE, don't modify the working copy.
+ * Do temporary allocations in POOL.
+ */
+static svn_error_t *
+write_out_rejected_hunks(patch_target_t *target,
+ svn_boolean_t dry_run,
+ apr_pool_t *pool)
+{
+ if (! dry_run && (target->had_rejects || target->had_prop_rejects))
{
+ /* Write out rejected hunks, if any. */
SVN_ERR(svn_io_copy_file(target->reject_path,
apr_psprintf(pool, "%s.svnpatch.rej",
- target->local_abspath),
+ target->local_abspath),
FALSE, pool));
/* ### TODO mark file as conflicted. */
}
+ return SVN_NO_ERROR;
+}
+
+/* Install the patched properties for TARGET. Use client context CTX to
+ * retrieve WC_CTX. If DRY_RUN is TRUE, don't modify the working copy.
+ * Do tempoary allocations in SCRATCH_POOL. */
+static svn_error_t *
+install_patched_prop_targets(patch_target_t *target,
+ svn_client_ctx_t *ctx, svn_boolean_t dry_run,
+ apr_pool_t *scratch_pool)
+{
+ apr_hash_index_t *hi;
+ apr_pool_t *iterpool;
+
+ if (dry_run)
+ return SVN_NO_ERROR;
+
+ iterpool = svn_pool_create(scratch_pool);
+
+ for (hi = apr_hash_first(scratch_pool, target->prop_targets);
+ hi;
+ hi = apr_hash_next(hi))
+ {
+ prop_patch_target_t *prop_target = svn__apr_hash_index_val(hi);
+ apr_file_t *file;
+ svn_stream_t *patched_stream;
+ svn_stringbuf_t *line;
+ svn_stringbuf_t *prop_content;
+ const char *eol_str;
+ svn_boolean_t eof;
+
+ svn_pool_clear(iterpool);
+
+ /* For a deleted prop we only set the value to NULL. */
+ if (prop_target->operation == svn_diff_op_deleted)
+ {
+ SVN_ERR(svn_wc_prop_set4(ctx->wc_ctx, target->local_abspath,
+ prop_target->name, NULL,
+ TRUE /* skip_checks */,
+ NULL, NULL,
+ iterpool));
+ continue;
+ }
+
+ /* A property is usually one line long.
+ * ### Is this the optimal size to allocate? */
+ prop_content = svn_stringbuf_create_ensure(80, scratch_pool);
+
+ /* svn_wc_prop_set4() wants a svn_string_t for input so we need to
+ * open the tmp file for reading again. */
+ SVN_ERR(svn_io_file_open(&file, prop_target->patched_path,
+ APR_READ | APR_BINARY, APR_OS_DEFAULT,
+ scratch_pool));
+
+ patched_stream = svn_stream_from_aprfile2(file, FALSE /* disown */,
+ iterpool);
+ do
+ {
+ SVN_ERR(svn_stream_readline_detect_eol(patched_stream,
+ &line, &eol_str,
+ &eof,
+ iterpool));
+
+ svn_stringbuf_appendstr(prop_content, line);
+
+ if (eol_str)
+ svn_stringbuf_appendcstr(prop_content, eol_str);
+ }
+ while (! eof);
+
+ svn_stream_close(patched_stream);
+
+ /* ### How should we handle SVN_ERR_ILLEGAL_TARGET and
+ * ### SVN_ERR_BAD_MIME_TYPE? */
+ SVN_ERR(svn_wc_prop_set4(ctx->wc_ctx, target->local_abspath,
+ prop_target->name,
+ svn_string_create_from_buf(prop_content,
+ iterpool),
+ TRUE /* skip_checks */,
+ NULL, NULL,
+ iterpool));
+ }
+
+ svn_pool_destroy(iterpool);
return SVN_NO_ERROR;
}
@@ -2169,9 +2557,20 @@ apply_patches(void *baton,
patch_target_info_t *) = target_info;
if (! target->skipped)
- SVN_ERR(install_patched_target(target, btn->abs_wc_path,
- btn->ctx, btn->dry_run,
- iterpool));
+ {
+ if (target->has_text_changes)
+ SVN_ERR(install_patched_target(target, btn->abs_wc_path,
+ btn->ctx, btn->dry_run,
+ iterpool));
+
+ if (target->has_prop_changes)
+ SVN_ERR(install_patched_prop_targets(target, btn->ctx,
+ btn->dry_run,
+ iterpool));
+
+ SVN_ERR(write_out_rejected_hunks(target, btn->dry_run,
+ iterpool));
+ }
SVN_ERR(send_patch_notification(target, btn->ctx, iterpool));
}
@@ -2221,7 +2620,8 @@ svn_client_patch(const char *patch_abspa
baton.patch_func = patch_func;
baton.patch_baton = patch_baton;
- return svn_error_return(svn_wc__call_with_write_lock(apply_patches, &baton,
- ctx->wc_ctx, local_abspath,
- result_pool, scratch_pool));
+ return svn_error_return(
+ svn_wc__call_with_write_lock(apply_patches, &baton,
+ ctx->wc_ctx, local_abspath, FALSE,
+ result_pool, scratch_pool));
}
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_client/prop_commands.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_client/prop_commands.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_client/prop_commands.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_client/prop_commands.c Thu Jul 29 19:38:44 2010
@@ -97,7 +97,7 @@ struct propset_walk_baton
void *notify_baton;
};
-/* An node-walk callback for svn_client_propset3.
+/* An node-walk callback for svn_client_propset4.
*
* For LOCAL_ABSPATH, set the property named wb->PROPNAME to the value
* wb->PROPVAL, where "wb" is the WALK_BATON of type "struct
@@ -189,8 +189,7 @@ do_url_propset(const char *propname,
}
static svn_error_t *
-propset_on_url(svn_commit_info_t **commit_info_p,
- const char *propname,
+propset_on_url(const char *propname,
const svn_string_t *propval,
const char *target,
svn_boolean_t skip_checks,
@@ -204,7 +203,7 @@ propset_on_url(svn_commit_info_t **commi
svn_node_kind_t node_kind;
const char *message;
const svn_delta_editor_t *editor;
- void *commit_baton, *edit_baton;
+ void *edit_baton;
apr_hash_t *commit_revprops;
svn_error_t *err;
@@ -268,11 +267,10 @@ propset_on_url(svn_commit_info_t **commi
message, ctx, pool));
/* Fetch RA commit editor. */
- SVN_ERR(svn_client__commit_get_baton(&commit_baton, commit_info_p, pool));
SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton,
commit_revprops,
- svn_client__commit_callback,
- commit_baton,
+ ctx->commit_callback2,
+ ctx->commit_baton,
NULL, TRUE, /* No lock tokens */
pool));
@@ -303,7 +301,7 @@ struct set_props_baton
apr_hash_t *changelist_hash;
};
-/* Working copy lock callback for svn_client_propset3 */
+/* Working copy lock callback for svn_client_propset4 */
static svn_error_t *
set_props_cb(void *baton,
apr_pool_t *result_pool,
@@ -339,8 +337,7 @@ set_props_cb(void *baton,
}
svn_error_t *
-svn_client_propset3(svn_commit_info_t **commit_info_p,
- const char *propname,
+svn_client_propset4(const char *propname,
const svn_string_t *propval,
const char *target,
svn_depth_t depth,
@@ -398,9 +395,8 @@ svn_client_propset3(svn_commit_info_t **
_("Setting property '%s' on non-local target "
"'%s' is not supported"), propname, target);
- return propset_on_url(commit_info_p, propname, propval, target,
- skip_checks, base_revision_for_url, revprop_table,
- ctx, pool);
+ return propset_on_url(propname, propval, target, skip_checks,
+ base_revision_for_url, revprop_table, ctx, pool);
}
else
{
@@ -441,7 +437,7 @@ svn_client_propset3(svn_commit_info_t **
baton.changelist_hash = changelist_hash;
SVN_ERR(svn_wc__call_with_write_lock(set_props_cb, &baton,
- ctx->wc_ctx, target_abspath,
+ ctx->wc_ctx, target_abspath, FALSE,
pool, pool));
return SVN_NO_ERROR;
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_client/repos_diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_client/repos_diff.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_client/repos_diff.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_client/repos_diff.c Thu Jul 29 19:38:44 2010
@@ -1057,6 +1057,27 @@ change_file_prop(void *file_baton,
if (b->skip)
return SVN_NO_ERROR;
+ /* Issue #3657 'phantom svn:eol-style changes cause spurious merge text
+ conflicts'. When communicating with the repository via ra_serf and
+ ra_neon, the change_dir_prop and change_file_prop svn_delta_editor_t
+ callbacks are called (obviously) when a directory or file property has
+ changed between the start and end of the edit. Less obvious however,
+ is that these callbacks may be made describing *all* of the properties
+ on FILE_BATON->PATH when using the DAV providers, not just the change(s).
+ (Specifically ra_neon does this for diff/merge and ra_serf does it
+ for diff/merge/update/switch).
+
+ Normally this is fairly harmless, but if it appears that the
+ svn:eol-style property has changed on a file, then we can get spurious
+ text conflicts (i.e. Issue #3657). To prevent this, we populate
+ FILE_BATON->PRISTINE_PROPS only with actual property changes. */
+ if (value)
+ {
+ const char *current_prop = svn_prop_get_value(b->pristine_props, name);
+ if (current_prop && strcmp(current_prop, value->data) == 0)
+ return SVN_NO_ERROR;
+ }
+
propchange = apr_array_push(b->propchanges);
propchange->name = apr_pstrdup(b->pool, name);
propchange->value = value ? svn_string_dup(value, b->pool) : NULL;
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_client/revert.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_client/revert.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_client/revert.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_client/revert.c Thu Jul 29 19:38:44 2010
@@ -151,7 +151,7 @@ svn_client_revert2(const apr_array_heade
baton.changelists = changelists;
baton.ctx = ctx;
err = svn_wc__call_with_write_lock(revert, &baton, ctx->wc_ctx,
- local_abspath, pool, pool);
+ local_abspath, TRUE, pool, pool);
if (err)
goto errorful;
}
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_client/switch.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_client/switch.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_client/switch.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_client/switch.c Thu Jul 29 19:38:44 2010
@@ -294,8 +294,9 @@ svn_client__switch_internal(svn_revnum_t
/* Rely on svn_wc__acquire_write_lock setting ANCHOR_ABSPATH even
when it returns SVN_ERR_WC_LOCKED */
- err = svn_wc__acquire_write_lock(&anchor_abspath, ctx->wc_ctx,
- local_abspath, pool, pool);
+ err = svn_wc__acquire_write_lock(&anchor_abspath,
+ ctx->wc_ctx, local_abspath, TRUE,
+ pool, pool);
if (err && err->apr_err != SVN_ERR_WC_LOCKED)
return svn_error_return(err);
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_client/update.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_client/update.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_client/update.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_client/update.c Thu Jul 29 19:38:44 2010
@@ -158,9 +158,6 @@ update_internal(svn_revnum_t *result_rev
pool));
/* Target excluded, we are done now */
- SVN_ERR(svn_wc__release_write_lock(ctx->wc_ctx, anchor_abspath,
- pool));
-
return SVN_NO_ERROR;
}
@@ -330,31 +327,30 @@ svn_client__update_internal(svn_revnum_t
apr_pool_t *pool)
{
const char *anchor_abspath;
- svn_error_t *err1, *err2;
+ svn_error_t *err;
SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
if (!innerupdate)
- {
- SVN_ERR(svn_wc__acquire_write_lock(&anchor_abspath, ctx->wc_ctx,
- local_abspath, pool, pool));
- }
+ SVN_ERR(svn_wc__acquire_write_lock(&anchor_abspath,
+ ctx->wc_ctx, local_abspath, TRUE,
+ pool, pool));
else
- {
- SVN_ERR(svn_wc__acquire_write_lock(NULL, ctx->wc_ctx,
- local_abspath, pool, pool));
- anchor_abspath = local_abspath;
- }
+ SVN_ERR(svn_wc__acquire_write_lock(&anchor_abspath,
+ ctx->wc_ctx, local_abspath, FALSE,
+ pool, pool));
- err1 = update_internal(result_rev, local_abspath, anchor_abspath,
+ err = update_internal(result_rev, local_abspath, anchor_abspath,
revision, depth, depth_is_sticky,
ignore_externals, allow_unver_obstructions,
timestamp_sleep, send_copyfrom_args,
innerupdate, ctx, pool);
- err2 = svn_wc__release_write_lock(ctx->wc_ctx, anchor_abspath, pool);
+ err = svn_error_compose_create(
+ err,
+ svn_wc__release_write_lock(ctx->wc_ctx, anchor_abspath, pool));
- return svn_error_compose_create(err1, err2);
+ return svn_error_return(err);
}
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/bdb/lock-tokens-table.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/bdb/lock-tokens-table.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/bdb/lock-tokens-table.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/bdb/lock-tokens-table.c Thu Jul 29 19:38:44 2010
@@ -104,7 +104,7 @@ svn_fs_bdb__lock_token_delete(svn_fs_t *
svn_fs_base__trail_debug(trail, "lock-tokens", "del");
db_err = bfd->lock_tokens->del(bfd->lock_tokens, trail->db_txn, &key, 0);
if (db_err == DB_NOTFOUND)
- return SVN_FS__ERR_NO_SUCH_LOCK(fs, path);
+ return SVN_FS__ERR_NO_SUCH_LOCK(fs, path, pool);
return BDB_WRAP(fs, "deleting entry from 'lock-tokens' table", db_err);
}
@@ -131,7 +131,7 @@ svn_fs_bdb__lock_token_get(const char **
svn_fs_base__track_dbt(&value, pool);
if (db_err == DB_NOTFOUND)
- return SVN_FS__ERR_NO_SUCH_LOCK(fs, path);
+ return SVN_FS__ERR_NO_SUCH_LOCK(fs, path, pool);
SVN_ERR(BDB_WRAP(fs, "reading lock token", db_err));
lock_token = apr_pstrmemdup(pool, value.data, value.size);
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/bdb/locks-table.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/bdb/locks-table.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/bdb/locks-table.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/bdb/locks-table.c Thu Jul 29 19:38:44 2010
@@ -152,7 +152,7 @@ svn_fs_bdb__lock_get(svn_lock_t **lock_p
if (lock->expiration_date && (apr_time_now() > lock->expiration_date))
{
SVN_ERR(svn_fs_bdb__lock_delete(fs, lock_token, trail, pool));
- return SVN_FS__ERR_LOCK_EXPIRED(fs, lock_token);
+ return SVN_FS__ERR_LOCK_EXPIRED(fs, lock_token, pool);
}
*lock_p = lock;
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/lock.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/lock.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/lock.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/lock.c Thu Jul 29 19:38:44 2010
@@ -92,7 +92,7 @@ txn_body_lock(void *baton, trail_t *trai
/* Until we implement directory locks someday, we only allow locks
on files or non-existent paths. */
if (kind == svn_node_dir)
- return SVN_FS__ERR_NOT_FILE(trail->fs, args->path);
+ return SVN_FS__ERR_NOT_FILE(trail->fs, args->path, trail->pool);
/* While our locking implementation easily supports the locking of
nonexistent paths, we deliberately choose not to allow such madness. */
@@ -112,7 +112,7 @@ txn_body_lock(void *baton, trail_t *trai
/* There better be a username attached to the fs. */
if (!trail->fs->access_ctx || !trail->fs->access_ctx->username)
- return SVN_FS__ERR_NO_USER(trail->fs);
+ return SVN_FS__ERR_NO_USER(trail->fs, trail->pool);
/* Is the caller attempting to lock an out-of-date working file? */
if (SVN_IS_VALID_REVNUM(args->current_rev))
@@ -178,7 +178,8 @@ txn_body_lock(void *baton, trail_t *trai
{
/* Sorry, the path is already locked. */
return SVN_FS__ERR_PATH_ALREADY_LOCKED(trail->fs,
- existing_lock);
+ existing_lock,
+ trail->pool);
}
else
{
@@ -280,21 +281,22 @@ txn_body_unlock(void *baton, trail_t *tr
if (args->token == NULL)
return svn_fs_base__err_no_lock_token(trail->fs, args->path);
else if (strcmp(lock_token, args->token) != 0)
- return SVN_FS__ERR_NO_SUCH_LOCK(trail->fs, args->path);
+ return SVN_FS__ERR_NO_SUCH_LOCK(trail->fs, args->path, trail->pool);
SVN_ERR(svn_fs_bdb__lock_get(&lock, trail->fs, lock_token,
trail, trail->pool));
/* There better be a username attached to the fs. */
if (!trail->fs->access_ctx || !trail->fs->access_ctx->username)
- return SVN_FS__ERR_NO_USER(trail->fs);
+ return SVN_FS__ERR_NO_USER(trail->fs, trail->pool);
/* And that username better be the same as the lock's owner. */
if (strcmp(trail->fs->access_ctx->username, lock->owner) != 0)
- return SVN_FS__ERR_LOCK_OWNER_MISMATCH
- (trail->fs,
+ return SVN_FS__ERR_LOCK_OWNER_MISMATCH(
+ trail->fs,
trail->fs->access_ctx->username,
- lock->owner);
+ lock->owner,
+ trail->pool);
}
/* Remove a row from each of the locking tables. */
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/tree.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/tree.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_fs_base/tree.c Thu Jul 29 19:38:44 2010
@@ -430,7 +430,7 @@ mutable_root_node(dag_node_t **node_p,
trail, pool);
else
/* If it's not a transaction root, we can't change its contents. */
- return SVN_FS__ERR_NOT_MUTABLE(root->fs, root->rev, error_path);
+ return SVN_FS__ERR_NOT_MUTABLE(root->fs, root->rev, error_path, pool);
}
@@ -768,7 +768,7 @@ open_path(parent_path_t **parent_path_p,
/* The path isn't finished yet; we'd better be in a directory. */
if (svn_fs_base__dag_node_kind(child) != svn_node_dir)
- SVN_ERR_W(SVN_FS__ERR_NOT_DIRECTORY(fs, path_so_far),
+ SVN_ERR_W(SVN_FS__ERR_NOT_DIRECTORY(fs, path_so_far, pool),
apr_psprintf(pool, _("Failure opening '%s'"), path));
rest = next;
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/fs_fs.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/fs_fs.c Thu Jul 29 19:38:44 2010
@@ -250,6 +250,14 @@ svn_fs_fs__path_rev_absolute(const char
svn_revnum_t rev,
apr_pool_t *pool)
{
+ fs_fs_data_t *ffd = fs->fsap_data;
+
+ if (ffd->format < SVN_FS_FS__MIN_PACKED_FORMAT)
+ {
+ *path = path_rev(fs, rev, pool);
+ return SVN_NO_ERROR;
+ }
+
if (! is_packed_rev(fs, rev))
{
svn_node_kind_t kind;
@@ -317,6 +325,7 @@ path_revprops(svn_fs_t *fs, svn_revnum_t
static APR_INLINE const char *
path_txn_dir(svn_fs_t *fs, const char *txn_id, apr_pool_t *pool)
{
+ SVN_ERR_ASSERT_NO_RETURN(txn_id != NULL);
return svn_dirent_join_many(pool, fs->path, PATH_TXNS_DIR,
apr_pstrcat(pool, txn_id, PATH_EXT_TXN, NULL),
NULL);
@@ -1167,6 +1176,8 @@ update_min_unpacked_rev(svn_fs_t *fs, ap
{
fs_fs_data_t *ffd = fs->fsap_data;
+ SVN_ERR_ASSERT(ffd->format >= SVN_FS_FS__MIN_PACKED_FORMAT);
+
return read_min_unpacked_rev(&ffd->min_unpacked_rev,
path_min_unpacked_rev(fs, pool),
pool);
@@ -1177,6 +1188,8 @@ update_min_unpacked_revprop(svn_fs_t *fs
{
fs_fs_data_t *ffd = fs->fsap_data;
+ SVN_ERR_ASSERT(ffd->format >= SVN_FS_FS__MIN_PACKED_REVPROP_FORMAT);
+
return read_min_unpacked_rev(&ffd->min_unpacked_revprop,
path_min_unpacked_revprop(fs, pool),
pool);
@@ -2821,9 +2834,11 @@ svn_fs_fs__revision_proplist(apr_hash_t
apr_pool_t *pool)
{
svn_error_t *err;
+ fs_fs_data_t *ffd = fs->fsap_data;
err = revision_proplist(proplist_p, fs, rev, pool);
- if (err && err->apr_err == SVN_ERR_FS_NO_SUCH_REVISION)
+ if (err && err->apr_err == SVN_ERR_FS_NO_SUCH_REVISION
+ && ffd->format >= SVN_FS_FS__MIN_PACKED_REVPROP_FORMAT)
{
/* If a pack is occurring simultaneously, the min-unpacked-revprop value
could change, so reload it and then attempt to fetch these revprops
@@ -4586,6 +4601,13 @@ get_txn_proplist(apr_hash_t *proplist,
{
svn_stream_t *stream;
+ /* The following error has been observed at least twice in real life when
+ * WANdisco software sends a DAV 'MERGE' command to a Subversion server:
+ * "Can't open file '[...]/db/transactions/props': No such file or directory"
+ * The path should be '[...]/db/transactions/<txn-id>/props'.
+ * The only way that could happen is if txn_id was NULL here. */
+ SVN_ERR_ASSERT(txn_id != NULL);
+
/* Open the transaction properties file. */
SVN_ERR(svn_stream_open_readonly(&stream, path_txn_props(fs, txn_id, pool),
pool, pool));
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/lock.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/lock.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/lock.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/lock.c Thu Jul 29 19:38:44 2010
@@ -462,7 +462,7 @@ get_lock(svn_lock_t **lock_p,
SVN_ERR(read_digest_file(NULL, &lock, fs, digest_path, pool));
if (! lock)
- return SVN_FS__ERR_NO_SUCH_LOCK(fs, path);
+ return SVN_FS__ERR_NO_SUCH_LOCK(fs, path, pool);
/* Don't return an expired lock. */
if (lock->expiration_date && (apr_time_now() > lock->expiration_date))
@@ -472,7 +472,7 @@ get_lock(svn_lock_t **lock_p,
if (have_write_lock)
SVN_ERR(delete_lock(fs, lock, pool));
*lock_p = NULL;
- return SVN_FS__ERR_LOCK_EXPIRED(fs, lock->token);
+ return SVN_FS__ERR_LOCK_EXPIRED(fs, lock->token, pool);
}
*lock_p = lock;
@@ -676,7 +676,7 @@ lock_body(void *baton, apr_pool_t *pool)
SVN_ERR(lb->fs->vtable->revision_root(&root, lb->fs, youngest, pool));
SVN_ERR(svn_fs_fs__check_path(&kind, root, lb->path, pool));
if (kind == svn_node_dir)
- return SVN_FS__ERR_NOT_FILE(lb->fs, lb->path);
+ return SVN_FS__ERR_NOT_FILE(lb->fs, lb->path, pool);
/* While our locking implementation easily supports the locking of
nonexistent paths, we deliberately choose not to allow such madness. */
@@ -696,7 +696,7 @@ lock_body(void *baton, apr_pool_t *pool)
/* We need to have a username attached to the fs. */
if (!lb->fs->access_ctx || !lb->fs->access_ctx->username)
- return SVN_FS__ERR_NO_USER(lb->fs);
+ return SVN_FS__ERR_NO_USER(lb->fs, pool);
/* Is the caller attempting to lock an out-of-date working file? */
if (SVN_IS_VALID_REVNUM(lb->current_rev))
@@ -742,7 +742,7 @@ lock_body(void *baton, apr_pool_t *pool)
if (! lb->steal_lock)
{
/* Sorry, the path is already locked. */
- return SVN_FS__ERR_PATH_ALREADY_LOCKED(lb->fs, existing_lock);
+ return SVN_FS__ERR_PATH_ALREADY_LOCKED(lb->fs, existing_lock, pool);
}
else
{
@@ -797,16 +797,16 @@ unlock_body(void *baton, apr_pool_t *poo
{
/* Sanity check: the incoming token should match lock->token. */
if (strcmp(ub->token, lock->token) != 0)
- return SVN_FS__ERR_NO_SUCH_LOCK(ub->fs, lock->path);
+ return SVN_FS__ERR_NO_SUCH_LOCK(ub->fs, lock->path, pool);
/* There better be a username attached to the fs. */
if (! (ub->fs->access_ctx && ub->fs->access_ctx->username))
- return SVN_FS__ERR_NO_USER(ub->fs);
+ return SVN_FS__ERR_NO_USER(ub->fs, pool);
/* And that username better be the same as the lock's owner. */
if (strcmp(ub->fs->access_ctx->username, lock->owner) != 0)
- return SVN_FS__ERR_LOCK_OWNER_MISMATCH
- (ub->fs, ub->fs->access_ctx->username, lock->owner);
+ return SVN_FS__ERR_LOCK_OWNER_MISMATCH(
+ ub->fs, ub->fs->access_ctx->username, lock->owner, pool);
}
/* Remove lock and lock token files. */
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/tree.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_fs_fs/tree.c Thu Jul 29 19:38:44 2010
@@ -358,7 +358,7 @@ mutable_root_node(dag_node_t **node_p,
return svn_fs_fs__dag_clone_root(node_p, root->fs, root->txn, pool);
else
/* If it's not a transaction root, we can't change its contents. */
- return SVN_FS__ERR_NOT_MUTABLE(root->fs, root->rev, error_path);
+ return SVN_FS__ERR_NOT_MUTABLE(root->fs, root->rev, error_path, pool);
}
@@ -692,7 +692,7 @@ open_path(parent_path_t **parent_path_p,
/* The path isn't finished yet; we'd better be in a directory. */
if (svn_fs_fs__dag_node_kind(child) != svn_node_dir)
- SVN_ERR_W(SVN_FS__ERR_NOT_DIRECTORY(fs, path_so_far),
+ SVN_ERR_W(SVN_FS__ERR_NOT_DIRECTORY(fs, path_so_far, pool),
apr_psprintf(pool, _("Failure opening '%s'"), path));
rest = next;
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra/compat.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra/compat.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra/compat.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra/compat.c Thu Jul 29 19:38:44 2010
@@ -663,24 +663,24 @@ svn_ra__file_revs_from_log(svn_ra_sessio
svn_stream_t *last_stream;
apr_pool_t *currpool, *lastpool;
+ /* Check to make sure we're dealing with a file. */
+ SVN_ERR(svn_ra_check_path(ra_session, path, end, &kind, pool));
+
+ if (kind == svn_node_dir)
+ return svn_error_createf(SVN_ERR_FS_NOT_FILE, NULL,
+ _("'%s' is not a file"), path);
+
SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_url, pool));
SVN_ERR(svn_ra_get_session_url(ra_session, &session_url, pool));
/* Create the initial path, using the repos_url and session_url */
- tmp = svn_path_is_child(repos_url, session_url, pool);
+ tmp = svn_uri_is_child(repos_url, session_url, pool);
repos_abs_path = apr_palloc(pool, strlen(tmp) + 1);
repos_abs_path[0] = '/';
memcpy(repos_abs_path + 1, tmp, strlen(tmp));
- /* Check to make sure we're dealing with a file. */
- SVN_ERR(svn_ra_check_path(ra_session, "", end, &kind, pool));
-
- if (kind == svn_node_dir)
- return svn_error_createf(SVN_ERR_FS_NOT_FILE, NULL,
- _("'%s' is not a file"), repos_abs_path);
-
condensed_targets = apr_array_make(pool, 1, sizeof(const char *));
- APR_ARRAY_PUSH(condensed_targets, const char *) = "";
+ APR_ARRAY_PUSH(condensed_targets, const char *) = path;
lmb.path = svn_path_uri_decode(repos_abs_path, pool);
lmb.eldest = NULL;
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c Thu Jul 29 19:38:44 2010
@@ -341,14 +341,16 @@ deltify_etc(const svn_commit_info_t *com
void *baton, apr_pool_t *pool)
{
struct deltify_etc_baton *db = baton;
- svn_error_t *err1, *err2;
+ svn_error_t *err1 = SVN_NO_ERROR;
+ svn_error_t *err2;
apr_hash_index_t *hi;
apr_pool_t *iterpool;
/* Invoke the original callback first, in case someone's waiting to
know the revision number so they can go off and annotate an
issue or something. */
- err1 = (*db->callback)(commit_info, db->callback_baton, pool);
+ if (*db->callback)
+ err1 = (*db->callback)(commit_info, db->callback_baton, pool);
/* Maybe unlock the paths. */
if (db->lock_tokens)
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_neon/commit.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_neon/commit.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_neon/commit.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_neon/commit.c Thu Jul 29 19:38:44 2010
@@ -1360,7 +1360,7 @@ static svn_error_t * commit_close_edit(v
SVN_ERR(delete_activity(edit_baton, pool));
SVN_ERR(svn_ra_neon__maybe_store_auth_info(cc->ras, pool));
- if (commit_info->revision != SVN_INVALID_REVNUM)
+ if (cc->callback && commit_info->revision != SVN_INVALID_REVNUM)
SVN_ERR(cc->callback(commit_info, cc->callback_baton, pool));
return SVN_NO_ERROR;
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_neon/fetch.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_neon/fetch.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_neon/fetch.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_neon/fetch.c Thu Jul 29 19:38:44 2010
@@ -1715,8 +1715,10 @@ start_element(int *elem, void *userdata,
if (! rb->receiving_all)
break;
+ base_checksum = svn_xml_get_attr_value("base-checksum", atts);
+
SVN_ERR((*rb->editor->apply_textdelta)(rb->file_baton,
- NULL, /* ### base_checksum */
+ base_checksum,
rb->file_pool,
&(rb->whandler),
&(rb->whandler_baton)));
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/commit.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/commit.c Thu Jul 29 19:38:44 2010
@@ -1992,8 +1992,9 @@ close_edit(void *edit_baton,
}
/* Inform the WC that we did a commit. */
- SVN_ERR(ctx->callback(svn_ra_serf__merge_get_commit_info(merge_ctx),
- ctx->callback_baton, pool));
+ if (ctx->callback)
+ SVN_ERR(ctx->callback(svn_ra_serf__merge_get_commit_info(merge_ctx),
+ ctx->callback_baton, pool));
/* If we're using activities, DELETE our completed activity. */
if (ctx->activity_url)
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/update.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/update.c Thu Jul 29 19:38:44 2010
@@ -218,6 +218,9 @@ typedef struct report_info_t
svn_txdelta_window_handler_t textdelta;
void *textdelta_baton;
+ /* Checksum for close_file */
+ const char *final_checksum;
+
/* temporary property for this file which is currently being parsed
* It will eventually be stored in our parent directory's property hash.
*/
@@ -445,6 +448,12 @@ set_file_props(void *baton,
report_info_t *info = baton;
const svn_delta_editor_t *editor = info->dir->update_editor;
+ if (name_len == 12
+ && ns_len == 39
+ && strcmp(name, "md5-checksum") == 0
+ && strcmp(ns, SVN_DAV_PROP_NS_DAV) == 0)
+ info->final_checksum = apr_pstrdup(info->pool, val->data);
+
return svn_ra_serf__set_baton_props(editor->change_file_prop,
info->file_baton,
ns, ns_len, name, name_len, val, pool);
@@ -947,7 +956,8 @@ handle_fetch(serf_request_t *request,
info, info->editor_pool);
}
- err = info->dir->update_editor->close_file(info->file_baton, NULL,
+ err = info->dir->update_editor->close_file(info->file_baton,
+ info->final_checksum,
info->editor_pool);
if (err)
@@ -1120,7 +1130,8 @@ handle_propchange_only(report_info_t *in
set_file_props, info, info->editor_pool);
}
- SVN_ERR(info->dir->update_editor->close_file(info->file_baton, NULL,
+ SVN_ERR(info->dir->update_editor->close_file(info->file_baton,
+ info->final_checksum,
info->editor_pool));
/* We're done with our pools. */
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/win32_auth_sspi.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/win32_auth_sspi.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/win32_auth_sspi.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/win32_auth_sspi.c Thu Jul 29 19:38:44 2010
@@ -171,14 +171,18 @@ do_auth(serf_sspi_context_t *sspi_contex
apr_size_t tmp_len, token_len = 0;
const char *space;
- space = strchr(auth_attr, ' ');
- if (space)
+ if (auth_attr != NULL)
{
- const char *base64_token = apr_pstrmemdup(pool,
- auth_attr, space - auth_attr);
- token_len = apr_base64_decode_len(base64_token);
- token = apr_palloc(pool, token_len);
- apr_base64_decode(token, base64_token);
+ space = strchr(auth_attr, ' ');
+ if (space)
+ {
+ const char *base64_token = apr_pstrmemdup(pool,
+ auth_attr,
+ space - auth_attr);
+ token_len = apr_base64_decode_len(base64_token);
+ token = apr_palloc(pool, token_len);
+ apr_base64_decode(token, base64_token);
+ }
}
/* We can get a whole batch of 401 responses from the server, but we should
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c Thu Jul 29 19:38:44 2010
@@ -891,8 +891,10 @@ static svn_error_t *ra_svn_end_commit(vo
&(commit_info->author),
&(commit_info->post_commit_err)));
- return ccb->callback(commit_info, ccb->callback_baton, ccb->pool);
+ if (ccb->callback)
+ SVN_ERR(ccb->callback(commit_info, ccb->callback_baton, ccb->pool));
+ return SVN_NO_ERROR;
}
static svn_error_t *ra_svn_commit(svn_ra_session_t *session,
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_repos/dump.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_repos/dump.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_repos/dump.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_repos/dump.c Thu Jul 29 19:38:44 2010
@@ -25,6 +25,7 @@
#include "svn_pools.h"
#include "svn_error.h"
#include "svn_fs.h"
+#include "svn_hash.h"
#include "svn_iter.h"
#include "svn_repos.h"
#include "svn_string.h"
@@ -40,92 +41,6 @@
/*----------------------------------------------------------------------*/
-/** A variant of our hash-writing routine in libsvn_subr; this one
- writes to a stringbuf instead of a file, and outputs PROPS-END
- instead of END. If OLDHASH is not NULL, then only properties
- which vary from OLDHASH will be written, and properties which
- exist only in OLDHASH will be written out with "D" entries
- (like "K" entries but with no corresponding value). **/
-
-static void
-write_hash_to_stringbuf(apr_hash_t *hash,
- apr_hash_t *oldhash,
- svn_stringbuf_t **strbuf,
- apr_pool_t *pool)
-{
- apr_hash_index_t *this; /* current hash entry */
-
- *strbuf = svn_stringbuf_create("", pool);
-
- for (this = apr_hash_first(pool, hash); this; this = apr_hash_next(this))
- {
- const void *key;
- void *val;
- apr_ssize_t keylen;
- svn_string_t *value;
-
- /* Get this key and val. */
- apr_hash_this(this, &key, &keylen, &val);
- value = val;
-
- /* Don't output properties equal to the ones in oldhash, if present. */
- if (oldhash)
- {
- svn_string_t *oldvalue = apr_hash_get(oldhash, key, keylen);
-
- if (oldvalue && svn_string_compare(value, oldvalue))
- continue;
- }
-
- /* Output name length, then name. */
-
- svn_stringbuf_appendcstr(*strbuf,
- apr_psprintf(pool, "K %" APR_SSIZE_T_FMT "\n",
- keylen));
-
- svn_stringbuf_appendbytes(*strbuf, (const char *) key, keylen);
- svn_stringbuf_appendbytes(*strbuf, "\n", 1);
-
- /* Output value length, then value. */
-
- svn_stringbuf_appendcstr(*strbuf,
- apr_psprintf(pool, "V %" APR_SIZE_T_FMT "\n",
- value->len));
-
- svn_stringbuf_appendbytes(*strbuf, value->data, value->len);
- svn_stringbuf_appendbytes(*strbuf, "\n", 1);
- }
-
- if (oldhash)
- {
- /* Output a "D " entry for each property in oldhash but not hash. */
- for (this = apr_hash_first(pool, oldhash); this;
- this = apr_hash_next(this))
- {
- const void *key;
- apr_ssize_t keylen;
-
- /* Get this key. */
- apr_hash_this(this, &key, &keylen, NULL);
-
- /* Only output values deleted in hash. */
- if (apr_hash_get(hash, key, keylen))
- continue;
-
- /* Output name length, then name. */
-
- svn_stringbuf_appendcstr(*strbuf,
- apr_psprintf(pool,
- "D %" APR_SSIZE_T_FMT "\n",
- keylen));
-
- svn_stringbuf_appendbytes(*strbuf, (const char *) key, keylen);
- svn_stringbuf_appendbytes(*strbuf, "\n", 1);
- }
- }
- svn_stringbuf_appendbytes(*strbuf, "PROPS-END\n", 10);
-}
-
/* Compute the delta between OLDROOT/OLDPATH and NEWROOT/NEWPATH and
store it into a new temporary file *TEMPFILE. OLDROOT may be NULL,
@@ -509,6 +424,7 @@ dump_node(struct edit_baton *eb,
{
apr_hash_t *prophash, *oldhash = NULL;
apr_size_t proplen;
+ svn_stream_t *propstream;
SVN_ERR(svn_fs_node_proplist(&prophash, eb->fs_root, path, pool));
@@ -559,7 +475,13 @@ dump_node(struct edit_baton *eb,
SVN_REPOS_DUMPFILE_PROP_DELTA
": true\n"));
}
- write_hash_to_stringbuf(prophash, oldhash, &propstring, pool);
+ else
+ oldhash = apr_hash_make(pool);
+ propstring = svn_stringbuf_create_ensure(0, pool);
+ propstream = svn_stream_from_stringbuf(propstring, pool);
+ svn_hash_write_incremental(prophash, oldhash, propstream, "PROPS-END",
+ pool);
+ SVN_ERR(svn_stream_close(propstream));
proplen = propstring->len;
content_length += proplen;
SVN_ERR(svn_stream_printf(eb->stream, pool,
@@ -962,6 +884,7 @@ write_revision_record(svn_stream_t *stre
svn_stringbuf_t *encoded_prophash;
apr_time_t timetemp;
svn_string_t *datevalue;
+ svn_stream_t *propstream;
/* Read the revision props even if we're aren't going to dump
them for verification purposes */
@@ -981,7 +904,10 @@ write_revision_record(svn_stream_t *stre
datevalue);
}
- write_hash_to_stringbuf(props, NULL, &encoded_prophash, pool);
+ encoded_prophash = svn_stringbuf_create_ensure(0, pool);
+ propstream = svn_stream_from_stringbuf(encoded_prophash, pool);
+ svn_hash_write2(props, propstream, "PROPS-END", pool);
+ SVN_ERR(svn_stream_close(propstream));
/* ### someday write a revision-content-checksum */
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_repos/repos.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_repos/repos.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_repos/repos.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_repos/repos.c Thu Jul 29 19:38:44 2010
@@ -1806,14 +1806,14 @@ struct hotcopy_ctx_t {
size_t src_len; /* len of the source path*/
};
-/** Called by (svn_io_dir_walk).
+/** Called by (svn_io_dir_walk2).
* Copies the repository structure with exception of @c SVN_REPOS__DB_DIR,
* @c SVN_REPOS__LOCK_DIR and @c SVN_REPOS__FORMAT.
* Those directories and files are handled separetly.
* @a baton is a pointer to (struct hotcopy_ctx_t) specifying
* destination path to copy to and the length of the source path.
*
- * @copydoc svn_io_dir_walk()
+ * @copydoc svn_io_dir_walk2()
*/
static svn_error_t *hotcopy_structure(void *baton,
const char *path,
@@ -1910,11 +1910,11 @@ svn_repos_hotcopy(const char *src_path,
hotcopy_context.dest = dst_path;
hotcopy_context.src_len = strlen(src_path);
- SVN_ERR(svn_io_dir_walk(src_path,
- 0,
- hotcopy_structure,
- &hotcopy_context,
- pool));
+ SVN_ERR(svn_io_dir_walk2(src_path,
+ 0,
+ hotcopy_structure,
+ &hotcopy_context,
+ pool));
/* Prepare dst_repos object so that we may create locks,
so that we may open repository */
Modified: subversion/branches/issue-2779-dev/subversion/libsvn_subr/config.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_subr/config.c?rev=980551&r1=980550&r2=980551&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_subr/config.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_subr/config.c Thu Jul 29 19:38:44 2010
@@ -78,18 +78,29 @@ struct cfg_option_t
svn_error_t *
+svn_config_create(svn_config_t **cfgp, apr_pool_t *result_pool)
+{
+ svn_config_t *cfg = apr_palloc(result_pool, sizeof(*cfg));
+
+ cfg->sections = apr_hash_make(result_pool);
+ cfg->pool = result_pool;
+ cfg->x_pool = svn_pool_create(result_pool);
+ cfg->x_values = FALSE;
+ cfg->tmp_key = svn_stringbuf_create("", result_pool);
+ cfg->tmp_value = svn_stringbuf_create("", result_pool);
+
+ *cfgp = cfg;
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_config_read(svn_config_t **cfgp, const char *file,
svn_boolean_t must_exist, apr_pool_t *pool)
{
- svn_config_t *cfg = apr_palloc(pool, sizeof(*cfg));
+ svn_config_t *cfg;
svn_error_t *err;
- cfg->sections = apr_hash_make(pool);
- cfg->pool = pool;
- cfg->x_pool = svn_pool_create(pool);
- cfg->x_values = FALSE;
- cfg->tmp_key = svn_stringbuf_create("", pool);
- cfg->tmp_value = svn_stringbuf_create("", pool);
+ SVN_ERR(svn_config_create(&cfg, pool));
/* Yes, this is platform-specific code in Subversion, but there's no
practical way to migrate it into APR, as it's simultaneously