Author: rhuijben
Date: Fri Dec 13 20:07:03 2013
New Revision: 1550831
URL: http://svn.apache.org/r1550831
Log:
Extend the mtcc tests to change a few files remotely and fix a few more
issues found using this testcase.
* subversion/libsvn_client/mtcc.c
(commit_file): Use the stream read checksum. Explicitly close the used
files in all cases or we won't get a checksum.
* subversion/tests/libsvn_client/mtcc-test.c
(test_update_files): New test.
(test_list): Add test_update_files.
Modified:
subversion/trunk/subversion/libsvn_client/mtcc.c
subversion/trunk/subversion/tests/libsvn_client/mtcc-test.c
Modified: subversion/trunk/subversion/libsvn_client/mtcc.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mtcc.c?rev=1550831&r1=1550830&r2=1550831&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mtcc.c (original)
+++ subversion/trunk/subversion/libsvn_client/mtcc.c Fri Dec 13 20:07:03 2013
@@ -561,7 +561,7 @@ commit_file(const svn_delta_editor_t *ed
if (window_handler != svn_delta_noop_window_handler)
{
if (!src_checksum || src_checksum->kind != svn_checksum_md5)
- src_stream = svn_stream_checksummed2(src_stream, NULL,
&src_checksum,
+ src_stream = svn_stream_checksummed2(src_stream, &src_checksum,
NULL,
svn_checksum_md5,
TRUE, scratch_pool);
@@ -576,17 +576,14 @@ commit_file(const svn_delta_editor_t *ed
ctx->cancel_func, ctx->cancel_baton,
scratch_pool, scratch_pool));
}
- else
- {
- if (op->src_stream)
- SVN_ERR(svn_stream_close(op->src_stream));
- if (op->base_stream)
- SVN_ERR(svn_stream_close(op->base_stream));
- }
+
+ SVN_ERR(svn_stream_close(src_stream));
+ if (op->base_stream)
+ SVN_ERR(svn_stream_close(op->base_stream));
}
- if (op->src_checksum && op->src_checksum->kind == svn_checksum_md5)
- text_checksum = svn_checksum_to_cstring(op->src_checksum, scratch_pool);
+ if (src_checksum && src_checksum->kind == svn_checksum_md5)
+ text_checksum = svn_checksum_to_cstring(src_checksum, scratch_pool);
return svn_error_trace(editor->close_file(file_baton, text_checksum,
scratch_pool));
Modified: subversion/trunk/subversion/tests/libsvn_client/mtcc-test.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_client/mtcc-test.c?rev=1550831&r1=1550830&r2=1550831&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_client/mtcc-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_client/mtcc-test.c Fri Dec 13
20:07:03 2013
@@ -239,6 +239,64 @@ test_propset(const svn_test_opts_t *opts
return SVN_NO_ERROR;
}
+static svn_error_t *
+test_update_files(const svn_test_opts_t *opts,
+ apr_pool_t *pool)
+{
+ svn_client_mtcc_t *mtcc;
+ svn_client_ctx_t *ctx;
+ const char *repos_abspath;
+ const char *repos_url;
+ svn_repos_t* repos;
+
+ repos_abspath = svn_test_data_path("mtcc-update-files", pool);
+ SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool));
+ SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool));
+ SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool));
+
+ SVN_ERR(make_greek_tree(repos_url, pool));
+
+ SVN_ERR(svn_client_create_context2(&ctx, NULL, pool));
+ SVN_ERR(svn_client_mtcc_create(&mtcc, repos_url, 1, ctx, pool, pool));
+
+ /* Update iota with knowledge of the old data */
+ SVN_ERR(svn_client_mtcc_add_update_file(svn_test__greek_tree_nodes[0].path,
+ svn_stream_from_string(
+ svn_string_create(
+ "new-iota", pool),
+ pool),
+ NULL,
+ svn_stream_from_string(
+ svn_string_create(
+ svn_test__greek_tree_nodes[0]
+ .contents,
+ pool),
+ pool),
+ NULL,
+ mtcc, pool));
+
+ SVN_ERR(svn_client_mtcc_add_update_file("A/mu",
+ svn_stream_from_string(
+ svn_string_create(
+ "new-MU", pool),
+ pool),
+ NULL,
+ NULL, NULL,
+ mtcc, pool));
+
+ /* Set a property on the same node */
+ SVN_ERR(svn_client_mtcc_add_propset("A/mu", "mu-key",
+ svn_string_create("mu-A", pool), FALSE,
+ mtcc, pool));
+ /* And some other node */
+ SVN_ERR(svn_client_mtcc_add_propset("A/B", "B-key",
+ svn_string_create("val-B", pool), FALSE,
+ mtcc, pool));
+
+ SVN_ERR(verify_mtcc_commit(mtcc, 2, pool));
+ return SVN_NO_ERROR;
+}
+
/* ==========================================================================
*/
@@ -255,6 +313,8 @@ struct svn_test_descriptor_t test_funcs[
"swapping some trees"),
SVN_TEST_OPTS_PASS(test_propset,
"test propset and propdel"),
+ SVN_TEST_OPTS_PASS(test_update_files,
+ "test update files"),
SVN_TEST_NULL
};