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

Re: hook-scripts & .bat files

From: Mark Bohlman <mbohlman_at_tcicredit.com>
Date: 2004-09-09 16:34:20 CEST

Steven Higgan wrote:
> Ok SOMEBODY must have came up against this one so here goes.
>
> What I am trying to do is fire off a hook script from a .bat file, I THINK I
> have got most of the syntax right (at least from what I have read) but iam
> having trouble trying to figure out how to assign a variable a result from
> an operation eg::
>
> <from post-commit.bat>
> SET REPOS=%1
> SET REV=%2
> SET LOG=`D:\INSTALLS\Subversion\bin\svnlook log -r %REV% %REPOS%`
> SET AUTHOR=`D:\INSTALLS\Subversion\bin\svnlook author -r %REV% %REPOS%`
> SET TRAC_ENV='D:\MEDIA\DB-TRAC\cfl.db'
>
> D:\INSTALLS\Python\Python.exe
> D:\MEDIA\DB-SVN\c.f.l\hooks\trac-post-commit-hook -p %TRAC_ENV% -r %REV% -u
> %AUTHOR% -m %LOG%
>
> SET REPOS=
> SET REV=
> SET LOG=
> SET AUTHOR=
> SET TRAC_ENV=
>
> So how would I assign the value of LOG to be what svnlook returns?
>
> If I can get it right I might even be able to submit a patch to the dev list
> to provide examples of how us windows weenies can run hook scripts from bat
> files.
>
> ---------------------------------------------------------------------------
> Steven H - 3rd Year B.I.T. Otago Polytechnic, Dunedin New Zealand

I think the problem is that you are trying to use the back-ticks '`' for
evaluation within a .bat file and the cmd.exe or command.exe
interpreters do not understand that. You probably end up with the value
of LOG as the string:
"D:\INSTALLS\Subversion\bin\svnlook log -r %REV% %REPOS%"

The back tics work if this was perl, which is a "normal" way of doing
the hook scripts. Call the xxx-commit.bat from the svn code, and the
.bat file calls a perl script that does the "real" work. As in:
post-commit.bat:
    @echo off
    path_to_perl.exe post-commit.pl %REV% %REPOS%
    if errorlevel 1 goto bad_exit_label
    goto good_exit_label
    ...

post-commit.pl
    #pseudo-code
    parse_args
    my $rc = `svnlook ....`
    # look for problems
    # return 0 or other value if not ok
    ...

DOS does not do well for scripting (even tho many people have some
extensive efforts out there).

HTH
-- Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Sep 9 16:35:10 2004

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