Author: cmpilato
Date: Wed Nov 10 01:44:35 2010
New Revision: 1033320
URL: http://svn.apache.org/viewvc?rev=1033320&view=rev
Log:
Fix issue #3622 ("svn should exit with exit code 1 if updating
externals fails").
* subversion/include/svn_error_codes.h
(SVN_ERR_CL_ERROR_PROCESSING_EXTERNALS): New error code.
* subversion/svn/cl.h
(struct svn_cl__check_externals_failed_notify_baton): New baton.
(svn_cl__check_externals_failed_notify_wrapper): New function.
* subversion/svn/notify.c
(svn_cl__check_externals_failed_notify_wrapper): New function.
* subversion/svn/update-cmd.c
(svn_cl__update): Use the new wrapper baton and function to track
externals processing failures, and return an error after all else
is finished if such failures occured.
* subversion/svn/export-cmd.c
(svn_cl__export): Use the new wrapper baton and function to track
externals processing failures, and return an error after all else
is finished if such failures occured.
* subversion/svn/switch-cmd.c
(svn_cl__switch): Use the new wrapper baton and function to track
externals processing failures, and return an error after all else
is finished if such failures occured.
* subversion/tests/cmdline/externals_tests.py
(old_style_externals_ignore_peg_reg,
can_place_file_external_into_dir_external): Change expected exit code.
Modified:
subversion/trunk/subversion/include/svn_error_codes.h
subversion/trunk/subversion/svn/cl.h
subversion/trunk/subversion/svn/export-cmd.c
subversion/trunk/subversion/svn/notify.c
subversion/trunk/subversion/svn/switch-cmd.c
subversion/trunk/subversion/svn/update-cmd.c
subversion/trunk/subversion/tests/cmdline/externals_tests.py
Modified: subversion/trunk/subversion/include/svn_error_codes.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_error_codes.h?rev=1033320&r1=1033319&r2=1033320&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_error_codes.h (original)
+++ subversion/trunk/subversion/include/svn_error_codes.h Wed Nov 10 01:44:35
2010
@@ -1391,6 +1391,10 @@ SVN_ERROR_START
SVN_ERR_CL_CATEGORY_START + 10,
"No external merge tool available")
+ SVN_ERRDEF(SVN_ERR_CL_ERROR_PROCESSING_EXTERNALS,
+ SVN_ERR_CL_CATEGORY_START + 11,
+ "Failed processing one or more externals definitions")
+
/* malfunctions such as assertion failures */
SVN_ERRDEF(SVN_ERR_ASSERTION_FAIL,
Modified: subversion/trunk/subversion/svn/cl.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1033320&r1=1033319&r2=1033320&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Wed Nov 10 01:44:35 2010
@@ -569,6 +569,21 @@ svn_cl__notifier_mark_checkout(void *bat
svn_error_t *
svn_cl__notifier_mark_export(void *baton);
+/* Baton for use with svn_cl__check_externals_failed_notify_wrapper(). */
+struct svn_cl__check_externals_failed_notify_baton
+{
+ void *wrapped_baton; /* The "real" notify_func2. */
+ svn_wc_notify_func2_t wrapped_func; /* The "real" notify_func2 baton. */
+ svn_boolean_t had_externals_error; /* Did something fail in an external? */
+};
+
+/* Notification function wrapper (implements `svn_wc_notify_func2_t').
+ Use with an svn_cl__check_externals_failed_notify_baton BATON. */
+void
+svn_cl__check_externals_failed_notify_wrapper(void *baton,
+ const svn_wc_notify_t *n,
+ apr_pool_t *pool);
+
/* Print conflict stats accumulated in NOTIFY_BATON.
* Return any error encountered during printing.
* Do all allocations in POOL.*/
Modified: subversion/trunk/subversion/svn/export-cmd.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/export-cmd.c?rev=1033320&r1=1033319&r2=1033320&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/export-cmd.c (original)
+++ subversion/trunk/subversion/svn/export-cmd.c Wed Nov 10 01:44:35 2010
@@ -52,6 +52,7 @@ svn_cl__export(apr_getopt_t *os,
svn_error_t *err;
svn_opt_revision_t peg_revision;
const char *truefrom;
+ struct svn_cl__check_externals_failed_notify_baton nwb;
SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
opt_state->targets,
@@ -95,6 +96,12 @@ svn_cl__export(apr_getopt_t *os,
if (opt_state->depth == svn_depth_unknown)
opt_state->depth = svn_depth_infinity;
+ nwb.wrapped_func = ctx->notify_func2;
+ nwb.wrapped_baton = ctx->notify_baton2;
+ nwb.had_externals_error = FALSE;
+ ctx->notify_func2 = svn_cl__check_externals_failed_notify_wrapper;
+ ctx->notify_baton2 = &nwb;
+
/* Do the export. */
err = svn_client_export5(NULL, truefrom, to, &peg_revision,
&(opt_state->start_revision),
@@ -106,5 +113,10 @@ svn_cl__export(apr_getopt_t *os,
_("Destination directory exists; please remove "
"the directory or use --force to overwrite"));
+ if (nwb.had_externals_error)
+ return svn_error_create(SVN_ERR_CL_ERROR_PROCESSING_EXTERNALS, NULL,
+ _("Failure occured processing one or more "
+ "externals definitions"));
+
return svn_error_return(err);
}
Modified: subversion/trunk/subversion/svn/notify.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/notify.c?rev=1033320&r1=1033319&r2=1033320&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/notify.c (original)
+++ subversion/trunk/subversion/svn/notify.c Wed Nov 10 01:44:35 2010
@@ -952,3 +952,18 @@ svn_cl__notifier_mark_export(void *baton
nb->is_export = TRUE;
return SVN_NO_ERROR;
}
+
+void
+svn_cl__check_externals_failed_notify_wrapper(void *baton,
+ const svn_wc_notify_t *n,
+ apr_pool_t *pool)
+{
+ struct svn_cl__check_externals_failed_notify_baton *nwb = baton;
+
+ if (n->action == svn_wc_notify_failed_external)
+ nwb->had_externals_error = TRUE;
+
+ if (nwb->wrapped_func)
+ nwb->wrapped_func(nwb->wrapped_baton, n, pool);
+}
+
Modified: subversion/trunk/subversion/svn/switch-cmd.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/switch-cmd.c?rev=1033320&r1=1033319&r2=1033320&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/switch-cmd.c (original)
+++ subversion/trunk/subversion/svn/switch-cmd.c Wed Nov 10 01:44:35 2010
@@ -101,6 +101,7 @@ svn_cl__switch(apr_getopt_t *os,
svn_opt_revision_t peg_revision;
svn_depth_t depth;
svn_boolean_t depth_is_sticky;
+ struct svn_cl__check_externals_failed_notify_baton nwb;
/* This command should discover (or derive) exactly two cmdline
arguments: a local path to update ("target"), and a new url to
@@ -158,6 +159,12 @@ svn_cl__switch(apr_getopt_t *os,
depth_is_sticky = FALSE;
}
+ nwb.wrapped_func = ctx->notify_func2;
+ nwb.wrapped_baton = ctx->notify_baton2;
+ nwb.had_externals_error = FALSE;
+ ctx->notify_func2 = svn_cl__check_externals_failed_notify_wrapper;
+ ctx->notify_baton2 = &nwb;
+
/* Do the 'switch' update. */
SVN_ERR(svn_client_switch2(NULL, target, switch_url, &peg_revision,
&(opt_state->start_revision), depth,
@@ -165,7 +172,12 @@ svn_cl__switch(apr_getopt_t *os,
opt_state->force, ctx, scratch_pool));
if (! opt_state->quiet)
- SVN_ERR(svn_cl__print_conflict_stats(ctx->notify_baton2, scratch_pool));
+ SVN_ERR(svn_cl__print_conflict_stats(nwb.wrapped_baton, scratch_pool));
+
+ if (nwb.had_externals_error)
+ return svn_error_create(SVN_ERR_CL_ERROR_PROCESSING_EXTERNALS, NULL,
+ _("Failure occured processing one or more "
+ "externals definitions"));
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/svn/update-cmd.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/update-cmd.c?rev=1033320&r1=1033319&r2=1033320&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/update-cmd.c (original)
+++ subversion/trunk/subversion/svn/update-cmd.c Wed Nov 10 01:44:35 2010
@@ -50,6 +50,7 @@ svn_cl__update(apr_getopt_t *os,
apr_array_header_t *targets;
svn_depth_t depth;
svn_boolean_t depth_is_sticky;
+ struct svn_cl__check_externals_failed_notify_baton nwb;
SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
opt_state->targets,
@@ -85,6 +86,12 @@ svn_cl__update(apr_getopt_t *os,
depth_is_sticky = FALSE;
}
+ nwb.wrapped_func = ctx->notify_func2;
+ nwb.wrapped_baton = ctx->notify_baton2;
+ nwb.had_externals_error = FALSE;
+ ctx->notify_func2 = svn_cl__check_externals_failed_notify_wrapper;
+ ctx->notify_baton2 = &nwb;
+
SVN_ERR(svn_client_update3(NULL, targets,
&(opt_state->start_revision),
depth, depth_is_sticky,
@@ -93,7 +100,12 @@ svn_cl__update(apr_getopt_t *os,
ctx, scratch_pool));
if (! opt_state->quiet)
- SVN_ERR(svn_cl__print_conflict_stats(ctx->notify_baton2, scratch_pool));
+ SVN_ERR(svn_cl__print_conflict_stats(nwb.wrapped_baton, scratch_pool));
+
+ if (nwb.had_externals_error)
+ return svn_error_create(SVN_ERR_CL_ERROR_PROCESSING_EXTERNALS, NULL,
+ _("Failure occured processing one or more "
+ "externals definitions"));
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/tests/cmdline/externals_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/externals_tests.py?rev=1033320&r1=1033319&r2=1033320&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/externals_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/externals_tests.py Wed Nov 10
01:44:35 2010
@@ -947,7 +947,7 @@ def old_style_externals_ignore_peg_reg(s
svntest.actions.run_and_verify_svn2("External '%s' used pegs" % ext.strip(),
None,
expected_error,
- 0,
+ 1,
'up',
wc_dir)
@@ -1063,7 +1063,7 @@ def can_place_file_external_into_dir_ext
svntest.actions.run_and_verify_svn2("Able to put file external in foreign
wc",
None,
expected_error,
- 0,
+ 1,
'up',
repo_url, wc_dir)