[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r35053 - in trunk/subversion: svnsync tests/cmdline

From: David Glasser <glasser_at_davidglasser.net>
Date: Tue, 6 Jan 2009 11:58:41 -0800

On Tue, Jan 6, 2009 at 11:34 AM, C. Michael Pilato <cmpilato_at_collab.net> wrote:
> Author: cmpilato
> Date: Tue Jan 6 11:34:33 2009
> New Revision: 35053
>
> Log:
> Add an 'info' subcommand to svnsync to print the synchronization
> information, and also add two tests for it.
>
> * subversion/svnsync/main.c
> (SVNSYNC_OPTS_DEFAULT): Remove 'q' from the default options.
> (svnsync_cmd_table): Add the 'info' subcommand, and add 'q' to the
> list of accepted options for the 'init', 'sync', and 'copy-revprops'
> subcommands.
> (info_cmd): New 'info' subcommand handler.
>
> * subversion/tests/cmdline/svnsync_tests.py
> (run_info): New helper function.
> (info_syncronized, info_not_syncronized): New tests.
> (test_list): Add references to new tests.
>
> Patch by: Chris Foote <cafoote {at} yahoo.com>
> (Tweaked by me.)
>
> 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=35053&r1=35052&r2=35053
> ==============================================================================
> --- trunk/subversion/svnsync/main.c Tue Jan 6 10:58:34 2009 (r35052)
> +++ trunk/subversion/svnsync/main.c Tue Jan 6 11:34:33 2009 (r35053)
> @@ -35,6 +35,7 @@
> static svn_opt_subcommand_t initialize_cmd,
> synchronize_cmd,
> copy_revprops_cmd,
> + info_cmd,
> help_cmd;
>
> enum {
> @@ -60,8 +61,7 @@ enum {
> svnsync_opt_source_password, \
> svnsync_opt_sync_username, \
> svnsync_opt_sync_password, \
> - svnsync_opt_config_dir, \
> - 'q'
> + svnsync_opt_config_dir
>
> static const svn_opt_subcommand_desc2_t svnsync_cmd_table[] =
> {
> @@ -82,13 +82,13 @@ static const svn_opt_subcommand_desc2_t
> "the destination repository by any method other than 'svnsync'.\n"
> "In other words, the destination repository should be a read-only\n"
> "mirror of the source repository.\n"),
> - { SVNSYNC_OPTS_DEFAULT } },
> + { SVNSYNC_OPTS_DEFAULT, 'q' } },
> { "synchronize", synchronize_cmd, { "sync" },
> N_("usage: svnsync synchronize DEST_URL\n"
> "\n"
> "Transfer all pending revisions to the destination from the source\n"
> "with which it was initialized.\n"),
> - { SVNSYNC_OPTS_DEFAULT } },
> + { SVNSYNC_OPTS_DEFAULT, 'q' } },
> { "copy-revprops", copy_revprops_cmd, { 0 },
> N_("usage: svnsync copy-revprops DEST_URL [REV[:REV2]]\n"
> "\n"
> @@ -104,6 +104,12 @@ static const svn_opt_subcommand_desc2_t
> "REV and REV2 must be revisions which were previously transferred\n"
> "to the destination. You may use \"HEAD\" for either revision to\n"
> "mean \"the last revision transferred\".\n"),
> + { SVNSYNC_OPTS_DEFAULT, 'q' } },
> + { "info", info_cmd, { 0 },
> + N_("usage: svnsync info DEST_URL\n"
> + "\n"
> + "Print information about the synchronization destination repository\n"
> + "located at DEST_URL.\n"),
> { SVNSYNC_OPTS_DEFAULT } },
> { "help", help_cmd, { "?", "h" },
> N_("usage: svnsync help [SUBCOMMAND...]\n"
> @@ -1796,6 +1802,68 @@ copy_revprops_cmd(apr_getopt_t *os, void
>
>
>
> +/*** `svnsync info' ***/
> +
> +
> +/* SUBCOMMAND: info */
> +static svn_error_t *
> +info_cmd(apr_getopt_t *os, void *b, apr_pool_t * pool)
> +{
> + svn_ra_session_t *to_session;
> + opt_baton_t *opt_baton = b;
> + apr_array_header_t *targets;
> + subcommand_baton_t *baton;
> + const char *to_url;
> + svn_string_t *from_url, *from_uuid, *last_merged_rev;
> +
> + SVN_ERR(svn_opt__args_to_target_array(&targets, os,
> + apr_array_make(pool, 0,
> + sizeof(const char *)),
> + pool));
> + if (targets->nelts < 1)
> + return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
> + if (targets->nelts > 1)
> + return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, 0, NULL);
> +
> + /* Get the mirror repository URL, and verify that it is URL-ish. */
> + to_url = APR_ARRAY_IDX(targets, 0, const char *);
> + if (! svn_path_is_url(to_url))
> + return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
> + _("Path '%s' is not a URL"), to_url);
> +
> + /* Open an RA session to the mirror repository URL. */
> + baton = make_subcommand_baton(opt_baton, to_url, NULL, 0, 0, pool);
> + SVN_ERR(svn_ra_open3(&to_session, baton->to_url, NULL,
> + &(baton->sync_callbacks), baton, baton->config, pool));
> + SVN_ERR(check_if_session_is_at_repos_root(to_session, baton->to_url, pool));
> +
> + /* Verify that the repos has been initialized for synchronization. */
> + SVN_ERR(svn_ra_rev_prop(to_session, 0, SVNSYNC_PROP_FROM_URL,
> + &from_url, pool));
> + if (! from_url)
> + return svn_error_createf
> + (SVN_ERR_BAD_URL, NULL,
> + _("Repository '%s' is not initialized for synchronization"), to_url);
> +
> + /* Fetch more of the magic properties, which are the source of our info. */
> + SVN_ERR(svn_ra_rev_prop(to_session, 0, SVNSYNC_PROP_FROM_UUID,
> + &from_uuid, pool));
> + SVN_ERR(svn_ra_rev_prop(to_session, 0, SVNSYNC_PROP_LAST_MERGED_REV,
> + &last_merged_rev, pool));
> +
> + /* Print the info. */
> + SVN_ERR(svn_cmdline_printf(pool, _("Source URL: %s\n"), from_url->data));
> + if (from_uuid)
> + SVN_ERR(svn_cmdline_printf(pool, _("Source Repository UUID: %s\n"),
> + from_uuid->data));
> + if (last_merged_rev)
> + SVN_ERR(svn_cmdline_printf(pool, _("Last Merged Revision: %s\n"),
> + last_merged_rev->data));

Perhaps also print out if there is a sync in progress, from where (ie, lock)?

> + return SVN_NO_ERROR;
> +}
> +
> +
> +
> /*** `svnsync help' ***/
>
>
>
> Modified: trunk/subversion/tests/cmdline/svnsync_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svnsync_tests.py?pathrev=35053&r1=35052&r2=35053
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svnsync_tests.py Tue Jan 6 10:58:34 2009 (r35052)
> +++ trunk/subversion/tests/cmdline/svnsync_tests.py Tue Jan 6 11:34:33 2009 (r35053)
> @@ -99,6 +99,28 @@ def run_init(dst_url, src_url):
> if output != ['Copied properties for revision 0.\n']:
> raise SVNUnexpectedStdout(output)
>
> +def run_info(url, expected_error=None):
> + "Print synchronization information of the repository"
> + exit_code, output, errput = svntest.main.run_svnsync(
> + "info", 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: ['From URL: http://....\n',
> + # 'From UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n',
> + # 'Last Merged Revision: XXX\n']
> + raise SVNUnexpectedStdout("Missing stdout")
> +
>
> def run_test(sbox, dump_file_name, subdir = None, exp_dump_file_name = None):
> """Load a dump file, sync repositories, and compare contents with the original
> @@ -680,6 +702,47 @@ def move_and_modify_in_the_same_revision
> "test move parent and modify child file in same rev"
> run_test(sbox, "svnsync-move-and-modify.dump")
>
> +def info_syncronized(sbox):

synchronized

> + "test info cmd on a syncronized repo"

ditto

> +
> + sbox.build("svnsync-info-syncd", False)
> +
> + # Get the UUID of the source repository.
> + exit_code, output, errput = svntest.main.run_svnlook("uuid", sbox.repo_dir)
> + src_uuid = output[0].strip()
> +
> + dest_sbox = sbox.clone_dependent()
> + build_repos(dest_sbox)
> +
> + svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)
> + run_init(dest_sbox.repo_url, sbox.repo_url)
> + run_sync(dest_sbox.repo_url)
> +
> + exit_code, output, errput = svntest.main.run_svnsync(
> + "info", dest_sbox.repo_url,
> + "--username", svntest.main.wc_author,
> + "--password", svntest.main.wc_passwd)
> + if errput:
> + raise SVNUnexpectedStderr(errput)
> +
> + expected_out = ['Source URL: %s\n' % sbox.repo_url,
> + 'Source Repository UUID: %s\n' % src_uuid,
> + 'Last Merged Revision: 1\n',
> + ]
> +
> + svntest.verify.compare_and_display_lines(None,
> + 'INFO',
> + expected_out,
> + output)
> +
> +def info_not_syncronized(sbox):

ditto

> + "test info cmd on an un-syncronized repo"

ditto

> +
> + sbox.build("svnsync-info-not-syncd", False)
> +
> + run_info(sbox.repo_url,
> + ".*Repository '%s' is not initialized.*" % sbox.repo_url)
> +
> ########################################################################
> # Run the tests
>
> @@ -713,6 +776,8 @@ test_list = [ None,
> SkipUnless(only_trunk_A_with_changes,
> server_has_partial_replay),
> move_and_modify_in_the_same_revision,
> + info_syncronized,
> + info_not_syncronized,
> ]
>
> if __name__ == '__main__':
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1008299
>

-- 
glasser_at_davidglasser.net | langtonlabs.org | flickr.com/photos/glasser/
Received on 2009-01-06 21:16:54 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.