On Tue, Jan 08, 2002 at 07:59:49PM -0500, Garrett Rooney wrote:
> > > now the question is what to do about it. i have a patch that will
> > > just handle this for SVN_CLIENT_DIFF. we can just check that diff
> > > exited with either 0, 1, or 2 (the only exit codes it is supposed to
> > > use, according to it's man page), and if it exits with something else,
> > > we know there's a problem and we error out.
> > >
> > +1 for this approach. We should also be doing something similar when we run
> > patch. In fact I beleive there are/were comments to the effect of
> >
> > /* ### need to do better handling of the exit status diff left us here. */
>
> ok, i'll put that patch together again and send it off as soon as the
> recent diff breakage is fixed (no reason to send the patch and then
> imediately have to recreate it if any of the files change...).
here's the diff to handle errors calling diff. i looked for places
that we're calling patch, but the only place we seem to use
SVN_CLIENT_PATCH is in libsvn_wc/get-editor.c, and that's just
creating a stringbuf. i couldn't find anywhere that we actually call
it.
* subversion/include/svn_error_codes.h
(SVN_ERR_EXTERNAL_PROGRAM): new error for when an external program
fails for some reason.
* subversion/libsvn_wc/get_editor.c
(close_file): return an error when diff returns an unexpected exit
code.
* subversion/libsvn_client/diff.c
(svn_client__diff_cmd): ditto
* subversion/svnlook/main.c
(print_diff_tree): ditto
Index: ./subversion/include/svn_error_codes.h
===================================================================
--- ./subversion/include/svn_error_codes.h
+++ ./subversion/include/svn_error_codes.h Tue Jan 8 21:14:51 2002
@@ -274,6 +274,9 @@
SVN_ERRDEF (SVN_ERR_REPOS_HOOK_FAILURE,
"A repository hook failed.")
+ SVN_ERRDEF (SVN_ERR_EXTERNAL_PROGRAM,
+ "Error calling external program")
+
SVN_ERRDEF (SVN_ERR_BERKELEY_DB,
"Berkeley DB error")
Index: ./subversion/libsvn_wc/get_editor.c
===================================================================
--- ./subversion/libsvn_wc/get_editor.c
+++ ./subversion/libsvn_wc/get_editor.c Tue Jan 8 21:15:08 2002
@@ -1245,6 +1245,7 @@
apr_proc_t diff_proc;
apr_procattr_t *diffproc_attr;
const char *diff_args[6];
+ int exitcode;
apr_file_t *received_diff_file;
svn_stringbuf_t *tmp_txtb_full_path
@@ -1318,12 +1319,17 @@
"close_file: error starting diff process");
/* Wait for the diff command to finish. */
- apr_err = apr_proc_wait (&diff_proc, NULL, NULL, APR_WAIT);
+ apr_err = apr_proc_wait
+ (&diff_proc, &exitcode, NULL, APR_WAIT);
if (APR_STATUS_IS_CHILD_NOTDONE (apr_err))
return svn_error_createf
(apr_err, 0, NULL, fb->pool,
"close_file: error waiting for diff process");
-
+
+ if (exitcode < 0 || exitcode > 2)
+ return svn_error_createf
+ (SVN_ERR_EXTERNAL_PROGRAM, 0, NULL, fb->pool,
+ "Error calling %s.", SVN_CLIENT_DIFF);
/* Write a log message to `patch' the working file and
cleanup... */
Index: ./subversion/libsvn_client/diff.c
===================================================================
--- ./subversion/libsvn_client/diff.c
+++ ./subversion/libsvn_client/diff.c Tue Jan 8 21:15:27 2002
@@ -119,6 +119,11 @@
SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, &exitcode, &exitwhy, NULL,
outhandle, errhandle, subpool));
+ if (exitcode < 0 || exitcode > 2)
+ return svn_error_createf
+ (SVN_ERR_EXTERNAL_PROGRAM, 0, NULL, subpool,
+ "Error calling %s.", SVN_CLIENT_DIFF);
+
/* TODO: Handle exit code == 2 (i.e. errors with diff) here */
/* TODO: someday we'll need to worry about whether we're going to need to
Index: ./subversion/svnlook/main.c
===================================================================
--- ./subversion/svnlook/main.c
+++ ./subversion/svnlook/main.c Tue Jan 8 21:15:35 2002
@@ -472,6 +472,7 @@
const char *args[5];
apr_file_t *outhandle;
apr_status_t apr_err;
+ int exitcode;
printf ("%s: %s\n",
((tmp_node->action == 'A') ? "Added" :
@@ -496,8 +497,13 @@
(apr_err, 0, NULL, pool,
"print_diff_tree: can't open handle to stdout");
- SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, NULL, NULL,
+ SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, &exitcode, NULL,
NULL, outhandle, NULL, pool));
+
+ if (exitcode < 0 || exitcode > 2)
+ return svn_error_createf
+ (SVN_ERR_EXTERNAL_PROGRAM, 0, NULL, pool,
+ "Error running %s.", SVN_CLIENT_DIFF);
/* TODO: Handle exit code == 2 (i.e. diff error) here. */
--
garrett rooney Unix was not designed to stop you from
rooneg@electricjellyfish.net doing stupid things, because that would
http://electricjellyfish.net/ stop you from doing clever things.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:55 2006