0

I have a slow running batch file that compiles a log of changes and then emails a user. I would like it not to cause the user's commits to perform slowly in TortoiseSVN.

@ECHO OFF
SET REPOS=%1
SET REV=%2
SET DIR=%REPOS%/hooks
SET PATH=%PATH%;%DIR%;C:\Utils 
SET WORKING_COPY=C:\path\to\local\copy\
SET SITENAME=MySiteName
SET SMTP_SERVER=11.11.11.11
SET [email protected]
SET [email protected]
SET SUBJECT=SVN Update - %SITENAME% - rev %REV% - %REPOS%

svn cleanup %WORKING_COPY%
svn update %WORKING_COPY%


ECHO The following changes were made to the code: > %DIR%/email.txt
ECHO. >> %DIR%/email.txt


svn log %WORKING_COPY% -v -r "%REV%" >> %DIR%/email.txt


svn diff %WORKING_COPY% -c "%REV%" --no-diff-deleted >> %DIR%/email.txt


sendEmail -s %SMTP_SERVER% -t %EMAIL_TO% -f %EMAIL_FROM% -u "%SUBJECT%" -o message-file=%DIR%/email.txt

I realised that this was running slowly, so I moved it to another file "email-changes.bat" and created a simple batch to call this batch asynchronously.

@ECHO OFF
#START %1\hooks\email-changes.bat %1 %2
echo 'fired' > %1\hooks\test.log

If I comment out the "START" line it runs and finishes instantly. If I remove the comment it takes forever to complete. I thought that should allow the post-commit to return to SVN quickly.

Is there any way I can get the code to not hang in Subversion, but still complete the emailing task in the background?

1
  • Yes looking at this, I should really go "post-commit > MSMQ > update & email" that way I won't get any nasty collisons if 2 people check in at once. Commented Apr 28, 2011 at 15:55

1 Answer 1

1

Try starting the real hook script in a separate process:

@ECHO OFF
cmd.exe /c START %1\hooks\email-changes.bat %1 %2
echo 'fired' > %1\hooks\test.log

if that doesn't work, find a tool that can start another bat file in a separate process/thread.

Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately, this didn't work - but big respect to you Stefan for all your work in TortoiseSVN.
According to this: stackoverflow.com/questions/2190944/… it should work: start cmd /c proc1.bat
Commenting out the cmd.exe line takes a few seconds to complete, but putting back in takes 1 minute 30 - and I always recieev the email before the command completes implying it's not working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.