(svn r14242) -Fix: removed some possible infinite loop in version determination (again).

This commit is contained in:
glx 2008-09-04 15:27:21 +00:00
parent 8ca4d34aad
commit 199a53c4ca

View File

@ -138,39 +138,42 @@ Function DetermineSVNVersion()
' Reset error and version ' Reset error and version
Err.Clear Err.Clear
version = "norev000" version = "norev000"
' Set the environment to english
WshShell.Environment("PROCESS")("LANG") = "en"
' Do we have subversion installed? Check immediatelly whether we've got a modified WC. ' Do we have subversion installed? Check immediatelly whether we've got a modified WC.
Set oExec = WshShell.Exec("svnversion ../src") Set oExec = WshShell.Exec("svnversion ../src")
If Err.Number = 0 Then If Err.Number = 0 Then
' Wait till the application is finished ... ' Wait till the application is finished ...
Do While oExec.Status = 0 Do While oExec.Status = 0
Loop Loop
End If
If Err.Number = 0 And oExec.ExitCode = 0 Then
Dim modified
If InStr(OExec.StdOut.ReadLine(), "M") Then
modified = "M"
Else
modified = ""
End If
' Set the environment to english line = OExec.StdOut.ReadLine()
WshShell.Environment("PROCESS")("LANG") = "en" If line <> "exported" Then
Dim modified
If InStr(line, "M") Then
modified = "M"
Else
modified = ""
End If
' And use svn info to get the correct revision and branch information. ' And use svn info to get the correct revision and branch information.
Set oExec = WshShell.Exec("svn info ../src") Set oExec = WshShell.Exec("svn info ../src")
If Err.Number = 0 Then If Err.Number = 0 Then
Do Do
line = OExec.StdOut.ReadLine() line = OExec.StdOut.ReadLine()
If InStr(line, "URL") Then If InStr(line, "URL") Then
url = line url = line
End If End If
If InStr(line, "Last Changed Rev") Then If InStr(line, "Last Changed Rev") Then
version = "r" & Mid(line, 19) & modified version = "r" & Mid(line, 19) & modified
End If End If
Loop While Not OExec.StdOut.atEndOfStream Loop While Not OExec.StdOut.atEndOfStream
End If End If ' Err.Number = 0
End If End If ' line <> "exported"
End If End If ' Err.Number = 0
End If ' InStr(version, "$")
If version <> "norev000" Then If version <> "norev000" Then
If InStr(url, "branches") Then If InStr(url, "branches") Then
@ -178,7 +181,7 @@ Function DetermineSVNVersion()
url = Mid(url, 1, InStr(2, url, "/") - 1) url = Mid(url, 1, InStr(2, url, "/") - 1)
version = version & Replace(url, "/", "-") version = version & Replace(url, "/", "-")
End If End If
Else Else ' version <> "norev000"
' svn detection failed, reset error and try git ' svn detection failed, reset error and try git
Err.Clear Err.Clear
Set oExec = WshShell.Exec("git rev-parse --verify --short=8 HEAD") Set oExec = WshShell.Exec("git rev-parse --verify --short=8 HEAD")
@ -186,56 +189,65 @@ Function DetermineSVNVersion()
' Wait till the application is finished ... ' Wait till the application is finished ...
Do While oExec.Status = 0 Do While oExec.Status = 0
Loop Loop
End If
If Err.Number = 0 And oExec.ExitCode = 0 Then
version = "g" & oExec.StdOut.ReadLine()
Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../src")
Do While oExec.Status = 0 And Err.Number = 0
Loop
If Err.Number = 0 And oExec.ExitCode = 1 Then
version = version & "M"
End If
Set oExec = WshShell.Exec("git symbolic-ref HEAD") If oExec.ExitCode = 0 Then
If Err.Number = 0 Then version = "g" & oExec.StdOut.ReadLine()
line = oExec.StdOut.ReadLine() Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../src")
line = Mid(line, InStrRev(line, "/") + 1) If Err.Number = 0 Then
If line <> "master" Then ' Wait till the application is finished ...
version = version & "-" & line Do While oExec.Status = 0
End If Loop
End If
Else If oExec.ExitCode = 1 Then
' try mercurial (hg) version = version & "M"
End If ' oExec.ExitCode = 1
Set oExec = WshShell.Exec("git symbolic-ref HEAD")
If Err.Number = 0 Then
line = oExec.StdOut.ReadLine()
line = Mid(line, InStrRev(line, "/") + 1)
If line <> "master" Then
version = version & "-" & line
End If ' line <> "master"
End If ' Err.Number = 0
End If ' Err.Number = 0
End If ' oExec.ExitCode = 0
End If ' Err.Number = 0
If version = "norev000" Then
' git detection failed, reset error and try mercurial (hg)
Err.Clear Err.Clear
Set oExec = WshShell.Exec("hg tip") Set oExec = WshShell.Exec("hg tip")
If Err.Number = 0 Then If Err.Number = 0 Then
' Wait till the application is finished ... ' Wait till the application is finished ...
Do While oExec.Status = 0 Do While oExec.Status = 0
Loop Loop
End If
If Err.Number = 0 And oExec.ExitCode = 0 Then If oExec.ExitCode = 0 Then
line = OExec.StdOut.ReadLine() line = OExec.StdOut.ReadLine()
version = "h" & Mid(line, InStrRev(line, ":") + 1, 8) version = "h" & Mid(line, InStrRev(line, ":") + 1, 8)
Set oExec = WshShell.Exec("hg status ../src") Set oExec = WshShell.Exec("hg status ../src")
If Err.Number = 0 Then If Err.Number = 0 Then
Do Do
line = OExec.StdOut.ReadLine() line = OExec.StdOut.ReadLine()
If Len(line) > 0 And Mid(line, 1, 1) <> "?" Then If Len(line) > 0 And Mid(line, 1, 1) <> "?" Then
version = version & "M" version = version & "M"
Exit Do Exit Do
End If End If ' Len(line) > 0 And Mid(line, 1, 1) <> "?"
Loop While Not OExec.StdOut.atEndOfStream Loop While Not OExec.StdOut.atEndOfStream
End If
Set oExec = WshShell.Exec("hg branch") Set oExec = WshShell.Exec("hg branch")
If Err.Number = 0 Then If Err.Number = 0 Then
line = OExec.StdOut.ReadLine() line = OExec.StdOut.ReadLine()
If line <> "default" Then If line <> "default" Then
version = version & "-" & line version = version & "-" & line
End If End If ' line <> "default"
End If End If ' Err.Number = 0
End If End If ' Err.Number = 0
End If End If ' oExec.ExitCode = 0
End If End If ' Err.Number = 0
End If ' version = "norev000"
End If ' version <> "norev000"
DetermineSVNVersion = version DetermineSVNVersion = version
End Function End Function