On Tue, Oct 23, 2001 at 04:18:17PM -0500, kfogel@collab.net wrote:
> I know these are small patches, but could you guys each write a log
> message & post, so we can more easily see the difference between these
> two solutions?
OK, here is take two. The is a slightly improved patch, taking
advantage of the fact that we can pass NULL when we don't care
about the values.
Matt
* subversion/include/svn_io.h
Include apr_thread_proc.h.
(svn_io_run_cmd): Remove status parameter and add exitcode and
exitwhy parameters.
* subversion/libsvn_wc/log.c
(log_do_run_cmd): Update call to svn_io_run_cmd.
* subversion/libsvn_wc/get_editor.c
(close_file): Update call to apr_proc_wait.
* subversion/libsvn_subr/io.c
(svn_io_run_cmd): Remove status parameter and add exitcode and
exitwhy parameters. Update call to apr_proc_wait.
* subversion/svnlook/main.c
(print_diff_tree): Update call to svn_io_run_cmd.
* subversion/clients/cmdline/diff.c
(svn_cl__print_file_diff): Update call to svn_io_run_cmd.
* subversion/libsvn_repos/hooks.c
(run_cmd_with_output): Remove status parameter and add exitcode
and exitwhy parameters. Update call to svn_io_run_cmd.
(run_start_commit_hook): Update call to run_cmd_with_output.
(run_pre_commit_hook): Update call to run_cmd_with_output.
Check exitwhy to ensure process exited normally.
(run_post_commit_hook): Update call to run_cmd_with_output.
Index: ./subversion/include/svn_io.h
===================================================================
--- ./subversion/include/.svn/text-base/svn_io.h Tue Oct 23 11:43:06 2001
+++ ./subversion/include/svn_io.h Tue Oct 23 15:32:48 2001
@@ -25,6 +25,7 @@
#include <apr.h>
#include <apr_pools.h>
#include <apr_file_io.h>
+#include <apr_thread_proc.h>
#include "svn_types.h"
#include "svn_error.h"
@@ -270,14 +271,16 @@
Connect PROGRAM's stdin, stdout, and stderr to INFILE, OUTFILE, and
ERRFILE, except where they are null.
- STATUS will contain the exit code of the process upon return.
-
+ EXITCODE will contain the exit code of the process upon return, and
+ EXITWHY will indicate why the process terminated.
+
ARGS is a list of (const char *)'s, terminated by NULL. ARGS[0] is
the name of the program, though it need not be the same as CMD. */
svn_error_t *svn_io_run_cmd (const char *path,
const char *cmd,
const char *const *args,
- apr_wait_t *status,
+ int *exitcode,
+ apr_exit_why_e *exitwhy,
apr_file_t *infile,
apr_file_t *outfile,
apr_file_t *errfile,
Index: ./subversion/libsvn_wc/log.c
===================================================================
--- ./subversion/libsvn_wc/.svn/text-base/log.c Tue Oct 23 11:42:41 2001
+++ ./subversion/libsvn_wc/log.c Tue Oct 23 15:24:43 2001
@@ -142,7 +142,6 @@
{
svn_error_t *err;
apr_status_t apr_err;
- apr_wait_t status;
const char
*infile_name,
*outfile_name,
@@ -219,7 +218,7 @@
"error opening %s", errfile_path->data);
}
- err = svn_io_run_cmd (loggy->path->data, name, args, &status,
+ err = svn_io_run_cmd (loggy->path->data, name, args, NULL, NULL,
infile, outfile, errfile, loggy->pool);
if (err)
return svn_error_createf (SVN_ERR_WC_BAD_ADM_LOG, 0, NULL, loggy->pool,
Index: ./subversion/libsvn_wc/get_editor.c
===================================================================
--- ./subversion/libsvn_wc/.svn/text-base/get_editor.c Tue Oct 23 11:42:39 2001
+++ ./subversion/libsvn_wc/get_editor.c Tue Oct 23 12:29:33 2001
@@ -1276,7 +1276,7 @@
"close_file: error starting diff process");
/* Wait for the diff command to finish. */
- apr_err = apr_proc_wait (&diff_proc, NULL, APR_WAIT);
+ apr_err = apr_proc_wait (&diff_proc, NULL, NULL, APR_WAIT);
if (APR_STATUS_IS_CHILD_NOTDONE (apr_err))
return svn_error_createf
(apr_err, 0, NULL, fb->pool,
Index: ./subversion/libsvn_subr/io.c
===================================================================
--- ./subversion/libsvn_subr/.svn/text-base/io.c Tue Oct 23 11:42:36 2001
+++ ./subversion/libsvn_subr/io.c Tue Oct 23 12:34:28 2001
@@ -788,7 +788,8 @@
svn_io_run_cmd (const char *path,
const char *cmd,
const char *const *args,
- apr_wait_t *status,
+ int *exitcode,
+ apr_exit_why_e *exitwhy,
apr_file_t *infile,
apr_file_t *outfile,
apr_file_t *errfile,
@@ -872,7 +873,7 @@
cmd);
/* Wait for the cmd command to finish. */
- apr_err = apr_proc_wait (&cmd_proc, status, APR_WAIT);
+ apr_err = apr_proc_wait (&cmd_proc, exitcode, exitwhy, APR_WAIT);
if (APR_STATUS_IS_CHILD_NOTDONE (apr_err))
return svn_error_createf
(apr_err, 0, NULL, pool,
Index: ./subversion/svnlook/main.c
===================================================================
--- ./subversion/svnlook/.svn/text-base/main.c Tue Oct 23 11:42:25 2001
+++ ./subversion/svnlook/main.c Tue Oct 23 15:26:19 2001
@@ -468,7 +468,6 @@
{
const char *args[5];
apr_file_t *outhandle;
- apr_wait_t status;
apr_status_t apr_err;
printf ("%s: %s\n",
@@ -494,10 +493,10 @@
(apr_err, 0, NULL, pool,
"print_diff_tree: can't open handle to stdout");
- SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, &status,
+ SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, NULL, NULL,
NULL, outhandle, NULL, pool));
- /* TODO: Handle status == 2 (i.e. diff error) here. */
+ /* TODO: Handle exit code == 2 (i.e. diff error) here. */
printf ("\n");
fflush (stdout);
Index: ./subversion/clients/cmdline/diff.c
===================================================================
--- ./subversion/clients/cmdline/.svn/text-base/diff.c Tue Oct 23 11:41:22 2001
+++ ./subversion/clients/cmdline/diff.c Tue Oct 23 15:26:59 2001
@@ -107,7 +107,6 @@
apr_status_t status;
svn_stringbuf_t *pristine_copy_path;
svn_boolean_t text_is_modified = FALSE;
- apr_wait_t proc_status;
const char **args;
int i = 0;
@@ -159,10 +158,10 @@
apr_file_printf (outhandle, "Index: %s\n", path->data);
apr_file_printf (outhandle, "===================================================================\n");
- SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, &proc_status,
+ SVN_ERR(svn_io_run_cmd (".", SVN_CLIENT_DIFF, args, NULL, NULL,
NULL, outhandle, NULL, pool));
- /* TODO: Handle proc_status == 2 (i.e. errors with diff) here */
+ /* TODO: Handle exit code == 2 (i.e. errors with diff) here */
/* TODO: someday we'll need to worry about two things here:
Index: ./subversion/libsvn_repos/hooks.c
===================================================================
--- ./subversion/libsvn_repos/.svn/text-base/hooks.c Tue Oct 23 11:40:44 2001
+++ ./subversion/libsvn_repos/hooks.c Tue Oct 23 15:28:38 2001
@@ -40,7 +40,8 @@
static svn_error_t *
run_cmd_with_output (const char *cmd,
const char **args,
- apr_wait_t *status,
+ int *exitcode,
+ apr_exit_why_e *exitwhy,
apr_pool_t *pool)
{
apr_file_t *outhandle, *errhandle;
@@ -58,7 +59,7 @@
(apr_err, 0, NULL, pool,
"run_cmd_with_output: can't open handle to stderr");
- return svn_io_run_cmd (".", cmd, args, status, NULL, outhandle,
+ return svn_io_run_cmd (".", cmd, args, exitcode, exitwhy, NULL, outhandle,
errhandle, pool);
}
@@ -76,7 +77,6 @@
if ((! svn_io_check_path (svn_stringbuf_create (hook, pool), &kind, pool))
&& (kind == svn_node_file))
{
- apr_wait_t status;
svn_error_t *err;
const char *args[4];
@@ -85,7 +85,7 @@
args[2] = user;
args[3] = NULL;
- if ((err = run_cmd_with_output (hook, args, &status, pool)))
+ if ((err = run_cmd_with_output (hook, args, NULL, NULL, pool)))
{
return svn_error_createf
(SVN_ERR_REPOS_HOOK_FAILURE, 0, err, pool,
@@ -111,7 +111,8 @@
&& (kind == svn_node_file))
{
svn_error_t *err;
- apr_wait_t status;
+ int exitcode;
+ apr_exit_why_e exitwhy;
const char *args[4];
args[0] = hook;
@@ -119,13 +120,13 @@
args[2] = txn_name;
args[3] = NULL;
- if ((err = run_cmd_with_output (hook, args, &status, pool)))
+ if ((err = run_cmd_with_output (hook, args, &exitcode, &exitwhy, pool)))
{
return svn_error_createf
(SVN_ERR_REPOS_HOOK_FAILURE, 0, err, pool,
"run_pre_commit_hook: error running cmd `%s'", hook);
}
- if (status != 0)
+ if (! APR_PROC_CHECK_EXIT (exitwhy) || exitcode != 0)
{
return svn_error_create
(SVN_ERR_REPOS_HOOK_FAILURE, 0, err, pool,
@@ -151,7 +152,6 @@
&& (kind == svn_node_file))
{
svn_error_t *err;
- apr_wait_t status;
const char *args[4];
args[0] = hook;
@@ -159,7 +159,7 @@
args[2] = apr_psprintf (pool, "%lu", rev);
args[3] = NULL;
- if ((err = run_cmd_with_output (hook, args, &status, pool)))
+ if ((err = run_cmd_with_output (hook, args, NULL, NULL, pool)))
{
return svn_error_createf
(SVN_ERR_REPOS_HOOK_FAILURE, 0, err, pool,
---------------------------------------------------------------------
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:45 2006