summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-10-23 02:52:11 +0000
committerglx <glx@openttd.org>2008-10-23 02:52:11 +0000
commit2af314553c4a5ce54533d298cc85455fb9b8bac4 (patch)
tree21ddae839bb772710fa38178f042465f49c7eda8
parentf28957bcc40442b1cb88a03e3d4c5f4e7b1cd6cd (diff)
downloadopenttd-2af314553c4a5ce54533d298cc85455fb9b8bac4.tar.xz
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
-rwxr-xr-xprojects/determineversion.vbs108
1 files changed, 61 insertions, 47 deletions
diff --git a/projects/determineversion.vbs b/projects/determineversion.vbs
index 301f3097e..39ac7bf8a 100755
--- a/projects/determineversion.vbs
+++ b/projects/determineversion.vbs
@@ -23,36 +23,18 @@ Sub UpdateFile(modified, revision, version, cur_date, filename)
End Sub
Sub UpdateFiles(version)
- Dim WshShell, cur_date, modified, revision, oExec
- Set WshShell = CreateObject("WScript.Shell")
+ Dim modified, revision, cur_date
cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
- revision = 0
- modified = 1
- Select Case Mid(version, 1, 1)
- Case "r" ' svn
- revision = Mid(version, 2)
- If InStr(revision, "M") Then
- revision = Mid(revision, 1, InStr(revision, "M") - 1)
- modified = 2
- Else
- modified = 0
- End If
- If InStr(revision, "-") Then
- revision = Mid(revision, 1, InStr(revision, "-") - 1)
- End If
- Case "h" ' mercurial (hg)
- Set oExec = WshShell.Exec("hg log -r " & Mid(version, 2, 8) & ":0 -k " & Chr(34) & "svn" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc}\n" & Chr(34) & " ../src")
- If Err.Number = 0 Then
- revision = Mid(OExec.StdOut.ReadLine(), 7)
- revision = Mid(revision, 1, InStr(revision, ")") - 1)
- End If
- Case "g" ' git
- Set oExec = WshShell.Exec("git log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 ../src")
- if Err.Number = 0 Then
- revision = Mid(oExec.StdOut.ReadLine(), 7)
- revision = Mid(revision, 1, InStr(revision, ")") - 1)
- End If
- End Select
+
+ If InStr(version, Chr(9)) Then
+ revision = Mid(version, InStr(version, Chr(9)) + 1)
+ revision = Mid(revision, 1, InStr(revision, Chr(9)) - 1)
+ modified = Mid(version, InStrRev(version, Chr(9)) + 1)
+ version = Mid(version, 1, InStr(version, Chr(9)) - 1)
+ Else
+ revision = 0
+ modified = 1
+ End If
UpdateFile modified, revision, version, cur_date, "../src/rev.cpp"
UpdateFile modified, revision, version, cur_date, "../src/ottdres.rc"
@@ -96,7 +78,7 @@ Function ReadRegistryKey(shive, subkey, valuename, architecture)
End Function
Function DetermineSVNVersion()
- Dim WshShell, version, url, oExec, line
+ Dim WshShell, version, branch, modified, revision, url, oExec, line, hash
Set WshShell = CreateObject("WScript.Shell")
On Error Resume Next
@@ -117,6 +99,8 @@ Function DetermineSVNVersion()
Set file = FSO.CreateTextFile("tsvn_tmp", -1, 0)
file.WriteLine "r$WCREV$$WCMODS?M:$"
file.WriteLine "$WCURL$"
+ file.WriteLine "$WCMODS?2:0$"
+ file.WriteLine "$WCREV$"
file.Close
Set oExec = WshShell.Exec(sTortoise & "\bin\SubWCRev.exe ../src tsvn_tmp tsvn_tmp")
' Wait till the application is finished ...
@@ -127,6 +111,8 @@ Function DetermineSVNVersion()
Set file = FSO.OpenTextFile("tsvn_tmp", 1, 0, 0)
version = file.ReadLine
url = file.ReadLine
+ modified = file.ReadLine
+ revision = file.ReadLine
file.Close
Set file = FSO.GetFile("tsvn_tmp")
@@ -138,6 +124,7 @@ Function DetermineSVNVersion()
' Reset error and version
Err.Clear
version = "norev000"
+ modified = 0
' Set the environment to english
WshShell.Environment("PROCESS")("LANG") = "en"
@@ -151,11 +138,8 @@ Function DetermineSVNVersion()
line = OExec.StdOut.ReadLine()
If line <> "exported" Then
- Dim modified
If InStr(line, "M") Then
- modified = "M"
- Else
- modified = ""
+ modified = 2
End If
' And use svn info to get the correct revision and branch information.
@@ -167,7 +151,8 @@ Function DetermineSVNVersion()
url = line
End If
If InStr(line, "Last Changed Rev") Then
- version = "r" & Mid(line, 19) & modified
+ revision = Mid(line, 19)
+ version = "r" & revision
End If
Loop While Not OExec.StdOut.atEndOfStream
End If ' Err.Number = 0
@@ -177,21 +162,21 @@ Function DetermineSVNVersion()
If version <> "norev000" Then
If InStr(url, "branches") Then
- url = Mid(url, InStr(url, "branches") + 8)
- url = Mid(url, 1, InStr(2, url, "/") - 1)
- version = version & Replace(url, "/", "-")
+ url = Mid(url, InStr(url, "branches/") + 9)
+ branch = Mid(url, 1, InStr(2, url, "/") - 1)
End If
Else ' version <> "norev000"
' svn detection failed, reset error and try git
Err.Clear
- Set oExec = WshShell.Exec("git rev-parse --verify --short=8 HEAD")
+ Set oExec = WshShell.Exec("git rev-parse --verify HEAD")
If Err.Number = 0 Then
' Wait till the application is finished ...
Do While oExec.Status = 0
Loop
If oExec.ExitCode = 0 Then
- version = "g" & oExec.StdOut.ReadLine()
+ hash = oExec.StdOut.ReadLine()
+ version = "g" & Mid(hash, 1, 8)
Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../src")
If Err.Number = 0 Then
' Wait till the application is finished ...
@@ -199,7 +184,7 @@ Function DetermineSVNVersion()
Loop
If oExec.ExitCode = 1 Then
- version = version & "M"
+ modified = 2
End If ' oExec.ExitCode = 1
Set oExec = WshShell.Exec("git symbolic-ref HEAD")
@@ -207,9 +192,15 @@ Function DetermineSVNVersion()
line = oExec.StdOut.ReadLine()
line = Mid(line, InStrRev(line, "/") + 1)
If line <> "master" Then
- version = version & "-" & line
+ branch = line
End If ' line <> "master"
End If ' Err.Number = 0
+
+ Set oExec = WshShell.Exec("git log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 ../src")
+ if Err.Number = 0 Then
+ revision = Mid(oExec.StdOut.ReadLine(), 7)
+ revision = Mid(revision, 1, InStr(revision, ")") - 1)
+ End If ' Err.Number = 0
End If ' Err.Number = 0
End If ' oExec.ExitCode = 0
End If ' Err.Number = 0
@@ -225,13 +216,14 @@ Function DetermineSVNVersion()
If oExec.ExitCode = 0 Then
line = OExec.StdOut.ReadLine()
- version = "h" & Mid(line, InStrRev(line, ":") + 1, 8)
+ hash = Mid(line, InStrRev(line, ":") + 1)
+ version = "h" & Mid(hash, 1, 8)
Set oExec = WshShell.Exec("hg status ../src")
If Err.Number = 0 Then
Do
line = OExec.StdOut.ReadLine()
If Len(line) > 0 And Mid(line, 1, 1) <> "?" Then
- version = version & "M"
+ modified = 2
Exit Do
End If ' Len(line) > 0 And Mid(line, 1, 1) <> "?"
Loop While Not OExec.StdOut.atEndOfStream
@@ -240,19 +232,37 @@ Function DetermineSVNVersion()
If Err.Number = 0 Then
line = OExec.StdOut.ReadLine()
If line <> "default" Then
- version = version & "-" & line
+ branch = line
End If ' line <> "default"
End If ' Err.Number = 0
+
+ Set oExec = WshShell.Exec("hg log -r " & hash & ":0 -k " & Chr(34) & "svn" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc}\n" & Chr(34) & " ../src")
+ If Err.Number = 0 Then
+ revision = Mid(OExec.StdOut.ReadLine(), 7)
+ revision = Mid(revision, 1, InStr(revision, ")") - 1)
+ End If ' Err.Number = 0
End If ' Err.Number = 0
End If ' oExec.ExitCode = 0
End If ' Err.Number = 0
End If ' version = "norev000"
End If ' version <> "norev000"
- DetermineSVNVersion = version
+ If modified = 2 Then
+ version = version & "M"
+ End If
+
+ If branch <> "" Then
+ version = version & "-" & branch
+ End If
+
+ If version <> "norev000" Then
+ DetermineSVNVersion = version & Chr(9) & revision & Chr(9) & modified
+ Else
+ DetermineSVNVersion = version
+ End If
End Function
-Function IsCachedVersion(version)
+Function IsCachedVersion(ByVal version)
Dim cache_file, cached_version
cached_version = ""
Set cache_file = FSO.OpenTextFile("../config.cache.version", 1, True, 0)
@@ -261,6 +271,10 @@ Function IsCachedVersion(version)
End If
cache_file.Close
+ If InStr(version, Chr(9)) Then
+ version = Mid(version, 1, Instr(version, Chr(9)) - 1)
+ End If
+
If version <> cached_version Then
Set cache_file = fso.CreateTextFile("../config.cache.version", True)
cache_file.WriteLine(version)