From f06261e712be2a3c1356f85a02ddbab4ad5b7d45 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 5 Nov 2012 21:11:45 +0000 Subject: [PATCH] make subwcrev process more reliable --- SubWCRev.bat | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/SubWCRev.bat b/SubWCRev.bat index 927371554e..06abfe3eac 100755 --- a/SubWCRev.bat +++ b/SubWCRev.bat @@ -1,34 +1,43 @@ @echo off -set TEMPFILE="%TEMP%-%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%" +set TEMPFILE="%TEMP%\BIZBUILD-SVN-%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%" set SVNREV="%~1properties\svnrev.cs" -rem generate a wvnrev with sed using no revision number, in case svn isnt available -@"%~1..\sed.exe" s/\$WCREV\$/0/ < "%~1properties\svnrev_template" > %TEMPFILE% - rem try generating svnrev from svn now. this will fail if svn is nonexistent, so... -@"%~1..\SubWCRev.exe" "%~1\.." "%~1properties\svnrev_template" %TEMPFILE% > nul +"%~1..\SubWCRev.exe" "%~1\.." "%~1properties\svnrev_template" %TEMPFILE% > nul + +rem generate a svnrev with sed using no revision number, in case svn isnt available +if not exist %TEMPFILE% ( + "%~1..\sed.exe" s/\$WCREV\$/0/ < "%~1properties\svnrev_template" > %TEMPFILE% +) rem ... ignore the error SET ERRORLEVEL=0 + + rem if we didnt even have a svnrev, then go ahead and copy it if not exist %SVNREV% ( - @copy /y %TEMPFILE% %SVNREV% + copy /y %TEMPFILE% %SVNREV% ) else if exist %TEMPFILE% ( rem check to see whether its any different, so we dont touch unchanged files fc /b %TEMPFILE% %SVNREV% > nul - if %ERRORLEVEL% neq 0 ( - echo Updated svnrev file - @copy /y %TEMPFILE% %SVNREV% - ) else ( + if ERRORLEVEL 0 ( echo Not touching unchanged svnrev file ) + if ERRORLEVEL 1 ( + echo Updated svnrev file + @copy /y %TEMPFILE% %SVNREV% + ) + if ERRORLEVEL 2 ( + echo Updated svnrev file + @copy /y %TEMPFILE% %SVNREV% + ) ) else ( echo Ran into a weird error writing subwcrev output to tempfile: %TEMPFILE% ) -del %TEMPFILE% +rem del %TEMPFILE% rem always let build proceed SET ERRORLEVEL=0 \ No newline at end of file