Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 690E810006 for ; Fri, 7 Mar 2014 17:15:30 +0000 (UTC) Received: (qmail 52805 invoked by uid 500); 7 Mar 2014 17:15:29 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 52579 invoked by uid 500); 7 Mar 2014 17:15:28 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 52572 invoked by uid 99); 7 Mar 2014 17:15:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2014 17:15:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2014 17:15:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1BE702388A5E; Fri, 7 Mar 2014 17:15:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1575333 - in /subversion/branches/1.7.x-r1574868: ./ subversion/libsvn_repos/dump.c subversion/tests/libsvn_repos/repos-test.c Date: Fri, 07 Mar 2014 17:15:02 -0000 To: commits@subversion.apache.org From: julianfoad@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140307171503.1BE702388A5E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: julianfoad Date: Fri Mar 7 17:15:02 2014 New Revision: 1575333 URL: http://svn.apache.org/r1575333 Log: On the 1.7.x-r1574868 branch: merge r1574868 from trunk. Modified: subversion/branches/1.7.x-r1574868/ (props changed) subversion/branches/1.7.x-r1574868/subversion/libsvn_repos/dump.c subversion/branches/1.7.x-r1574868/subversion/tests/libsvn_repos/repos-test.c Propchange: subversion/branches/1.7.x-r1574868/ ------------------------------------------------------------------------------ Merged /subversion/trunk:r1574868 Modified: subversion/branches/1.7.x-r1574868/subversion/libsvn_repos/dump.c URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-r1574868/subversion/libsvn_repos/dump.c?rev=1575333&r1=1575332&r2=1575333&view=diff ============================================================================== --- subversion/branches/1.7.x-r1574868/subversion/libsvn_repos/dump.c (original) +++ subversion/branches/1.7.x-r1574868/subversion/libsvn_repos/dump.c Fri Mar 7 17:15:02 2014 @@ -212,6 +212,48 @@ make_dir_baton(const char *path, return new_db; } +/* If the mergeinfo in MERGEINFO_STR refers to any revisions older than + * OLDEST_DUMPED_REV, issue a warning and set *FOUND_OLD_MERGEINFO to TRUE, + * otherwise leave *FOUND_OLD_MERGEINFO unchanged. + */ +static svn_error_t * +verify_mergeinfo_revisions(svn_boolean_t *found_old_mergeinfo, + const char *mergeinfo_str, + svn_revnum_t oldest_dumped_rev, + svn_repos_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool) +{ + svn_mergeinfo_t mergeinfo, old_mergeinfo; + + SVN_ERR(svn_mergeinfo_parse(&mergeinfo, mergeinfo_str, pool)); + SVN_ERR(svn_mergeinfo__filter_mergeinfo_by_ranges( + &old_mergeinfo, mergeinfo, + oldest_dumped_rev - 1, 0, + TRUE, pool, pool)); + + if (apr_hash_count(old_mergeinfo)) + { + svn_repos_notify_t *notify = + svn_repos_notify_create(svn_repos_notify_warning, pool); + + notify->warning = svn_repos_notify_warning_found_old_mergeinfo; + notify->warning_str = apr_psprintf( + pool, + _("Mergeinfo referencing revision(s) prior " + "to the oldest dumped revision (r%ld). " + "Loading this dump may result in invalid " + "mergeinfo."), + oldest_dumped_rev); + + if (found_old_mergeinfo) + *found_old_mergeinfo = TRUE; + notify_func(notify_baton, notify, pool); + } + + return SVN_NO_ERROR; +} + /* This helper is the main "meat" of the editor -- it does all the work of writing a node record. @@ -473,31 +515,13 @@ dump_node(struct edit_baton *eb, APR_HASH_KEY_STRING); if (mergeinfo_str) { - svn_mergeinfo_t mergeinfo, old_mergeinfo; - - SVN_ERR(svn_mergeinfo_parse(&mergeinfo, mergeinfo_str->data, - pool)); - SVN_ERR(svn_mergeinfo__filter_mergeinfo_by_ranges( - &old_mergeinfo, mergeinfo, - eb->oldest_dumped_rev - 1, 0, - TRUE, pool, pool)); - if (apr_hash_count(old_mergeinfo)) - { - svn_repos_notify_t *notify = - svn_repos_notify_create(svn_repos_notify_warning, pool); - - notify->warning = svn_repos_notify_warning_found_old_mergeinfo; - notify->warning_str = apr_psprintf( - pool, - _("Mergeinfo referencing revision(s) prior " - "to the oldest dumped revision (r%ld). " - "Loading this dump may result in invalid " - "mergeinfo."), - eb->oldest_dumped_rev); - - eb->found_old_mergeinfo = TRUE; - eb->notify_func(eb->notify_baton, notify, pool); - } + /* An error in verifying the mergeinfo must not prevent dumping + the data. Ignore any such error. */ + svn_error_clear(verify_mergeinfo_revisions( + eb->found_old_mergeinfo, + mergeinfo_str->data, eb->oldest_dumped_rev, + eb->notify_func, eb->notify_baton, + pool)); } } Modified: subversion/branches/1.7.x-r1574868/subversion/tests/libsvn_repos/repos-test.c URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-r1574868/subversion/tests/libsvn_repos/repos-test.c?rev=1575333&r1=1575332&r2=1575333&view=diff ============================================================================== --- subversion/branches/1.7.x-r1574868/subversion/tests/libsvn_repos/repos-test.c (original) +++ subversion/branches/1.7.x-r1574868/subversion/tests/libsvn_repos/repos-test.c Fri Mar 7 17:15:02 2014 @@ -2527,6 +2527,65 @@ issue_4060(const svn_test_opts_t *opts, } +/* Notification receiver for test_dump_bad_mergeinfo(). This does not + need to do anything, it just needs to exist. + */ +static void +dump_r0_mergeinfo_notifier(void *baton, + const svn_repos_notify_t *notify, + apr_pool_t *scratch_pool) +{ +} + +/* Regression test for part the 'dump' part of issue #4476 "Mergeinfo + containing r0 makes svnsync and svnadmin dump fail". */ +static svn_error_t * +test_dump_r0_mergeinfo(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_repos_t *repos; + svn_fs_t *fs; + svn_fs_txn_t *txn; + svn_fs_root_t *txn_root; + svn_revnum_t youngest_rev = 0; + const svn_string_t *bad_mergeinfo = svn_string_create("/foo:0", pool); + + SVN_ERR(svn_test__create_repos(&repos, "test-repo-dump-r0-mergeinfo", + opts, pool)); + fs = svn_repos_fs(repos); + + /* Revision 1: Any commit will do, here */ + SVN_ERR(svn_fs_begin_txn(&txn, fs, youngest_rev, pool)); + SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); + SVN_ERR(svn_fs_make_dir(txn_root, "/bar", pool)); + SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool)); + SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev)); + + /* Revision 2: Add bad mergeinfo */ + SVN_ERR(svn_fs_begin_txn(&txn, fs, youngest_rev, pool)); + SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); + SVN_ERR(svn_fs_change_node_prop(txn_root, "/bar", "svn:mergeinfo", bad_mergeinfo, pool)); + SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool)); + SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev)); + + /* Test that a dump completes without error. In order to exercise the + functionality under test -- that is, in order for the dump to try to + parse the mergeinfo it is dumping -- the dump must start from a + revision greater than 1 and must take a notification callback. */ + { + svn_stringbuf_t *stringbuf = svn_stringbuf_create("", pool); + svn_stream_t *stream = svn_stream_from_stringbuf(stringbuf, pool); + + SVN_ERR(svn_repos_dump_fs3(repos, stream, 2, SVN_INVALID_REVNUM, + FALSE, FALSE, + dump_r0_mergeinfo_notifier, NULL, + NULL, NULL, + pool)); + } + + return SVN_NO_ERROR; +} + /* The test table. */ struct svn_test_descriptor_t test_funcs[] = @@ -2562,5 +2621,7 @@ struct svn_test_descriptor_t test_funcs[ "test svn_repos_get_file_revsN"), SVN_TEST_OPTS_PASS(issue_4060, "test issue 4060"), + SVN_TEST_OPTS_PASS(test_dump_r0_mergeinfo, + "test dumping with r0 mergeinfo"), SVN_TEST_NULL };