You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/12/29 22:12:38 UTC
svn commit: r1053735 [6/8] - in /subversion/branches/performance: ./ build/
build/ac-macros/ build/generator/ build/generator/swig/
contrib/client-side/svn_load_dirs/ notes/
subversion/bindings/javahl/native/ subversion/bindings/swig/
subversion/includ...
Modified: subversion/branches/performance/subversion/svn/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svn/main.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svn/main.c (original)
+++ subversion/branches/performance/subversion/svn/main.c Wed Dec 29 21:12:33 2010
@@ -1329,7 +1329,8 @@ main(int argc, const char *argv[])
const char *utf8_opt_arg;
/* Parse the next option. */
- apr_status_t apr_err = apr_getopt_long(os, svn_cl__options, &opt_id, &opt_arg);
+ apr_status_t apr_err = apr_getopt_long(os, svn_cl__options, &opt_id,
+ &opt_arg);
if (APR_STATUS_IS_EOF(apr_err))
break;
else if (apr_err)
@@ -1406,7 +1407,8 @@ main(int argc, const char *argv[])
{
if (changeno < 0 || is_negative)
{
- err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
+ NULL,
_("Negative number in range (%s)"
" not supported with -c"),
change_str);
@@ -1577,8 +1579,8 @@ main(int argc, const char *argv[])
return svn_cmdline_handle_exit_error
(svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("'%s' is not a valid depth; try "
- "'exclude', 'empty', 'files', 'immediates', "
- "or 'infinity'"),
+ "'exclude', 'empty', 'files', "
+ "'immediates', or 'infinity'"),
utf8_opt_arg), pool, "svn: ");
}
break;
@@ -1681,7 +1683,8 @@ main(int argc, const char *argv[])
case opt_config_options:
if (!opt_state.config_options)
opt_state.config_options =
- apr_array_make(pool, 1, sizeof(svn_cmdline__config_argument_t*));
+ apr_array_make(pool, 1,
+ sizeof(svn_cmdline__config_argument_t*));
err = svn_utf_cstring_to_utf8(&opt_arg, opt_arg, pool);
if (!err)
@@ -2170,7 +2173,8 @@ main(int argc, const char *argv[])
if (opt_state.config_options)
{
svn_error_clear(
- svn_cmdline__apply_config_options(ctx->config, opt_state.config_options,
+ svn_cmdline__apply_config_options(ctx->config,
+ opt_state.config_options,
"svn: ", "--config-option"));
}
@@ -2379,6 +2383,11 @@ main(int argc, const char *argv[])
err = svn_error_quick_wrap(err,
_("Try 'svn help' for more info"));
}
+ if (err->apr_err == SVN_ERR_WC_UPGRADE_REQUIRED)
+ {
+ err = svn_error_quick_wrap(err,
+ _("Please see the 'svn upgrade' command"));
+ }
svn_handle_error2(err, stderr, FALSE, "svn: ");
/* Tell the user about 'svn cleanup' if any error on the stack
Modified: subversion/branches/performance/subversion/svn/mergeinfo-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svn/mergeinfo-cmd.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svn/mergeinfo-cmd.c (original)
+++ subversion/branches/performance/subversion/svn/mergeinfo-cmd.c Wed Dec 29 21:12:33 2010
@@ -48,9 +48,9 @@ print_log_rev(void *baton,
apr_pool_t *pool)
{
if (log_entry->non_inheritable)
- svn_cmdline_printf(pool, "r%ld*\n", log_entry->revision);
+ SVN_ERR(svn_cmdline_printf(pool, "r%ld*\n", log_entry->revision));
else
- svn_cmdline_printf(pool, "r%ld\n", log_entry->revision);
+ SVN_ERR(svn_cmdline_printf(pool, "r%ld\n", log_entry->revision));
return SVN_NO_ERROR;
}
Modified: subversion/branches/performance/subversion/svn/mkdir-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svn/mkdir-cmd.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svn/mkdir-cmd.c (original)
+++ subversion/branches/performance/subversion/svn/mkdir-cmd.c Wed Dec 29 21:12:33 2010
@@ -48,8 +48,6 @@ svn_cl__mkdir(apr_getopt_t *os,
svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
apr_array_header_t *targets;
svn_error_t *err;
- svn_boolean_t wc_present = FALSE, url_present = FALSE;
- int i;
SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
opt_state->targets,
@@ -58,21 +56,7 @@ svn_cl__mkdir(apr_getopt_t *os,
if (! targets->nelts)
return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
- /* Check to see if at least one of our paths is a working copy
- path or a repository url. */
- for (i = 0; i < targets->nelts; ++i)
- {
- const char *target = APR_ARRAY_IDX(targets, i, const char *);
- if (! svn_path_is_url(target))
- wc_present = TRUE;
- else
- url_present = TRUE;
- }
-
- if (url_present && wc_present)
- return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
- _("Cannot mix repository and working copy "
- "targets"));
+ SVN_ERR(svn_cl__assert_homogeneous_target_type(targets));
if (! svn_path_is_url(APR_ARRAY_IDX(targets, 0, const char *)))
{
Modified: subversion/branches/performance/subversion/svn/propget-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svn/propget-cmd.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svn/propget-cmd.c (original)
+++ subversion/branches/performance/subversion/svn/propget-cmd.c Wed Dec 29 21:12:33 2010
@@ -155,7 +155,7 @@ print_properties(svn_stream_t *out,
apr_hash_t *hash = apr_hash_make(iterpool);
apr_hash_set(hash, pname_utf8, APR_HASH_KEY_STRING, propval);
- svn_cl__print_prop_hash(out, hash, FALSE, iterpool);
+ SVN_ERR(svn_cl__print_prop_hash(out, hash, FALSE, iterpool));
}
else
{
Modified: subversion/branches/performance/subversion/svn/status.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svn/status.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svn/status.c (original)
+++ subversion/branches/performance/subversion/svn/status.c Wed Dec 29 21:12:33 2010
@@ -167,8 +167,10 @@ print_status(const char *path,
old_tree_conflict = svn_wc__cd2_to_cd(tree_conflict, pool);
tree_status_code = 'C';
- svn_cl__get_human_readable_tree_conflict_description(
- &desc, old_tree_conflict, pool);
+ SVN_ERR(svn_cl__get_human_readable_tree_conflict_description(
+ &desc,
+ old_tree_conflict,
+ pool));
tree_desc_line = apr_psprintf(pool, "\n > %s", desc);
(*tree_conflicts)++;
}
Modified: subversion/branches/performance/subversion/svn/unlock-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svn/unlock-cmd.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svn/unlock-cmd.c (original)
+++ subversion/branches/performance/subversion/svn/unlock-cmd.c Wed Dec 29 21:12:33 2010
@@ -49,8 +49,6 @@ svn_cl__unlock(apr_getopt_t *os,
svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
apr_array_header_t *targets;
- svn_boolean_t wc_present = FALSE, url_present = FALSE;
- int i;
SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
opt_state->targets,
@@ -62,22 +60,7 @@ svn_cl__unlock(apr_getopt_t *os,
SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
- /* Check to see if at least one of our paths is a working copy
- * path or a repository url. */
- for (i = 0; i < targets->nelts; ++i)
- {
- const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
- if (! svn_path_is_url(target))
- wc_present = TRUE;
- else
- url_present = TRUE;
- }
-
- if (url_present && wc_present)
- return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
- _("Cannot mix repository and working copy "
- "targets"));
+ SVN_ERR(svn_cl__assert_homogeneous_target_type(targets));
return svn_error_return(
svn_client_unlock(targets, opt_state->force, ctx, scratch_pool));
Modified: subversion/branches/performance/subversion/svn/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svn/util.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svn/util.c (original)
+++ subversion/branches/performance/subversion/svn/util.c Wed Dec 29 21:12:33 2010
@@ -61,6 +61,7 @@
#include "private/svn_token.h"
#include "private/svn_opt_private.h"
+#include "private/svn_client_private.h"
@@ -483,8 +484,9 @@ svn_cl__edit_string_externally(svn_strin
/* Translate back to UTF8/LF if desired. */
if (as_text)
{
- err = svn_subst_translate_string(edited_contents, *edited_contents,
- encoding, pool);
+ err = svn_subst_translate_string2(edited_contents, FALSE, FALSE,
+ *edited_contents, encoding, pool,
+ pool);
if (err)
{
err = svn_error_quick_wrap
@@ -709,8 +711,9 @@ svn_cl__get_log_message(const char **log
/* Make a string from a stringbuf, sharing the data allocation. */
log_msg_str->data = log_msg_buf->data;
log_msg_str->len = log_msg_buf->len;
- SVN_ERR_W(svn_subst_translate_string(&log_msg_str, log_msg_str,
- lmb->message_encoding, pool),
+ SVN_ERR_W(svn_subst_translate_string2(&log_msg_str, FALSE, FALSE,
+ log_msg_str, lmb->message_encoding,
+ pool, pool),
_("Error normalizing log message to internal format"));
*log_msg = log_msg_str->data;
@@ -1345,3 +1348,16 @@ svn_cl__opt_parse_path(svn_opt_revision_
return SVN_NO_ERROR;
}
+
+svn_error_t *
+svn_cl__assert_homogeneous_target_type(const apr_array_header_t *targets)
+{
+ svn_error_t *err;
+
+ err = svn_client__assert_homogeneous_target_type(targets);
+ if (err && err->apr_err == SVN_ERR_ILLEGAL_TARGET)
+ return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
+ _("Cannot mix repository and working copy "
+ "targets"));
+ return err;
+}
Modified: subversion/branches/performance/subversion/svnadmin/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnadmin/main.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnadmin/main.c (original)
+++ subversion/branches/performance/subversion/svnadmin/main.c Wed Dec 29 21:12:33 2010
@@ -223,6 +223,7 @@ enum
svnadmin__bdb_log_keep,
svnadmin__config_dir,
svnadmin__bypass_hooks,
+ svnadmin__bypass_prop_validation,
svnadmin__use_pre_commit_hook,
svnadmin__use_post_commit_hook,
svnadmin__use_pre_revprop_change_hook,
@@ -262,6 +263,9 @@ static const apr_getopt_option_t options
{"bypass-hooks", svnadmin__bypass_hooks, 0,
N_("bypass the repository hook system")},
+ {"bypass-prop-validation", svnadmin__bypass_prop_validation, 0,
+ N_("bypass property validation logic")},
+
{"quiet", 'q', 0,
N_("no progress (only errors) to stderr")},
@@ -407,7 +411,7 @@ static const svn_opt_subcommand_desc2_t
"one specified in the stream. Progress feedback is sent to stdout.\n"),
{'q', svnadmin__ignore_uuid, svnadmin__force_uuid,
svnadmin__use_pre_commit_hook, svnadmin__use_post_commit_hook,
- svnadmin__parent_dir, 'M', 'F'} },
+ svnadmin__parent_dir, svnadmin__bypass_prop_validation, 'M', 'F'} },
{"lslocks", subcommand_lslocks, {0}, N_
("usage: svnadmin lslocks REPOS_PATH [PATH-IN-REPOS]\n\n"
@@ -521,6 +525,7 @@ struct svnadmin_opt_state
svn_boolean_t clean_logs; /* --clean-logs */
svn_boolean_t bypass_hooks; /* --bypass-hooks */
svn_boolean_t wait; /* --wait */
+ svn_boolean_t bypass_prop_validation; /* --bypass-prop-validation */
enum svn_repos_load_uuid uuid_action; /* --ignore-uuid,
--force-uuid */
apr_uint64_t memory_cache_size; /* --memory-cache-size M */
@@ -946,6 +951,7 @@ subcommand_help(apr_getopt_t *os, void *
static svn_error_t *
subcommand_load(apr_getopt_t *os, void *baton, apr_pool_t *pool)
{
+ svn_error_t *err;
struct svnadmin_opt_state *opt_state = baton;
svn_repos_t *repos;
svn_stream_t *stdin_stream, *stdout_stream = NULL;
@@ -960,14 +966,20 @@ subcommand_load(apr_getopt_t *os, void *
if (! opt_state->quiet)
stdout_stream = recode_stream_create(stdout, pool);
- SVN_ERR(svn_repos_load_fs3(repos, stdin_stream,
- opt_state->uuid_action, opt_state->parent_dir,
- opt_state->use_pre_commit_hook,
- opt_state->use_post_commit_hook,
- !opt_state->quiet ? repos_notify_handler : NULL,
- stdout_stream, check_cancel, NULL, pool));
-
- return SVN_NO_ERROR;
+ err = svn_repos_load_fs3(repos, stdin_stream,
+ opt_state->uuid_action, opt_state->parent_dir,
+ opt_state->use_pre_commit_hook,
+ opt_state->use_post_commit_hook,
+ opt_state->bypass_prop_validation ? FALSE : TRUE,
+ opt_state->quiet ? NULL : repos_notify_handler,
+ stdout_stream, check_cancel, NULL, pool);
+ if (err && err->apr_err == SVN_ERR_BAD_PROPERTY_VALUE)
+ return svn_error_quick_wrap(err,
+ _("Invalid property value found in "
+ "dumpstream; consider repairing the source "
+ "or using --bypass-prop-validation while "
+ "loading."));
+ return err;
}
@@ -1190,23 +1202,12 @@ set_revprop(const char *prop_name, const
/* If we are bypassing the hooks system, we just hit the filesystem
directly. */
- if (opt_state->use_pre_revprop_change_hook ||
- opt_state->use_post_revprop_change_hook)
- {
- SVN_ERR(svn_repos_fs_change_rev_prop3(repos,
- opt_state->start_revision.value.number,
- NULL, prop_name, prop_value,
- opt_state->use_pre_revprop_change_hook,
- opt_state->use_post_revprop_change_hook, NULL,
- NULL, pool));
- }
- else
- {
- svn_fs_t *fs = svn_repos_fs(repos);
- SVN_ERR(svn_fs_change_rev_prop2(fs,
- opt_state->start_revision.value.number,
- prop_name, NULL, prop_value, pool));
- }
+ SVN_ERR(svn_repos_fs_change_rev_prop4(
+ repos, opt_state->start_revision.value.number,
+ NULL, prop_name, NULL, prop_value,
+ opt_state->use_pre_revprop_change_hook,
+ opt_state->use_post_revprop_change_hook,
+ NULL, NULL, pool));
return SVN_NO_ERROR;
}
@@ -1387,7 +1388,8 @@ subcommand_lslocks(apr_getopt_t *os, voi
SVN_ERR(open_repos(&repos, opt_state->repository_path, pool));
/* Fetch all locks on or below the root directory. */
- SVN_ERR(svn_repos_fs_get_locks(&locks, repos, fs_path, NULL, NULL, pool));
+ SVN_ERR(svn_repos_fs_get_locks2(&locks, repos, fs_path, svn_depth_infinity,
+ NULL, NULL, pool));
for (hi = apr_hash_first(pool, locks); hi; hi = apr_hash_next(hi))
{
@@ -1607,7 +1609,7 @@ main(int argc, const char *argv[])
if (argc <= 1)
{
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1636,7 +1638,7 @@ main(int argc, const char *argv[])
break;
else if (apr_err)
{
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1745,6 +1747,9 @@ main(int argc, const char *argv[])
case svnadmin__bypass_hooks:
opt_state.bypass_hooks = TRUE;
break;
+ case svnadmin__bypass_prop_validation:
+ opt_state.bypass_prop_validation = TRUE;
+ break;
case svnadmin__clean_logs:
opt_state.clean_logs = TRUE;
break;
@@ -1757,7 +1762,7 @@ main(int argc, const char *argv[])
break;
default:
{
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1791,7 +1796,7 @@ main(int argc, const char *argv[])
{
svn_error_clear(svn_cmdline_fprintf(stderr, pool,
_("subcommand argument required\n")));
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1809,7 +1814,7 @@ main(int argc, const char *argv[])
svn_error_clear(svn_cmdline_fprintf(stderr, pool,
_("Unknown command: '%s'\n"),
first_arg_utf8));
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1860,7 +1865,7 @@ main(int argc, const char *argv[])
pool);
svn_opt_format_option(&optstr, badopt, FALSE, pool);
if (subcommand->name[0] == '-')
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
else
svn_error_clear(svn_cmdline_fprintf(stderr, pool
, _("Subcommand '%s' doesn't accept option '%s'\n"
Modified: subversion/branches/performance/subversion/svndumpfilter/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svndumpfilter/main.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svndumpfilter/main.c (original)
+++ subversion/branches/performance/subversion/svndumpfilter/main.c Wed Dec 29 21:12:33 2010
@@ -1294,7 +1294,7 @@ main(int argc, const char *argv[])
if (argc <= 1)
{
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1320,7 +1320,7 @@ main(int argc, const char *argv[])
break;
else if (apr_err)
{
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1359,7 +1359,7 @@ main(int argc, const char *argv[])
break;
default:
{
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1394,7 +1394,7 @@ main(int argc, const char *argv[])
svn_error_clear(svn_cmdline_fprintf
(stderr, pool,
_("Subcommand argument required\n")));
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1414,7 +1414,7 @@ main(int argc, const char *argv[])
svn_error_clear(svn_cmdline_fprintf(stderr, pool,
_("Unknown command: '%s'\n"),
first_arg_utf8));
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1496,7 +1496,7 @@ main(int argc, const char *argv[])
pool);
svn_opt_format_option(&optstr, badopt, FALSE, pool);
if (subcommand->name[0] == '-')
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
else
svn_error_clear(svn_cmdline_fprintf
(stderr, pool,
Modified: subversion/branches/performance/subversion/svnlook/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnlook/main.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnlook/main.c (original)
+++ subversion/branches/performance/subversion/svnlook/main.c Wed Dec 29 21:12:33 2010
@@ -1841,6 +1841,24 @@ warning_func(void *baton,
}
+/* Return an error if the number of arguments (excluding the repository
+ * argument) is not NUM_ARGS. NUM_ARGS must be 0 or 1. The arguments
+ * are assumed to be found in OPT_STATE->arg1 and OPT_STATE->arg2. */
+static svn_error_t *
+check_number_of_args(struct svnlook_opt_state *opt_state,
+ int num_args)
+{
+ if ((num_args == 0 && opt_state->arg1 != NULL)
+ || (num_args == 1 && opt_state->arg2 != NULL))
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Too many arguments given"));
+ if ((num_args == 1 && opt_state->arg1 == NULL))
+ return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,
+ _("Missing repository path argument"));
+ return SVN_NO_ERROR;
+}
+
+
/* Factory function for the context baton. */
static svn_error_t *
get_ctxt_baton(svnlook_ctxt_t **baton_p,
@@ -1887,6 +1905,8 @@ subcommand_author(apr_getopt_t *os, void
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_author(c, pool));
return SVN_NO_ERROR;
@@ -1899,10 +1919,7 @@ subcommand_cat(apr_getopt_t *os, void *b
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
- if (opt_state->arg1 == NULL)
- return svn_error_createf
- (SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,
- _("Missing repository path argument"));
+ SVN_ERR(check_number_of_args(opt_state, 1));
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_cat(c, opt_state->arg1, pool));
@@ -1916,6 +1933,8 @@ subcommand_changed(apr_getopt_t *os, voi
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_changed(c, pool));
return SVN_NO_ERROR;
@@ -1928,6 +1947,8 @@ subcommand_date(apr_getopt_t *os, void *
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_date(c, pool));
return SVN_NO_ERROR;
@@ -1940,6 +1961,8 @@ subcommand_diff(apr_getopt_t *os, void *
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_diff(c, pool));
return SVN_NO_ERROR;
@@ -1952,6 +1975,8 @@ subcommand_dirschanged(apr_getopt_t *os,
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_dirs_changed(c, pool));
return SVN_NO_ERROR;
@@ -1964,10 +1989,7 @@ subcommand_filesize(apr_getopt_t *os, vo
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
- if (opt_state->arg1 == NULL)
- return svn_error_createf
- (SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,
- _("Missing repository path argument"));
+ SVN_ERR(check_number_of_args(opt_state, 1));
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_filesize(c, opt_state->arg1, pool));
@@ -2012,10 +2034,11 @@ subcommand_history(apr_getopt_t *os, voi
{
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
- const char *path = "/";
+ const char *path = (opt_state->arg1 ? opt_state->arg1 : "/");
- if (opt_state->arg1)
- path = opt_state->arg1;
+ if (opt_state->arg2 != NULL)
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Too many arguments given"));
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_history(c, path, pool));
@@ -2029,18 +2052,13 @@ subcommand_lock(apr_getopt_t *os, void *
{
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
- const char *path;
svn_lock_t *lock;
- if (opt_state->arg1)
- path = opt_state->arg1;
- else
- return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,
- _("Missing path argument"));
+ SVN_ERR(check_number_of_args(opt_state, 1));
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
- SVN_ERR(svn_fs_get_lock(&lock, c->fs, path, pool));
+ SVN_ERR(svn_fs_get_lock(&lock, c->fs, opt_state->arg1, pool));
if (lock)
{
@@ -2078,6 +2096,8 @@ subcommand_info(apr_getopt_t *os, void *
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_author(c, pool));
SVN_ERR(do_date(c, pool));
@@ -2092,6 +2112,8 @@ subcommand_log(apr_getopt_t *os, void *b
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_log(c, FALSE, pool));
return SVN_NO_ERROR;
@@ -2117,6 +2139,10 @@ subcommand_pget(apr_getopt_t *os, void *
(SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,
_("Missing propname or repository path argument"));
}
+ if ((opt_state->revprop && opt_state->arg2 != NULL)
+ || os->ind < os->argc)
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Too many arguments given"));
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_pget(c, opt_state->arg1,
@@ -2131,10 +2157,7 @@ subcommand_plist(apr_getopt_t *os, void
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
- if (!opt_state->revprop && opt_state->arg1 == NULL)
- return svn_error_create
- (SVN_ERR_CL_INSUFFICIENT_ARGS, NULL,
- _("Missing repository path argument"));
+ SVN_ERR(check_number_of_args(opt_state, opt_state->revprop ? 0 : 1));
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_plist(c, opt_state->revprop ? NULL : opt_state->arg1,
@@ -2149,6 +2172,10 @@ subcommand_tree(apr_getopt_t *os, void *
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ if (opt_state->arg2 != NULL)
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Too many arguments given"));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(do_tree(c, opt_state->arg1 ? opt_state->arg1 : "",
opt_state->show_ids, opt_state->full_paths,
@@ -2163,6 +2190,8 @@ subcommand_youngest(apr_getopt_t *os, vo
struct svnlook_opt_state *opt_state = baton;
svnlook_ctxt_t *c;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(svn_cmdline_printf(pool, "%ld\n", c->rev_id));
return SVN_NO_ERROR;
@@ -2176,6 +2205,8 @@ subcommand_uuid(apr_getopt_t *os, void *
svnlook_ctxt_t *c;
const char *uuid;
+ SVN_ERR(check_number_of_args(opt_state, 0));
+
SVN_ERR(get_ctxt_baton(&c, opt_state, pool));
SVN_ERR(svn_fs_get_uuid(c->fs, &uuid, pool));
SVN_ERR(svn_cmdline_printf(pool, "%s\n", uuid));
@@ -2230,7 +2261,7 @@ main(int argc, const char *argv[])
if (argc <= 1)
{
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -2255,7 +2286,7 @@ main(int argc, const char *argv[])
break;
else if (apr_err)
{
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -2355,7 +2386,7 @@ main(int argc, const char *argv[])
break;
default:
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
@@ -2397,7 +2428,7 @@ main(int argc, const char *argv[])
svn_error_clear
(svn_cmdline_fprintf(stderr, pool,
_("Subcommand argument required\n")));
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -2417,7 +2448,7 @@ main(int argc, const char *argv[])
(svn_cmdline_fprintf(stderr, pool,
_("Unknown command: '%s'\n"),
first_arg_utf8));
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -2449,7 +2480,7 @@ main(int argc, const char *argv[])
svn_error_clear
(svn_cmdline_fprintf(stderr, pool,
_("Repository argument required\n")));
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -2504,7 +2535,7 @@ main(int argc, const char *argv[])
pool);
svn_opt_format_option(&optstr, badopt, FALSE, pool);
if (subcommand->name[0] == '-')
- subcommand_help(NULL, NULL, pool);
+ SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
else
svn_error_clear
(svn_cmdline_fprintf
Modified: subversion/branches/performance/subversion/svnrdump/dump_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnrdump/dump_editor.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnrdump/dump_editor.c (original)
+++ subversion/branches/performance/subversion/svnrdump/dump_editor.c Wed Dec 29 21:12:33 2010
@@ -207,8 +207,8 @@ dump_props(struct dump_edit_baton *eb,
SVN_ERR(svn_stream_printf(eb->stream, pool, "\n\n"));
/* Cleanup so that data is never dumped twice. */
- svn_hash__clear(eb->props, eb->pool);
- svn_hash__clear(eb->deleted_props, eb->pool);
+ SVN_ERR(svn_hash__clear(eb->props, eb->pool));
+ SVN_ERR(svn_hash__clear(eb->deleted_props, eb->pool));
if (trigger_var)
*trigger_var = FALSE;
}
@@ -525,7 +525,7 @@ close_directory(void *dir_baton,
FALSE, NULL, SVN_INVALID_REVNUM, pool));
}
- svn_hash__clear(db->deleted_entries, pool);
+ SVN_ERR(svn_hash__clear(db->deleted_entries, pool));
return SVN_NO_ERROR;
}
@@ -725,7 +725,7 @@ apply_textdelta(void *file_baton, const
eb->dump_text = TRUE;
eb->base_checksum = apr_pstrdup(eb->pool, base_checksum);
- svn_stream_close(delta_filestream);
+ SVN_ERR(svn_stream_close(delta_filestream));
/* The actual writing takes place when this function has
finished. Set handler and handler_baton now so for
@@ -806,8 +806,8 @@ close_file(void *file_baton,
/* Cleanup */
eb->dump_props = FALSE;
- svn_hash__clear(eb->props, eb->pool);
- svn_hash__clear(eb->deleted_props, eb->pool);
+ SVN_ERR(svn_hash__clear(eb->props, eb->pool));
+ SVN_ERR(svn_hash__clear(eb->deleted_props, eb->pool));
}
/* Dump the text */
Modified: subversion/branches/performance/subversion/svnrdump/load_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnrdump/load_editor.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnrdump/load_editor.c (original)
+++ subversion/branches/performance/subversion/svnrdump/load_editor.c Wed Dec 29 21:12:33 2010
@@ -31,13 +31,12 @@
#include "svn_ra.h"
#include "svn_io.h"
#include "svn_private_config.h"
-
-#include <apr_network_io.h>
+#include "private/svn_repos_private.h"
+#include "private/svn_ra_private.h"
#include "load_editor.h"
#define SVNRDUMP_PROP_LOCK SVN_PROP_PREFIX "rdump-lock"
-#define LOCK_RETRIES 10
#if 0
#define LDR_DBG(x) SVN_DBG(x)
@@ -56,10 +55,16 @@ commit_callback(const svn_commit_info_t
return SVN_NO_ERROR;
}
-/* See subversion/svnsync/main.c for docstring */
-static svn_boolean_t is_atomicity_error(svn_error_t *err)
+/* Implements `svn_ra__lock_retry_func_t'. */
+static svn_error_t *
+lock_retry_func(void *baton,
+ const svn_string_t *reposlocktoken,
+ apr_pool_t *pool)
{
- return svn_error_has_cause(err, SVN_ERR_FS_PROP_BASEVALUE_MISMATCH);
+ return svn_cmdline_printf(pool,
+ _("Failed to get lock on destination "
+ "repos, currently held by '%s'\n"),
+ reposlocktoken->data);
}
/* Acquire a lock (of sorts) on the repository associated with the
@@ -77,13 +82,8 @@ get_lock(const svn_string_t **lock_strin
void *cancel_baton,
apr_pool_t *pool)
{
- char hostname_str[APRMAXHOSTLEN + 1] = { 0 };
- svn_string_t *mylocktoken, *reposlocktoken;
- apr_status_t apr_err;
svn_boolean_t be_atomic;
- apr_pool_t *subpool;
- int i;
-
+
SVN_ERR(svn_ra_has_capability(session, &be_atomic,
SVN_RA_CAPABILITY_ATOMIC_REVPROPS,
pool));
@@ -98,103 +98,10 @@ get_lock(const svn_string_t **lock_strin
svn_error_clear(err);
}
- apr_err = apr_gethostname(hostname_str, sizeof(hostname_str), pool);
- if (apr_err)
- return svn_error_wrap_apr(apr_err, _("Can't get local hostname"));
-
- mylocktoken = svn_string_createf(pool, "%s:%s", hostname_str,
- svn_uuid_generate(pool));
-
- /* If we succeed, this is what the property will be set to. */
- *lock_string_p = mylocktoken;
-
- subpool = svn_pool_create(pool);
-
- for (i = 0; i < LOCK_RETRIES; ++i)
- {
- svn_error_t *err;
-
- svn_pool_clear(subpool);
-
- SVN_ERR(cancel_func(cancel_baton));
- SVN_ERR(svn_ra_rev_prop(session, 0, SVNRDUMP_PROP_LOCK, &reposlocktoken,
- subpool));
-
- if (reposlocktoken)
- {
- /* Did we get it? If so, we're done. */
- if (strcmp(reposlocktoken->data, mylocktoken->data) == 0)
- return SVN_NO_ERROR;
-
- /* ...otherwise, tell the user that someone else has the
- lock and sleep before retrying. */
- SVN_ERR(svn_cmdline_printf
- (pool, _("Failed to get lock on destination "
- "repos, currently held by '%s'\n"),
- reposlocktoken->data));
-
- apr_sleep(apr_time_from_sec(1));
- }
- else if (i < LOCK_RETRIES - 1)
- {
- const svn_string_t *unset = NULL;
-
- /* Except in the very last iteration, try to set the lock. */
- err = svn_ra_change_rev_prop2(session, 0, SVNRDUMP_PROP_LOCK,
- be_atomic ? &unset : NULL,
- mylocktoken, subpool);
-
- if (be_atomic && err && is_atomicity_error(err))
- {
- /* Someone else has the lock. Let's loop. */
- svn_error_clear(err);
- }
- else if (be_atomic && err == SVN_NO_ERROR)
- {
- /* We have the lock. However, for compatibility with
- concurrent svnrdumps that don't support atomicity, loop
- anyway to double-check that they haven't overwritten
- our lock. */
- continue;
- }
- else
- {
- /* Genuine error, or we aren't atomic and need to loop. */
- SVN_ERR(err);
- }
- }
- }
-
- return svn_error_createf(APR_EINVAL, NULL,
- _("Couldn't get lock on destination repos "
- "after %d attempts"), i);
-}
-
-/* Remove the lock on SESSION iff the lock is owned by MYLOCKTOKEN. */
-static svn_error_t *
-maybe_unlock(svn_ra_session_t *session,
- const svn_string_t *mylocktoken,
- apr_pool_t *scratch_pool)
-{
- svn_string_t *reposlocktoken;
- svn_boolean_t be_atomic;
-
- SVN_ERR(svn_ra_has_capability(session, &be_atomic,
- SVN_RA_CAPABILITY_ATOMIC_REVPROPS,
- scratch_pool));
- SVN_ERR(svn_ra_rev_prop(session, 0, SVNRDUMP_PROP_LOCK,
- &reposlocktoken, scratch_pool));
- if (reposlocktoken && strcmp(reposlocktoken->data, mylocktoken->data) == 0)
- {
- svn_error_t *err =
- svn_ra_change_rev_prop2(session, 0, SVNRDUMP_PROP_LOCK,
- be_atomic ? &mylocktoken : NULL, NULL,
- scratch_pool);
- if (is_atomicity_error(err))
- return svn_error_quick_wrap(err, _("svnrdump's lock was stolen; "
- "can't remove it"));
- }
- return SVN_NO_ERROR;
+ return svn_ra__get_operational_lock(lock_string_p, NULL, session,
+ SVNRDUMP_PROP_LOCK, FALSE,
+ 10 /* retries */, lock_retry_func, NULL,
+ cancel_func, cancel_baton, pool);
}
static svn_error_t *
@@ -469,6 +376,8 @@ set_revision_property(void *baton,
struct revision_baton *rb;
rb = baton;
+ SVN_ERR(svn_repos__validate_prop(name, value, rb->pool));
+
if (rb->rev > 0)
apr_hash_set(rb->revprop_table, apr_pstrdup(rb->pool, name),
APR_HASH_KEY_STRING, svn_string_dup(value, rb->pool));
@@ -500,6 +409,8 @@ set_node_property(void *baton,
commit_editor = nb->rb->pb->commit_editor;
pool = nb->rb->pool;
+ SVN_ERR(svn_repos__validate_prop(name, value, pool));
+
switch (nb->kind)
{
case svn_node_file:
@@ -529,6 +440,8 @@ delete_node_property(void *baton,
commit_editor = nb->rb->pb->commit_editor;
pool = nb->rb->pool;
+ SVN_ERR(svn_repos__validate_prop(name, NULL, pool));
+
if (nb->kind == svn_node_file)
SVN_ERR(commit_editor->change_file_prop(nb->file_baton, name,
NULL, pool));
@@ -641,11 +554,15 @@ close_revision(void *baton)
SVN_ERR(commit_editor->close_edit(commit_edit_baton, rb->pool));
}
- /* svn_fs_commit_txn rewrites the datestamp/ author property-
- rewrite it by hand after closing the commit_editor. */
+ /* svn_fs_commit_txn() rewrites the datestamp and author properties;
+ we'll rewrite them again by hand after closing the commit_editor. */
+ SVN_ERR(svn_repos__validate_prop(SVN_PROP_REVISION_DATE,
+ rb->datestamp, rb->pool));
SVN_ERR(svn_ra_change_rev_prop2(rb->pb->session, rb->rev,
SVN_PROP_REVISION_DATE,
NULL, rb->datestamp, rb->pool));
+ SVN_ERR(svn_repos__validate_prop(SVN_PROP_REVISION_AUTHOR,
+ rb->author, rb->pool));
SVN_ERR(svn_ra_change_rev_prop2(rb->pb->session, rb->rev,
SVN_PROP_REVISION_AUTHOR,
NULL, rb->author, rb->pool));
@@ -710,9 +627,10 @@ drive_dumpstream_loader(svn_stream_t *st
/* If all goes well, or if we're cancelled cleanly, don't leave a
stray lock behind. */
- if ((! err)
- || (err && (err->apr_err == SVN_ERR_CANCELLED)))
- err = svn_error_compose_create(maybe_unlock(session, lock_string, pool),
- err);
+ if ((! err) || (err && (err->apr_err == SVN_ERR_CANCELLED)))
+ err = svn_error_compose_create(
+ svn_ra__release_operational_lock(session, SVNRDUMP_PROP_LOCK,
+ lock_string, pool),
+ err);
return err;
}
Modified: subversion/branches/performance/subversion/svnrdump/svnrdump.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnrdump/svnrdump.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnrdump/svnrdump.c (original)
+++ subversion/branches/performance/subversion/svnrdump/svnrdump.c Wed Dec 29 21:12:33 2010
@@ -74,33 +74,40 @@ static svn_opt_subcommand_t dump_cmd, lo
enum svn_svnrdump__longopt_t
{
opt_config_dir = SVN_OPT_FIRST_LONGOPT_ID,
+ opt_config_option,
opt_auth_username,
opt_auth_password,
- opt_non_interactive,
opt_auth_nocache,
+ opt_non_interactive,
+ opt_incremental,
opt_version,
- opt_config_option,
};
+#define SVN_SVNRDUMP__BASE_OPTIONS opt_config_dir, \
+ opt_config_option, \
+ opt_auth_username, \
+ opt_auth_password, \
+ opt_auth_nocache, \
+ opt_non_interactive
+
static const svn_opt_subcommand_desc2_t svnrdump__cmd_table[] =
- {
- { "dump", dump_cmd, { 0 },
- N_("usage: svnrdump dump URL [-r LOWER[:UPPER]]\n\n"
- "Dump revisions LOWER to UPPER of repository at remote URL "
- "to stdout in a 'dumpfile' portable format.\n"
- "If only LOWER is given, dump that one revision.\n"),
- { 0 } },
- { "load", load_cmd, { 0 },
- N_("usage: svnrdump load URL\n\n"
- "Load a 'dumpfile' given on stdin to a repository "
- "at remote URL.\n"),
- { 0 } },
- { "help", 0, { "?", "h" },
- N_("usage: svnrdump help [SUBCOMMAND...]\n\n"
- "Describe the usage of this program or its subcommands.\n"),
- { 0 } },
- { NULL, NULL, { 0 }, NULL, { 0 } }
- };
+{
+ { "dump", dump_cmd, { 0 },
+ N_("usage: svnrdump dump URL [-r LOWER[:UPPER]]\n\n"
+ "Dump revisions LOWER to UPPER of repository at remote URL to stdout\n"
+ "in a 'dumpfile' portable format. If only LOWER is given, dump that\n"
+ "one revision.\n"),
+ { 'r', 'q', opt_incremental, SVN_SVNRDUMP__BASE_OPTIONS } },
+ { "load", load_cmd, { 0 },
+ N_("usage: svnrdump load URL\n\n"
+ "Load a 'dumpfile' given on stdin to a repository at remote URL.\n"),
+ { 'q', SVN_SVNRDUMP__BASE_OPTIONS } },
+ { "help", 0, { "?", "h" },
+ N_("usage: svnrdump help [SUBCOMMAND...]\n\n"
+ "Describe the usage of this program or its subcommands.\n"),
+ { 0 } },
+ { NULL, NULL, { 0 }, NULL, { 0 } }
+};
static const apr_getopt_option_t svnrdump__options[] =
{
@@ -108,6 +115,8 @@ static const apr_getopt_option_t svnrdum
N_("specify revision number ARG (or X:Y range)")},
{"quiet", 'q', 0,
N_("no progress (only errors) to stderr")},
+ {"incremental", opt_incremental, 0,
+ N_("dump incrementally")},
{"config-dir", opt_config_dir, 1,
N_("read user configuration files from directory ARG")},
{"username", opt_auth_username, 1,
@@ -149,9 +158,11 @@ struct replay_baton {
typedef struct opt_baton_t {
svn_ra_session_t *session;
const char *url;
- svn_revnum_t start_revision;
- svn_revnum_t end_revision;
+ svn_boolean_t help;
+ svn_opt_revision_t start_revision;
+ svn_opt_revision_t end_revision;
svn_boolean_t quiet;
+ svn_boolean_t incremental;
} opt_baton_t;
/* Print dumpstream-formatted information about REVISION.
@@ -170,7 +181,7 @@ replay_revstart(svn_revnum_t revision,
svn_stream_t *stdout_stream;
svn_stream_t *revprop_stream;
- svn_stream_for_stdout(&stdout_stream, pool);
+ SVN_ERR(svn_stream_for_stdout(&stdout_stream, pool));
/* Revision-number: 19 */
SVN_ERR(svn_stream_printf(stdout_stream, pool,
@@ -220,7 +231,8 @@ replay_revend(svn_revnum_t revision,
/* No resources left to free. */
struct replay_baton *rb = replay_baton;
if (! rb->quiet)
- svn_cmdline_fprintf(stderr, pool, "* Dumped revision %lu.\n", revision);
+ SVN_ERR(svn_cmdline_fprintf(stderr, pool, "* Dumped revision %lu.\n",
+ revision));
return SVN_NO_ERROR;
}
@@ -271,6 +283,49 @@ open_connection(svn_ra_session_t **sessi
return SVN_NO_ERROR;
}
+/* Print a revision record header for REVISION to STDOUT_STREAM. Use
+ * SESSION to contact the repository for revision properties and
+ * such.
+ */
+static svn_error_t *
+dump_revision_header(svn_ra_session_t *session,
+ svn_stream_t *stdout_stream,
+ svn_revnum_t revision,
+ apr_pool_t *pool)
+{
+ apr_hash_t *prophash;
+ svn_stringbuf_t *propstring;
+ svn_stream_t *propstream;
+
+ SVN_ERR(svn_stream_printf(stdout_stream, pool,
+ SVN_REPOS_DUMPFILE_REVISION_NUMBER
+ ": %ld\n", revision));
+
+ prophash = apr_hash_make(pool);
+ propstring = svn_stringbuf_create("", pool);
+ SVN_ERR(svn_ra_rev_proplist(session, revision, &prophash, pool));
+
+ propstream = svn_stream_from_stringbuf(propstring, pool);
+ SVN_ERR(svn_hash_write2(prophash, propstream, "PROPS-END", pool));
+ SVN_ERR(svn_stream_close(propstream));
+
+ /* Property-content-length: 14; Content-length: 14 */
+ SVN_ERR(svn_stream_printf(stdout_stream, pool,
+ SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH
+ ": %" APR_SIZE_T_FMT "\n",
+ propstring->len));
+ SVN_ERR(svn_stream_printf(stdout_stream, pool,
+ SVN_REPOS_DUMPFILE_CONTENT_LENGTH
+ ": %" APR_SIZE_T_FMT "\n\n",
+ propstring->len));
+ /* The properties */
+ SVN_ERR(svn_stream_write(stdout_stream, propstring->data,
+ &(propstring->len)));
+ SVN_ERR(svn_stream_printf(stdout_stream, pool, "\n"));
+
+ return SVN_NO_ERROR;
+}
+
/* Replay revisions START_REVISION thru END_REVISION (inclusive) of
* the repository located at URL, using callbacks which generate
* Subversion repository dumpstreams describing the changes made in
@@ -283,6 +338,7 @@ replay_revisions(svn_ra_session_t *sessi
svn_revnum_t start_revision,
svn_revnum_t end_revision,
svn_boolean_t quiet,
+ svn_boolean_t incremental,
apr_pool_t *pool)
{
const svn_delta_editor_t *dump_editor;
@@ -312,46 +368,62 @@ replay_revisions(svn_ra_session_t *sessi
/* Fake revision 0 if necessary */
if (start_revision == 0)
{
- apr_hash_t *prophash;
- svn_stringbuf_t *propstring;
- svn_stream_t *propstream;
- SVN_ERR(svn_stream_printf(stdout_stream, pool,
- SVN_REPOS_DUMPFILE_REVISION_NUMBER
- ": %ld\n", start_revision));
-
- prophash = apr_hash_make(pool);
- propstring = svn_stringbuf_create("", pool);
-
- SVN_ERR(svn_ra_rev_proplist(session, start_revision,
- &prophash, pool));
-
- propstream = svn_stream_from_stringbuf(propstring, pool);
- SVN_ERR(svn_hash_write2(prophash, propstream, "PROPS-END", pool));
- SVN_ERR(svn_stream_close(propstream));
-
- /* Property-content-length: 14; Content-length: 14 */
- SVN_ERR(svn_stream_printf(stdout_stream, pool,
- SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH
- ": %" APR_SIZE_T_FMT "\n",
- propstring->len));
- SVN_ERR(svn_stream_printf(stdout_stream, pool,
- SVN_REPOS_DUMPFILE_CONTENT_LENGTH
- ": %" APR_SIZE_T_FMT "\n\n",
- propstring->len));
- /* The properties */
- SVN_ERR(svn_stream_write(stdout_stream, propstring->data,
- &(propstring->len)));
- SVN_ERR(svn_stream_printf(stdout_stream, pool, "\n"));
+ SVN_ERR(dump_revision_header(session, stdout_stream,
+ start_revision, pool));
+
+ /* Revision 0 has no tree changes, so we're done. */
if (! quiet)
- svn_cmdline_fprintf(stderr, pool, "* Dumped revision %lu.\n",
- start_revision);
+ SVN_ERR(svn_cmdline_fprintf(stderr, pool, "* Dumped revision %lu.\n",
+ start_revision));
+ start_revision++;
+ /* If our first revision is 0, we can treat this as an
+ incremental dump. */
+ incremental = TRUE;
+ }
+
+ if (incremental)
+ {
+ SVN_ERR(svn_ra_replay_range(session, start_revision, end_revision,
+ 0, TRUE, replay_revstart, replay_revend,
+ replay_baton, pool));
+ }
+ else
+ {
+ const svn_ra_reporter3_t *reporter;
+ void *report_baton;
+
+ /* First, we need to dump the start_revision in full. We'll
+ start with a revision record header. */
+ SVN_ERR(dump_revision_header(session, stdout_stream,
+ start_revision, pool));
+
+ /* Then, we'll drive the dump editor with what would look like a
+ full checkout of the repository as it looked in
+ START_REVISION. We do this by manufacturing a basic 'report'
+ to the update reporter, telling it that we have nothing to
+ start with. The delta between nothing and everything-at-REV
+ is, effectively, a full dump of REV. */
+ SVN_ERR(svn_ra_do_update2(session, &reporter, &report_baton,
+ start_revision, "", svn_depth_infinity,
+ FALSE, dump_editor, dump_baton, pool));
+ SVN_ERR(reporter->set_path(report_baton, "", start_revision,
+ svn_depth_infinity, TRUE, NULL, pool));
+ SVN_ERR(reporter->finish_report(report_baton, pool));
+
+ /* All finished with START_REVISION! */
+ if (! quiet)
+ SVN_ERR(svn_cmdline_fprintf(stderr, pool, "* Dumped revision %lu.\n",
+ start_revision));
start_revision++;
+
+ /* Now go pick up additional revisions in the range, if any. */
+ if (start_revision <= end_revision)
+ SVN_ERR(svn_ra_replay_range(session, start_revision, end_revision,
+ 0, TRUE, replay_revstart, replay_revend,
+ replay_baton, pool));
}
- SVN_ERR(svn_ra_replay_range(session, start_revision, end_revision,
- 0, TRUE, replay_revstart, replay_revend,
- replay_baton, pool));
SVN_ERR(svn_stream_close(stdout_stream));
return SVN_NO_ERROR;
}
@@ -378,7 +450,7 @@ load_revisions(svn_ra_session_t *session
SVN_ERR(drive_dumpstream_loader(stdin_stream, parser, parse_baton,
session, check_cancel, NULL, pool));
- svn_stream_close(stdin_stream);
+ SVN_ERR(svn_stream_close(stdin_stream));
return SVN_NO_ERROR;
}
@@ -450,8 +522,9 @@ dump_cmd(apr_getopt_t *os,
{
opt_baton_t *opt_baton = baton;
return replay_revisions(opt_baton->session, opt_baton->url,
- opt_baton->start_revision, opt_baton->end_revision,
- opt_baton->quiet, pool);
+ opt_baton->start_revision.value.number,
+ opt_baton->end_revision.value.number,
+ opt_baton->quiet, opt_baton->incremental, pool);
}
/* Handle the "load" subcommand. Implements `svn_opt_subcommand_t'. */
@@ -482,13 +555,95 @@ help_cmd(apr_getopt_t *os,
NULL, pool);
}
+/* Examine the OPT_BATON's 'start_revision' and 'end_revision'
+ * members, making sure that they make sense (in general, and as
+ * applied to a repository whose current youngest revision is
+ * LATEST_REVISION).
+ */
+static svn_error_t *
+validate_and_resolve_revisions(opt_baton_t *opt_baton,
+ svn_revnum_t latest_revision,
+ apr_pool_t *pool)
+{
+ svn_revnum_t provided_start_rev = SVN_INVALID_REVNUM;
+
+ /* Ensure that the start revision is something we can handle. We
+ want a number >= 0. If unspecified, make it a number (r0) --
+ anything else is bogus. */
+ if (opt_baton->start_revision.kind == svn_opt_revision_number)
+ {
+ provided_start_rev = opt_baton->start_revision.value.number;
+ }
+ else if (opt_baton->start_revision.kind == svn_opt_revision_unspecified)
+ {
+ opt_baton->start_revision.kind = svn_opt_revision_number;
+ opt_baton->start_revision.value.number = 0;
+ }
+
+ if (opt_baton->start_revision.kind != svn_opt_revision_number)
+ {
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Unsupported revision specifier used; use "
+ "only integer values or 'HEAD'"));
+ }
+
+ if ((opt_baton->start_revision.value.number < 0) ||
+ (opt_baton->start_revision.value.number > latest_revision))
+ {
+ return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Revision '%ld' does not exist"),
+ opt_baton->start_revision.value.number);
+ }
+
+ /* Ensure that the end revision is something we can handle. We want
+ a number <= the youngest, and > the start revision. If
+ unspecified, make it a number (start_revision + 1 if that was
+ specified, the youngest revision in the repository otherwise) --
+ anything else is bogus. */
+ if (opt_baton->end_revision.kind == svn_opt_revision_unspecified)
+ {
+ opt_baton->end_revision.kind = svn_opt_revision_number;
+ if (SVN_IS_VALID_REVNUM(provided_start_rev))
+ opt_baton->end_revision.value.number = provided_start_rev;
+ else
+ opt_baton->end_revision.value.number = latest_revision;
+ }
+
+ if (opt_baton->end_revision.kind != svn_opt_revision_number)
+ {
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Unsupported revision specifier used; use "
+ "only integer values or 'HEAD'"));
+ }
+
+ if ((opt_baton->end_revision.value.number < 0) ||
+ (opt_baton->end_revision.value.number > latest_revision))
+ {
+ return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Revision '%ld' does not exist"),
+ opt_baton->end_revision.value.number);
+ }
+
+ /* Finally, make sure that the end revision is younger than the
+ start revision. We don't do "backwards" 'round here. */
+ if (opt_baton->end_revision.value.number <
+ opt_baton->start_revision.value.number)
+ {
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("LOWER revision cannot be greater than "
+ "UPPER revision; consider reversing your "
+ "revision range"));
+ }
+ return SVN_NO_ERROR;
+}
+
int
main(int argc, const char **argv)
{
+ svn_error_t *err = SVN_NO_ERROR;
const svn_opt_subcommand_desc2_t *subcommand = NULL;
opt_baton_t *opt_baton;
- char *revision_cut = NULL;
- svn_revnum_t latest_revision = svn_opt_revision_unspecified;
+ svn_revnum_t latest_revision = SVN_INVALID_REVNUM;
apr_pool_t *pool = NULL;
const char *config_dir = NULL;
const char *username = NULL;
@@ -498,14 +653,16 @@ main(int argc, const char **argv)
apr_array_header_t *config_options = NULL;
apr_getopt_t *os;
const char *first_arg;
+ apr_array_header_t *received_opts;
+ int i;
if (svn_cmdline_init ("svnrdump", stderr) != EXIT_SUCCESS)
return EXIT_FAILURE;
pool = svn_pool_create(NULL);
opt_baton = apr_pcalloc(pool, sizeof(*opt_baton));
- opt_baton->start_revision = svn_opt_revision_unspecified;
- opt_baton->end_revision = svn_opt_revision_unspecified;
+ opt_baton->start_revision.kind = svn_opt_revision_unspecified;
+ opt_baton->end_revision.kind = svn_opt_revision_unspecified;
opt_baton->url = NULL;
SVNRDUMP_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
@@ -535,6 +692,8 @@ main(int argc, const char **argv)
apr_signal(SIGXFSZ, SIG_IGN);
#endif
+ received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
+
while (1)
{
int opt;
@@ -550,23 +709,34 @@ main(int argc, const char **argv)
exit(EXIT_FAILURE);
}
+ /* Stash the option code in an array before parsing it. */
+ APR_ARRAY_PUSH(received_opts, int) = opt;
+
switch(opt)
{
case 'r':
{
- revision_cut = strchr(opt_arg, ':');
- if (revision_cut)
+ /* Make sure we've not seen -r already. */
+ if (opt_baton->start_revision.kind != svn_opt_revision_unspecified)
{
- opt_baton->start_revision =
- (svn_revnum_t)strtoul(opt_arg, &revision_cut, 10);
- opt_baton->end_revision =
- (svn_revnum_t)strtoul(revision_cut + 1, NULL, 10);
+ err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Multiple revision arguments "
+ "encountered; try '-r N:M' instead "
+ "of '-r N -r M'"));
+ return svn_cmdline_handle_exit_error(err, pool, "svnrdump: ");
}
- else
+ /* Parse the -r argument. */
+ if (svn_opt_parse_revision(&(opt_baton->start_revision),
+ &(opt_baton->end_revision),
+ opt_arg, pool) != 0)
{
- opt_baton->start_revision =
- (svn_revnum_t)strtoul(opt_arg, NULL, 10);
- opt_baton->end_revision = opt_baton->start_revision;
+ const char *utf8_opt_arg;
+ err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
+ if (! err)
+ err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Syntax error in revision "
+ "argument '%s'"), utf8_opt_arg);
+ return svn_cmdline_handle_exit_error(err, pool, "svnrdump: ");
}
}
break;
@@ -581,8 +751,7 @@ main(int argc, const char **argv)
exit(EXIT_SUCCESS);
break;
case 'h':
- SVNRDUMP_ERR(help_cmd(os, opt_baton, pool));
- exit(EXIT_SUCCESS);
+ opt_baton->help = TRUE;
break;
case opt_auth_username:
SVNRDUMP_ERR(svn_utf_cstring_to_utf8(&username, opt_arg, pool));
@@ -596,6 +765,9 @@ main(int argc, const char **argv)
case opt_non_interactive:
non_interactive = TRUE;
break;
+ case opt_incremental:
+ opt_baton->incremental = TRUE;
+ break;
case opt_config_option:
if (!config_options)
config_options =
@@ -608,38 +780,77 @@ main(int argc, const char **argv)
}
}
- if (os->ind >= os->argc)
+ if (opt_baton->help)
{
- svn_error_clear(svn_cmdline_fprintf(stderr, pool,
- _("Subcommand argument required\n")));
- SVNRDUMP_ERR(help_cmd(NULL, NULL, pool));
- svn_pool_destroy(pool);
- exit(EXIT_FAILURE);
+ subcommand = svn_opt_get_canonical_subcommand2(svnrdump__cmd_table,
+ "help");
+ }
+ else
+ {
+ if (os->ind >= os->argc)
+ {
+ SVNRDUMP_ERR(help_cmd(NULL, NULL, pool));
+ svn_pool_destroy(pool);
+ exit(EXIT_FAILURE);
+ }
+ else
+ {
+ first_arg = os->argv[os->ind++];
+ subcommand = svn_opt_get_canonical_subcommand2(svnrdump__cmd_table,
+ first_arg);
+
+ if (subcommand == NULL)
+ {
+ const char *first_arg_utf8;
+ err = svn_utf_cstring_to_utf8(&first_arg_utf8, first_arg, pool);
+ if (err)
+ return svn_cmdline_handle_exit_error(err, pool, "svnrdump: ");
+ svn_error_clear(svn_cmdline_fprintf(stderr, pool,
+ _("Unknown command: '%s'\n"),
+ first_arg_utf8));
+ SVNRDUMP_ERR(help_cmd(NULL, NULL, pool));
+ svn_pool_destroy(pool);
+ exit(EXIT_FAILURE);
+ }
+ }
}
- first_arg = os->argv[os->ind++];
+ /* Check that the subcommand wasn't passed any inappropriate options. */
+ for (i = 0; i < received_opts->nelts; i++)
+ {
+ int opt_id = APR_ARRAY_IDX(received_opts, i, int);
- subcommand = svn_opt_get_canonical_subcommand2(svnrdump__cmd_table,
- first_arg);
+ /* All commands implicitly accept --help, so just skip over this
+ when we see it. Note that we don't want to include this option
+ in their "accepted options" list because it would be awfully
+ redundant to display it in every commands' help text. */
+ if (opt_id == 'h' || opt_id == '?')
+ continue;
- if (subcommand == NULL)
- {
- const char *first_arg_utf8;
- svn_error_t *err = svn_utf_cstring_to_utf8(&first_arg_utf8,
- first_arg, pool);
- if (err)
- return svn_cmdline_handle_exit_error(err, pool, "svnrdump: ");
- svn_error_clear(svn_cmdline_fprintf(stderr, pool,
- _("Unknown command: '%s'\n"),
- first_arg_utf8));
- SVNRDUMP_ERR(help_cmd(NULL, NULL, pool));
- svn_pool_destroy(pool);
- exit(EXIT_FAILURE);
+ if (! svn_opt_subcommand_takes_option3(subcommand, opt_id, NULL))
+ {
+ const char *optstr;
+ const apr_getopt_option_t *badopt =
+ svn_opt_get_option_from_code2(opt_id, svnrdump__options,
+ subcommand, pool);
+ svn_opt_format_option(&optstr, badopt, FALSE, pool);
+ if (subcommand->name[0] == '-')
+ SVN_INT_ERR(help_cmd(NULL, NULL, pool));
+ else
+ svn_error_clear(svn_cmdline_fprintf(
+ stderr, pool,
+ _("Subcommand '%s' doesn't accept option '%s'\n"
+ "Type 'svnrdump help %s' for usage.\n"),
+ subcommand->name, optstr, subcommand->name));
+ svn_pool_destroy(pool);
+ return EXIT_FAILURE;
+ }
}
if (subcommand && strcmp(subcommand->name, "help") == 0)
{
SVNRDUMP_ERR(help_cmd(os, opt_baton, pool));
+ svn_pool_destroy(pool);
exit(EXIT_SUCCESS);
}
@@ -648,6 +859,7 @@ main(int argc, const char **argv)
|| !svn_path_is_url(os->argv[os->ind]))
{
SVNRDUMP_ERR(usage(argv[0], pool));
+ svn_pool_destroy(pool);
exit(EXIT_FAILURE);
}
@@ -670,24 +882,10 @@ main(int argc, const char **argv)
unspecified. */
SVNRDUMP_ERR(svn_ra_get_latest_revnum(opt_baton->session,
&latest_revision, pool));
- if (opt_baton->start_revision == svn_opt_revision_unspecified)
- opt_baton->start_revision = 0;
- if (opt_baton->end_revision == svn_opt_revision_unspecified)
- opt_baton->end_revision = latest_revision;
- if (opt_baton->end_revision > latest_revision)
- {
- SVN_INT_ERR(svn_cmdline_fprintf(stderr, pool,
- _("Revision %ld does not exist.\n"),
- opt_baton->end_revision));
- exit(EXIT_FAILURE);
- }
- if (opt_baton->end_revision < opt_baton->start_revision)
- {
- SVN_INT_ERR(svn_cmdline_fprintf(stderr, pool,
- _("LOWER cannot be greater "
- "than UPPER.\n")));
- exit(EXIT_FAILURE);
- }
+
+ /* Make sure any provided revisions make sense. */
+ SVNRDUMP_ERR(validate_and_resolve_revisions(opt_baton,
+ latest_revision, pool));
/* Dispatch the subcommand */
SVNRDUMP_ERR((*subcommand->cmd_func)(os, opt_baton, pool));
Modified: subversion/branches/performance/subversion/svnsync/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnsync/main.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnsync/main.c (original)
+++ subversion/branches/performance/subversion/svnsync/main.c Wed Dec 29 21:12:33 2010
@@ -34,13 +34,13 @@
#include "svn_string.h"
#include "private/svn_opt_private.h"
+#include "private/svn_ra_private.h"
#include "private/svn_cmdline_private.h"
#include "sync.h"
#include "svn_private_config.h"
-#include <apr_network_io.h>
#include <apr_signal.h>
#include <apr_uuid.h>
@@ -65,6 +65,7 @@ enum svnsync__opt {
svnsync_opt_version,
svnsync_opt_trust_server_cert,
svnsync_opt_allow_non_empty,
+ svnsync_opt_steal_lock,
};
#define SVNSYNC_OPTS_DEFAULT svnsync_opt_non_interactive, \
@@ -105,7 +106,7 @@ static const svn_opt_subcommand_desc2_t
"In other words, the destination repository should be a read-only\n"
"mirror of the source repository.\n"),
{ SVNSYNC_OPTS_DEFAULT, 'q', svnsync_opt_allow_non_empty,
- svnsync_opt_disable_locking } },
+ svnsync_opt_disable_locking, svnsync_opt_steal_lock } },
{ "synchronize", synchronize_cmd, { "sync" },
N_("usage: svnsync synchronize DEST_URL [SOURCE_URL]\n"
"\n"
@@ -117,7 +118,8 @@ static const svn_opt_subcommand_desc2_t
"source URL. Specifying SOURCE_URL is recommended in particular\n"
"if untrusted users/administrators may have write access to the\n"
"DEST_URL repository.\n"),
- { SVNSYNC_OPTS_DEFAULT, 'q', svnsync_opt_disable_locking } },
+ { SVNSYNC_OPTS_DEFAULT, 'q', svnsync_opt_disable_locking,
+ svnsync_opt_steal_lock } },
{ "copy-revprops", copy_revprops_cmd, { 0 },
N_("usage:\n"
"\n"
@@ -137,7 +139,8 @@ static const svn_opt_subcommand_desc2_t
"DEST_URL repository.\n"
"\n"
"Form 2 is deprecated syntax, equivalent to specifying \"-rREV[:REV2]\".\n"),
- { SVNSYNC_OPTS_DEFAULT, 'q', 'r', svnsync_opt_disable_locking } },
+ { SVNSYNC_OPTS_DEFAULT, 'q', 'r', svnsync_opt_disable_locking,
+ svnsync_opt_steal_lock } },
{ "info", info_cmd, { 0 },
N_("usage: svnsync info DEST_URL\n"
"\n"
@@ -201,11 +204,19 @@ static const apr_getopt_option_t svnsync
" "
" servers:global:http-library=serf")},
{"disable-locking", svnsync_opt_disable_locking, 0,
- N_("Disable built-in locking. Use of this option can\n"
+ N_("Disable built-in locking. Use of this option can\n"
" "
"corrupt the mirror unless you ensure that no other\n"
" "
"instance of svnsync is running concurrently.")},
+ {"steal-lock", svnsync_opt_steal_lock, 0,
+ N_("Steal locks as necessary. Use, with caution,\n"
+ " "
+ "if your mirror repository contains stale locks\n"
+ " "
+ "and is not being concurrently accessed by another\n"
+ " "
+ "svnsync instance.")},
{"version", svnsync_opt_version, 0,
N_("show program version information")},
{"help", 'h', 0,
@@ -228,6 +239,7 @@ typedef struct {
const char *config_dir;
apr_hash_t *config;
svn_boolean_t disable_locking;
+ svn_boolean_t steal_lock;
svn_boolean_t quiet;
svn_boolean_t allow_non_empty;
svn_boolean_t version;
@@ -284,57 +296,32 @@ check_lib_versions(void)
}
-/* Does ERR mean "the current value of the revprop isn't equal to
- the *OLD_VALUE_P you gave me"?
- */
-static svn_boolean_t is_atomicity_error(svn_error_t *err)
-{
- return svn_error_has_cause(err, SVN_ERR_FS_PROP_BASEVALUE_MISMATCH);
-}
-
-/* Remove the lock on SESSION iff the lock is owned by MYLOCKTOKEN. */
+/* Implements `svn_ra__lock_retry_func_t'. */
static svn_error_t *
-maybe_unlock(svn_ra_session_t *session,
- const svn_string_t *mylocktoken,
- apr_pool_t *scratch_pool)
+lock_retry_func(void *baton,
+ const svn_string_t *reposlocktoken,
+ apr_pool_t *pool)
{
- svn_string_t *reposlocktoken;
- svn_boolean_t be_atomic;
-
- SVN_ERR(svn_ra_has_capability(session, &be_atomic,
- SVN_RA_CAPABILITY_ATOMIC_REVPROPS,
- scratch_pool));
-
- SVN_ERR(svn_ra_rev_prop(session, 0, SVNSYNC_PROP_LOCK, &reposlocktoken,
- scratch_pool));
- if (reposlocktoken && strcmp(reposlocktoken->data, mylocktoken->data) == 0)
- SVN_ERR(svn_ra_change_rev_prop2(session, 0, SVNSYNC_PROP_LOCK,
- be_atomic ? &mylocktoken : NULL, NULL,
- scratch_pool));
-
- return SVN_NO_ERROR;
+ return svn_cmdline_printf(pool,
+ _("Failed to get lock on destination "
+ "repos, currently held by '%s'\n"),
+ reposlocktoken->data);
}
/* Acquire a lock (of sorts) on the repository associated with the
* given RA SESSION. This lock is just a revprop change attempt in a
* time-delay loop. This function is duplicated by svnrdump in
* load_editor.c.
- *
- * ### TODO: Make this function more generic and
- * expose it through a header for use by other Subversion
- * applications to avoid duplication.
*/
static svn_error_t *
get_lock(const svn_string_t **lock_string_p,
svn_ra_session_t *session,
+ svn_boolean_t steal_lock,
apr_pool_t *pool)
{
- char hostname_str[APRMAXHOSTLEN + 1] = { 0 };
- svn_string_t *mylocktoken, *reposlocktoken;
- apr_status_t apr_err;
+ svn_error_t *err;
svn_boolean_t be_atomic;
- apr_pool_t *subpool;
- int i;
+ const svn_string_t *stolen_lock;
SVN_ERR(svn_ra_has_capability(session, &be_atomic,
SVN_RA_CAPABILITY_ATOMIC_REVPROPS,
@@ -344,8 +331,6 @@ get_lock(const svn_string_t **lock_strin
/* Pre-1.7 server. Can't lock without a race condition.
See issue #3546.
*/
- svn_error_t *err;
-
err = svn_error_create(
SVN_ERR_UNSUPPORTED_FEATURE, NULL,
_("Target server does not support atomic revision property "
@@ -355,80 +340,17 @@ get_lock(const svn_string_t **lock_strin
svn_error_clear(err);
}
- apr_err = apr_gethostname(hostname_str, sizeof(hostname_str), pool);
- if (apr_err)
- return svn_error_wrap_apr(apr_err, _("Can't get local hostname"));
-
- mylocktoken = svn_string_createf(pool, "%s:%s", hostname_str,
- svn_uuid_generate(pool));
-
- /* If we succeed, this is what the property will be set to. */
- *lock_string_p = mylocktoken;
-
- subpool = svn_pool_create(pool);
-
-#define SVNSYNC_LOCK_RETRIES 10
- for (i = 0; i < SVNSYNC_LOCK_RETRIES; ++i)
- {
- svn_error_t *err;
-
- svn_pool_clear(subpool);
-
- /* If we're cancelled, don't leave a stray lock behind. */
- err = check_cancel(NULL);
- if (err && err->apr_err == SVN_ERR_CANCELLED)
- return svn_error_compose_create(
- maybe_unlock(session, mylocktoken, subpool),
- err);
- else
- SVN_ERR(err);
-
- SVN_ERR(svn_ra_rev_prop(session, 0, SVNSYNC_PROP_LOCK, &reposlocktoken,
- subpool));
- if (reposlocktoken)
- {
- /* Did we get it? If so, we're done, otherwise we sleep. */
- if (strcmp(reposlocktoken->data, mylocktoken->data) == 0)
- return SVN_NO_ERROR;
- else
- {
- SVN_ERR(svn_cmdline_printf
- (pool, _("Failed to get lock on destination "
- "repos, currently held by '%s'\n"),
- reposlocktoken->data));
-
- apr_sleep(apr_time_from_sec(1));
- }
- }
- else if (i < SVNSYNC_LOCK_RETRIES - 1)
- {
- const svn_string_t *unset = NULL;
-
- /* Except in the very last iteration, try to set the lock. */
- err = svn_ra_change_rev_prop2(session, 0, SVNSYNC_PROP_LOCK,
- be_atomic ? &unset : NULL,
- mylocktoken, subpool);
-
- if (be_atomic && err && is_atomicity_error(err))
- /* Someone else has the lock. Let's loop. */
- svn_error_clear(err);
- else if (be_atomic && err == SVN_NO_ERROR)
- /* We have the lock.
-
- However, for compatibility with concurrent svnsync's that don't
- support atomicity, loop anyway to double-check that they haven't
- overwritten our lock.
- */
- continue;
- else
- /* Genuine error, or we aren't atomic and need to loop. */
- SVN_ERR(err);
- }
+ err = svn_ra__get_operational_lock(lock_string_p, &stolen_lock, session,
+ SVNSYNC_PROP_LOCK, steal_lock,
+ 10 /* retries */, lock_retry_func, NULL,
+ check_cancel, NULL, pool);
+ if (!err && stolen_lock)
+ {
+ return svn_cmdline_printf(pool,
+ _("Stole lock previously held by '%s'\n"),
+ stolen_lock->data);
}
-
- return svn_error_createf(APR_EINVAL, NULL,
- _("Couldn't get lock on destination repos "
- "after %d attempts"), i);
+ return err;
}
@@ -467,29 +389,17 @@ static svn_error_t *
with_locked(svn_ra_session_t *session,
with_locked_func_t func,
subcommand_baton_t *baton,
+ svn_boolean_t steal_lock,
apr_pool_t *pool)
{
- svn_error_t *err, *err2;
const svn_string_t *lock_string;
- svn_boolean_t be_atomic;
-
- SVN_ERR(svn_ra_has_capability(session, &be_atomic,
- SVN_RA_CAPABILITY_ATOMIC_REVPROPS,
- pool));
-
- SVN_ERR(get_lock(&lock_string, session, pool));
-
- err = func(session, baton, pool);
-
- err2 = svn_ra_change_rev_prop2(session, 0, SVNSYNC_PROP_LOCK,
- be_atomic ? &lock_string : NULL, NULL, pool);
- if (is_atomicity_error(err2))
- err2 = svn_error_quick_wrap(err2,
- _("svnsync's lock was stolen; "
- "can't remove it"));
+ SVN_ERR(get_lock(&lock_string, session, steal_lock, pool));
- return svn_error_compose_create(err, svn_error_return(err2));
+ return svn_error_compose_create(
+ func(session, baton, pool),
+ svn_ra__release_operational_lock(session, SVNSYNC_PROP_LOCK,
+ lock_string, pool));
}
@@ -925,7 +835,8 @@ initialize_cmd(apr_getopt_t *os, void *b
if (opt_baton->disable_locking)
SVN_ERR(do_initialize(to_session, baton, pool));
else
- SVN_ERR(with_locked(to_session, do_initialize, baton, pool));
+ SVN_ERR(with_locked(to_session, do_initialize, baton,
+ opt_baton->steal_lock, pool));
return SVN_NO_ERROR;
}
@@ -1441,7 +1352,8 @@ synchronize_cmd(apr_getopt_t *os, void *
if (opt_baton->disable_locking)
SVN_ERR(do_synchronize(to_session, baton, pool));
else
- SVN_ERR(with_locked(to_session, do_synchronize, baton, pool));
+ SVN_ERR(with_locked(to_session, do_synchronize, baton,
+ opt_baton->steal_lock, pool));
return SVN_NO_ERROR;
}
@@ -1675,7 +1587,8 @@ copy_revprops_cmd(apr_getopt_t *os, void
if (opt_baton->disable_locking)
SVN_ERR(do_copy_revprops(to_session, baton, pool));
else
- SVN_ERR(with_locked(to_session, do_copy_revprops, baton, pool));
+ SVN_ERR(with_locked(to_session, do_copy_revprops, baton,
+ opt_baton->steal_lock, pool));
return SVN_NO_ERROR;
}
@@ -1829,7 +1742,7 @@ main(int argc, const char *argv[])
if (argc <= 1)
{
- help_cmd(NULL, NULL, pool);
+ SVN_INT_ERR(help_cmd(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1850,7 +1763,7 @@ main(int argc, const char *argv[])
break;
else if (apr_err)
{
- help_cmd(NULL, NULL, pool);
+ SVN_INT_ERR(help_cmd(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -1922,6 +1835,10 @@ main(int argc, const char *argv[])
opt_baton.disable_locking = TRUE;
break;
+ case svnsync_opt_steal_lock:
+ opt_baton.steal_lock = TRUE;
+ break;
+
case svnsync_opt_version:
opt_baton.version = TRUE;
break;
@@ -1970,7 +1887,7 @@ main(int argc, const char *argv[])
default:
{
- help_cmd(NULL, NULL, pool);
+ SVN_INT_ERR(help_cmd(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -2012,6 +1929,15 @@ main(int argc, const char *argv[])
opt_baton.sync_username = sync_username;
opt_baton.sync_password = sync_password;
+ /* Disallow mixing of --steal-lock and --disable-locking. */
+ if (opt_baton.steal_lock && opt_baton.disable_locking)
+ {
+ err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("--disable-locking and --steal-lock are "
+ "mutually exclusive"));
+ return svn_cmdline_handle_exit_error(err, pool, "svnsync: ");
+ }
+
/* --trust-server-cert can only be used with --non-interactive */
if (opt_baton.trust_server_cert && !opt_baton.non_interactive)
{
@@ -2041,7 +1967,7 @@ main(int argc, const char *argv[])
}
else
{
- help_cmd(NULL, NULL, pool);
+ SVN_INT_ERR(help_cmd(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -2053,7 +1979,7 @@ main(int argc, const char *argv[])
first_arg);
if (subcommand == NULL)
{
- help_cmd(NULL, NULL, pool);
+ SVN_INT_ERR(help_cmd(NULL, NULL, pool));
svn_pool_destroy(pool);
return EXIT_FAILURE;
}
@@ -2076,7 +2002,7 @@ main(int argc, const char *argv[])
svn_opt_format_option(&optstr, badopt, FALSE, pool);
if (subcommand->name[0] == '-')
{
- help_cmd(NULL, NULL, pool);
+ SVN_INT_ERR(help_cmd(NULL, NULL, pool));
}
else
{
Modified: subversion/branches/performance/subversion/svnversion/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnversion/main.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnversion/main.c (original)
+++ subversion/branches/performance/subversion/svnversion/main.c Wed Dec 29 21:12:33 2010
@@ -74,8 +74,10 @@ help(const apr_getopt_option_t *options,
" 4123P partial working copy, from a sparse checkout\n"
" 4123:4168MS mixed revision, modified, switched working copy\n"
"\n"
- " If invoked on a directory that is not a working copy, an\n"
- " exported directory say, the program will output 'exported'.\n"
+ " If WC_PATH is an unversioned path, the program will output\n"
+ " 'Unversioned directory' or 'Unversioned file'. If WC_PATH is\n"
+ " an added or copied or moved path, the program will output\n"
+ " 'Uncommitted local addition, copy or move'.\n"
"\n"
" If invoked without arguments WC_PATH will be the current directory.\n"
"\n"
Modified: subversion/branches/performance/subversion/tests/cmdline/atomic-ra-revprop-change.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/cmdline/atomic-ra-revprop-change.c?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/cmdline/atomic-ra-revprop-change.c (original)
+++ subversion/branches/performance/subversion/tests/cmdline/atomic-ra-revprop-change.c Wed Dec 29 21:12:33 2010
@@ -164,7 +164,7 @@ change_rev_prop(const char *url,
&old_value, propval, pool);
if (want_error && err
- && svn_error_has_cause(err, SVN_ERR_FS_PROP_BASEVALUE_MISMATCH))
+ && svn_error_find_cause(err, SVN_ERR_FS_PROP_BASEVALUE_MISMATCH))
{
/* Expectation was matched. Get out. */
svn_error_clear(err);
Modified: subversion/branches/performance/subversion/tests/cmdline/copy_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/cmdline/copy_tests.py?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/cmdline/copy_tests.py (original)
+++ subversion/branches/performance/subversion/tests/cmdline/copy_tests.py Wed Dec 29 21:12:33 2010
@@ -4942,6 +4942,21 @@ def copy_wc_over_deleted_other_kind(sbox
Item(status=' ', wc_rev='-', copied='+')})
svntest.actions.run_and_verify_status(sbox.wc_dir, expected_status)
+def move_wc_and_repo_dir_to_itself(sbox):
+ "move wc and repo dir to itself"
+ sbox.build(read_only = True)
+ wc_dir = os.path.join(sbox.wc_dir, 'A')
+ repo_url = sbox.repo_url + '/A'
+
+ # try to move wc dir to itself
+ svntest.actions.run_and_verify_svn(None, [],
+ '.*Cannot move path.* into itself.*',
+ 'move', wc_dir, wc_dir)
+
+ # try to move repo dir to itself
+ svntest.actions.run_and_verify_svn(None, [],
+ '.*Cannot move URL.* into itself.*',
+ 'move', repo_url, repo_url)
########################################################################
# Run the tests
@@ -5045,6 +5060,7 @@ test_list = [ None,
copy_repos_over_deleted_other_kind,
copy_wc_over_deleted_same_kind,
copy_wc_over_deleted_other_kind,
+ move_wc_and_repo_dir_to_itself,
]
if __name__ == '__main__':
Modified: subversion/branches/performance/subversion/tests/cmdline/diff_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/cmdline/diff_tests.py?rev=1053735&r1=1053734&r2=1053735&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/branches/performance/subversion/tests/cmdline/diff_tests.py Wed Dec 29 21:12:33 2010
@@ -34,6 +34,7 @@ import svntest
# (abbreviation)
Skip = svntest.testcase.Skip
XFail = svntest.testcase.XFail
+Wimp = svntest.testcase.Wimp
Item = svntest.wc.StateItem
@@ -3795,7 +3796,7 @@ test_list = [ None,
diff_weird_author,
diff_ignore_whitespace,
diff_ignore_eolstyle,
- XFail(diff_in_renamed_folder),
+ diff_in_renamed_folder,
diff_with_depth,
diff_ignore_eolstyle_empty_lines,
diff_backward_repos_wc_copy,