The following patch adds an 'info' subcommand to svnsync that prints out the
syncronisation information of a repo. This is more convient than using an
svn proplist command.
Regards
Chris
-----------------------
[LOG]
Add an info subcommand to svnsync to print the syncronization information and
also add two tests for it.
* subversion/svnsync/main.c
 (svnsync_cmd_table): Add the info subcommand.
 (info_cmd): New. Add the info subcommand handler.
* subversion/tests/cmdline/svnsync_tests.py
 (run_info): New. Run the svnsync info subcommand.
 (info_syncronized): New. Test the info subcommand on a syncronized repo.
 (info_not_syncronized): New. Test the info subcommand on an un-syncronized
   repo.
 (test_list): Add the info_syncronized and info_not_syncronized tests.
-----------------------
Index: subversion/svnsync/main.c
===================================================================
--- subversion/svnsync/main.c (revision 35003)
+++ subversion/svnsync/main.c (working copy)
@@ -35,6 +35,7 @@
 static svn_opt_subcommand_t initialize_cmd,
                            synchronize_cmd,
                            copy_revprops_cmd,
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info_cmd,
                            help_cmd;
 enum {
@@ -105,6 +106,11 @@
         "to the destination. You may use \"HEAD\" for either revision to\n"
         "mean \"the last revision transferred\".\n"),
      { SVNSYNC_OPTS_DEFAULT } },
+Â Â Â { "info", info_cmd, { 0 },
+Â Â Â Â Â N_("usage: svnsync info URL\n"
+Â Â Â Â Â Â Â Â "\n"
+Â Â Â Â Â Â Â Â "Print syncronization information about the repository at URL.\n"),
+Â Â Â Â Â { SVNSYNC_OPTS_DEFAULT } },
    { "help", help_cmd, { "?", "h" },
      N_("usage: svnsync help [SUBCOMMAND...]\n"
         "\n"
@@ -1796,6 +1802,71 @@
Â
+/*** `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;
+Â svn_string_t *from_uuid;
+Â svn_string_t *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);
+
+Â 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);
+
+Â 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));
+
+Â /* First, check that the repos has been initialized for syncronization. */
+
+Â 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,
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â _("the repository at '%s' is not syncronized."),
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â to_url);
+
+Â 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));
+
+Â SVN_ERR(svn_cmdline_printf(pool, _("From URL: %s\n"), from_url->data));
+
+Â if (from_uuid)
+Â Â Â SVN_ERR(svn_cmdline_printf(pool, _("From 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));
+
+Â return SVN_NO_ERROR;
+}
+
+
+
 /*** `svnsync help' ***/
Index: subversion/tests/cmdline/svnsync_tests.py
===================================================================
--- subversion/tests/cmdline/svnsync_tests.py (revision 35003)
+++ subversion/tests/cmdline/svnsync_tests.py (working copy)
@@ -99,7 +99,29 @@
  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
 or another dump file."""
@@ -680,6 +702,47 @@
  "test move parent and modify child file in same rev"
  run_test(sbox, "svnsync-move-and-modify.dump")
+def info_syncronized(sbox):
+Â "test info cmd on a syncronized repo"
+
+Â 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 = ['From URL: %s\n' % sbox.repo_url,
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'From 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):
+Â "test info cmd on an un-syncronized repo"
+
+Â sbox.build("svnsync-info-not-syncd", False)
+
+Â run_info(sbox.repo_url,
+Â Â Â Â Â Â Â Â Â Â ".*the repository at '%s' is not syncronized.*" % sbox.repo_url)
+
 ########################################################################
 # Run the tests
@@ -713,6 +776,8 @@
              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=462&dsMessageId=999467
Received on 2009-01-02 10:17:39 CET