[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Subversion - .wsf hook scripts on Windows

From: Chris Foote <cafoote_at_yahoo.com>
Date: 2007-01-20 02:55:29 CET

Lieven Govaerts wrote:
>
> Andy Levy wrote:
> > Attached is a WSF script which iterates through all unnamed arguments
> > passed in and appends them to a textfile c:\hook.txt. It then iterates
> > through named arguments and does the same. It's not particularly
> > "clean" or elegant, but it gets the job done.
> I tried your script, but can't get it to run as a hook. I've made a few
> changes to the code to see if those fix the problem: translating the
> path to local style and changing some of the options used to create the
> process, but none of those changes fixed anything.
>
> I can only conclude that with the current code svn can only trigger hook
> scripts in formats supported by the shell, but none that need an
> external interpreter (cscript, python, perl), even if PATHEXT/ftype is
set.
>
> Lieven

Hi Lieven,

If you try the following patch (just a quick hack to test),
it should run the hook script. I'm not sure if .wsf needs to be
in PATHEXT, but I would expect so (it is in mine).
The hook fails, but that is expected as the exit code is 1.

C:\junk>svn ci -m "wsf test using the shell"
Sending test.txt
Transmitting file data .svn: Commit failed (details follow):
svn: MERGE request failed on '/repos/junk/trunk'
svn: 'pre-commit' hook failed with error output:

Looking into apr, it tries to execute the program directly unless it ends
in .cmd or .bat when using APR_PROGRAM(_PATH).

Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c (revision 23008)
+++ subversion/libsvn_subr/io.c (working copy)
@@ -1995,16 +1995,28 @@
   int num_args;
   const char **args_native;
   const char *cmd_apr;
+ int i;

   /* Create the process attributes. */
   apr_err = apr_procattr_create(&cmdproc_attr, pool);
   if (apr_err)
     return svn_error_wrap_apr
       (apr_err, _("Can't create process '%s' attributes"), cmd);
-
- /* Make sure we invoke cmd directly, not through a shell. */
- apr_err = apr_procattr_cmdtype_set(cmdproc_attr,
-
inherit?APR_PROGRAM_PATH:APR_PROGRAM);
+
+#ifdef WIN32
+ i = strlen(cmd);
+ if (i >= 4 && strcasecmp(cmd + i - 4, ".wsf") == 0)
+ {
+ /* Invoke cmd through the shell. */
+ apr_err = apr_procattr_cmdtype_set(cmdproc_attr, APR_SHELLCMD);
+ }
+ else
+#endif
+ {
+ /* Make sure we invoke cmd directly, not through a shell. */
+ apr_err = apr_procattr_cmdtype_set(cmdproc_attr,
+
inherit?APR_PROGRAM_PATH:APR_PROGRAM);

+ }
   if (apr_err)
     return svn_error_wrap_apr(apr_err, _("Can't set process '%s'
cmdtype"),
                               cmd);

Hope this helps.

Chris

                
___________________________________________________________
Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 20 02:55:55 2007

This is an archived mail posted to the Subversion Dev mailing list.