2008-02-26 20:09 epg_at_tigris.org <epg_at_tigris.org> napisał(a):
> Author: epg
> Date: Tue Feb 26 11:09:37 2008
> New Revision: 29600
>
> Log:
> r26470 changed all the subcommand batons to a shared implementation, with
> each baton now allocated from a pool rather than on the stack, but
> copy_revprops_cmd still passed the *address* of baton. To help prevent
> such errors in the future, how about some type checking and testing?
>
> * subversion/svnsync/main.c
> (with_locked_func_t): Use subcommand_baton_t * not void *;
> change all implementations.
> (with_locked): Take subcommand_baton_t * not void *.
> (copy_revprops_cmd): Pass baton to with_locked, not &baton.
>
> * subversion/tests/cmdline/svnsync_tests.py
> (run_copy_revprops): Add function to run copy-revprops.
> (run_test): Call run_copy_revprops after run_sync.
>
>
> Modified:
> trunk/subversion/svnsync/main.c
> trunk/subversion/tests/cmdline/svnsync_tests.py
>
> Modified: trunk/subversion/svnsync/main.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/svnsync/main.c?pathrev=29600&r1=29599&r2=29600
> ==============================================================================
> --- trunk/subversion/svnsync/main.c (original)
> +++ trunk/subversion/svnsync/main.c Tue Feb 26 11:09:37 2008
> @@ -262,8 +262,29 @@
> }
>
>
> +/* Baton for the various subcommands to share. */
> +typedef struct {
> + /* common to all subcommands */
> + apr_hash_t *config;
> + svn_ra_callbacks2_t source_callbacks;
> + svn_ra_callbacks2_t sync_callbacks;
> + svn_boolean_t quiet;
> + const char *to_url;
> +
> + /* initialize only */
> + const char *from_url;
> +
> + /* syncronize only */
"synchronize" would be better.
> + svn_revnum_t committed_rev;
> +
> + /* copy-revprops only */
> + svn_revnum_t start_rev;
> + svn_revnum_t end_rev;
> +
> +} subcommand_baton_t;
> +
> typedef svn_error_t *(*with_locked_func_t)(svn_ra_session_t *session,
> - void *baton,
> + subcommand_baton_t *baton,
> apr_pool_t *pool);
>
>
> @@ -274,7 +295,7 @@
> static svn_error_t *
> with_locked(svn_ra_session_t *session,
> with_locked_func_t func,
> - void *baton,
> + subcommand_baton_t *baton,
> apr_pool_t *pool)
> {
> svn_error_t *err, *err2;
> @@ -531,27 +552,6 @@
> }
>
>
> -/* Baton for the various subcommands to share. */
> -typedef struct {
> - /* common to all subcommands */
> - apr_hash_t *config;
> - svn_ra_callbacks2_t source_callbacks;
> - svn_ra_callbacks2_t sync_callbacks;
> - svn_boolean_t quiet;
> - const char *to_url;
> -
> - /* initialize only */
> - const char *from_url;
> -
> - /* syncronize only */
> - svn_revnum_t committed_rev;
> -
> - /* copy-revprops only */
> - svn_revnum_t start_rev;
> - svn_revnum_t end_rev;
> -
> -} subcommand_baton_t;
> -
> /* Return a subcommand baton allocated from POOL and populated with
> data from the provided parameters, which include the global
> OPT_BATON options structure and a handful of other options. Not
> @@ -588,11 +588,10 @@
> */
> static svn_error_t *
> do_initialize(svn_ra_session_t *to_session,
> - void *b,
> + subcommand_baton_t *baton,
> apr_pool_t *pool)
> {
> svn_ra_session_t *from_session;
> - subcommand_baton_t *baton = b;
> svn_string_t *from_url;
> svn_revnum_t latest;
> const char *uuid, *root_url;
> @@ -1333,12 +1332,12 @@
> * locked. Implements `with_locked_func_t' interface.
> */
> static svn_error_t *
> -do_synchronize(svn_ra_session_t *to_session, void *b, apr_pool_t *pool)
> +do_synchronize(svn_ra_session_t *to_session,
> + subcommand_baton_t *baton, apr_pool_t *pool)
> {
> svn_string_t *last_merged_rev;
> svn_revnum_t from_latest;
> svn_ra_session_t *from_session;
> - subcommand_baton_t *baton = b;
> svn_string_t *currently_copying;
> svn_revnum_t to_latest, copying, last_merged;
> svn_revnum_t start_revision, end_revision;
> @@ -1495,9 +1494,9 @@
> * repository is locked. Implements `with_locked_func_t' interface.
> */
> static svn_error_t *
> -do_copy_revprops(svn_ra_session_t *to_session, void *b, apr_pool_t *pool)
> +do_copy_revprops(svn_ra_session_t *to_session,
> + subcommand_baton_t *baton, apr_pool_t *pool)
> {
> - subcommand_baton_t *baton = b;
> svn_ra_session_t *from_session;
> svn_string_t *last_merged_rev;
> svn_revnum_t i;
> @@ -1632,7 +1631,7 @@
> SVN_ERR(svn_ra_open2(&to_session, baton->to_url, &(baton->sync_callbacks),
> baton, baton->config, pool));
> SVN_ERR(check_if_session_is_at_repos_root(to_session, baton->to_url, pool));
> - SVN_ERR(with_locked(to_session, do_copy_revprops, &baton, pool));
> + SVN_ERR(with_locked(to_session, do_copy_revprops, baton, pool));
>
> return SVN_NO_ERROR;
> }
>
> Modified: trunk/subversion/tests/cmdline/svnsync_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svnsync_tests.py?pathrev=29600&r1=29599&r2=29600
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svnsync_tests.py (original)
> +++ trunk/subversion/tests/cmdline/svnsync_tests.py Tue Feb 26 11:09:37 2008
> @@ -65,6 +65,26 @@
> # should be: ['Committed revision 1.\n', 'Committed revision 2.\n']
> raise SVNUnexpectedStdout("Missing stdout")
>
> +def run_copy_revprops(url, expected_error=None):
> + "Copy revprops to the mirror repository from the master"
> + output, errput = svntest.main.run_svnsync(
> + "copy-revprops", url,
> + "--username", svntest.main.wc_author,
> + "--password", svntest.main.wc_passwd)
> + if errput:
> + if expected_error is None:
> + raise SVNUnexpectedStderr(errput)
> + else:
> + expected_error = svntest.verify.RegexOutput(expected_error,
> + match_all=False)
> + svntest.verify.compare_and_display_lines(None, "STDERR",
> + expected_error, errput)
> + elif expected_error is not None:
> + raise SVNExpectedStderr
> + if not output and not expected_error:
> + # should be: ['Committed revision 1.\n', 'Committed revision 2.\n']
> + raise SVNUnexpectedStdout("Missing stdout")
> +
> def run_init(dst_url, src_url):
> "Initialize the mirror repository from the master"
> output, errput = svntest.main.run_svnsync(
> @@ -112,6 +132,7 @@
> run_init(dest_sbox.repo_url, repo_url)
>
> run_sync(dest_sbox.repo_url)
> + run_copy_revprops(dest_sbox.repo_url)
>
> # Remove some SVNSync-specific housekeeping properties from the
> # mirror repository in preparation for the comparison dump.
>
Received on 2008-02-27 10:42:43 CET