Author: rhuijben
Date: Fri Mar 6 15:48:06 2015
New Revision: 1664664
URL: http://svn.apache.org/r1664664
Log:
In the commit processing in the repository layer verify that the revision
passed to open_root() makes sense, like we already did in the http-v1 dav
code.
This patch adds the check for ra-svn and ra-local, but leaves http-v2 broken.
(I'm working on a fix for that problem in mod_dav)
Found by: philip
* subversion/libsvn_repos/commit.c
(open_root): Return an error when opening the root for revisions above HEAD.
* subversion/tests/libsvn_ra/ra-test.c
(commit_callback_failure): Open the root for the right revision.
(base_revision_above_youngest): New test, mostly copied from
commit_callback_failure, verifying the behavior on this new issue.
(test_list): Add base_revision_above_youngest.
Modified:
subversion/trunk/subversion/libsvn_repos/commit.c
subversion/trunk/subversion/tests/libsvn_ra/ra-test.c
Modified: subversion/trunk/subversion/libsvn_repos/commit.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/commit.c?rev=1664664&r1=1664663&r2=1664664&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/commit.c (original)
+++ subversion/trunk/subversion/libsvn_repos/commit.c Fri Mar 6 15:48:06 2015
@@ -397,6 +397,11 @@ open_root(void *edit_baton,
dateness checks. */
SVN_ERR(svn_fs_youngest_rev(&youngest, eb->fs, eb->pool));
+ if (base_revision > youngest)
+ return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
+ _("No such revision %ld (HEAD is %ld)"),
+ base_revision, youngest);
+
/* Unless we've been instructed to use a specific transaction, we'll
make our own. */
if (eb->txn_owner)
Modified: subversion/trunk/subversion/tests/libsvn_ra/ra-test.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_ra/ra-test.c?rev=1664664&r1=1664663&r2=1664664&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_ra/ra-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_ra/ra-test.c Fri Mar 6 15:48:06
2015
@@ -651,7 +651,7 @@ commit_callback_failure(const svn_test_o
apr_hash_make(pool),
commit_callback_with_failure,
NULL, NULL, FALSE, pool));
- SVN_ERR(editor->open_root(edit_baton, 1, pool, &root_baton));
+ SVN_ERR(editor->open_root(edit_baton, 0, pool, &root_baton));
SVN_ERR(editor->change_dir_prop(root_baton, "A",
svn_string_create("B", pool), pool));
SVN_ERR(editor->close_directory(root_baton, pool));
@@ -664,6 +664,41 @@ commit_callback_failure(const svn_test_o
return SVN_NO_ERROR;
}
+static svn_error_t *
+base_revision_above_youngest(const svn_test_opts_t *opts,
+ apr_pool_t *pool)
+{
+ svn_ra_session_t *ra_session;
+ const svn_delta_editor_t *editor;
+ void *edit_baton;
+ void *root_baton;
+ svn_error_t *err;
+ SVN_ERR(make_and_open_repos(&ra_session, "base_revision_above_youngest",
opts, pool));
+
+ SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton,
+ apr_hash_make(pool), NULL,
+ NULL, NULL, FALSE, pool));
+
+ err = editor->open_root(edit_baton, 1, pool, &root_baton);
+
+ if (!err)
+ err = editor->change_dir_prop(root_baton, "A",
+ svn_string_create("B", pool), pool);
+
+ if (!err)
+ err = editor->close_directory(root_baton, pool);
+
+ if (!err)
+ err = editor->close_edit(edit_baton, pool);
+
+ SVN_TEST_ASSERT_ERROR(err,
+ SVN_ERR_FS_NO_SUCH_REVISION);
+
+ SVN_ERR(editor->abort_edit(edit_baton, pool));
+ return SVN_NO_ERROR;
+}
+
+
/* The test table. */
@@ -684,6 +719,8 @@ static struct svn_test_descriptor_t test
"test ra_get_dir2"),
SVN_TEST_OPTS_PASS(commit_callback_failure,
"commit callback failure"),
+ SVN_TEST_OPTS_PASS(base_revision_above_youngest,
+ "base revision newer than youngest"),
SVN_TEST_NULL
};