+ Reply to Thread
Results 1 to 2 of 2

Thread: How to use TortoiseSVN and TortoiseGit with SetupBuilder

  1. #1

    Default How to use TortoiseSVN and TortoiseGit with SetupBuilder

    Having SetupBuilder Project Files and Include Scripts in source control is great. It did however require that you made a good commit message that described exactly what changes you have made in the files and why. You had no way to show the difference from the files itself as they are projected by an encryption. With the new release of SetupBuilder it is now possible to extract read friendly text version files of the Project Files and Include Scripts from the command line. This makes it possible to integrate to source control applications like TortoiseSVN and TortoiseGit. And as a side bonus you are now free to make commit messages that only describes the "why" and omit the "how" description when committing changes to SetupBuilder Project Files and Include Scripts.

    Here is a Diff-Script file that you can use to integrate TortoiseSVN and TortoiseGit. It uses Beyond Compare from Scooter Software to show the differences but you can use what ever you would like instead. The Diff-Script file is open source and you may use it as you please.

    Diff-Script file for TortoiseSVN and TortoiseGit: Attachment 4494

    Download and unzip the Diff-Script file. It can be used for both TortoiseSVN and TortoiseGit.

    How to setup in TortoiseSVN

    Copy the unzipped diff-sbp.vbs Diff-Script file into the Diff-Scripts subfolder in the TortoiseSVN installation folder i.e. c:\Program Files\TortoiseSVN\Diff-Scripts.

    Right click on an empty space at the desktop and select TortoiseSVN and Settings.
    Name:  2017-03-27 13_41_33-.png
Views: 391
Size:  65.9 KB

    Select Diff Viewer from the Treeview and select the Advanced... button.
    Name:  2017-03-27 13_44_20-SetupBuilder.png
Views: 464
Size:  43.4 KB

    Click the Add... button and fill out the extention field with ".sbp" and use this line for External Program:
    Code:
    wscript.exe "C:\Program Files\TortoiseSVN\Diff-Scripts\diff-sbp.vbs" %base %mine %bname %yname //E:vbscript
    (Correct for 32 bit if necessary)
    Name:  2017-03-27 13_50_08-.png
Views: 411
Size:  20.2 KB

    Make another entry for the ".sbi" extension.

    The Advanced diff settings should now look like this:
    Name:  2017-03-27 13_47_21-.png
Views: 391
Size:  58.1 KB

    Click the OK button to save the changes.

    That's it!

    Now you can use TortoiseSVN to compare the differences between two revisions in a subversion repository. Here is an example where the difference is shown using Beyond Compare 4. It shows that the difference for the SetupBuilder Project File "Template.sbp" between revision 28963 and revision 28964 is a change on the Handle String Operation. Here the operation "Split Source String at First Occurrence of Search String" has been replaced with the operation "Split Source String at Last Occurrence of Search String".
    Name:  2017-03-27 13_57_14-.png
Views: 399
Size:  115.4 KB


    How to setup in TortoiseGit

    The setup is the same procedure as with TortoiseSVN. Just change the destination path for the Diff-Script file to the Diff-Scripts subfolder in the TortoiseGit installation folder i.e. c:\Program Files\TortoiseGit\Diff-Scripts\ and in the path for External Program i.e.
    Code:
    wscript.exe "C:\Program Files\TortoiseGit\Diff-Scripts\diff-sbp.vbs" %base %mine %bname %yname //E:vbscript

    diff-sbp.vbs

    Code:
    '
    ' TortoiseSVN Diff script for Lindersoft SetupBuilder Project Files and Include Scripts
    '
    ' Authors:
    ' Allan Greis Eriksen, NOVAX, 2016-2017
    ' (Based on diff-nb.vbs)
    
    Const sb10 = "c:\Program Files (x86)\Lindersoft\SetupBuilder 10 Developer\SB10.EXE"
    Const bc4 = "C:\Program Files\Beyond Compare 4\BComp.exe"
    
    dim objArgs, objScript
    
    Set objArgs = WScript.Arguments
    num = objArgs.Count
    if num < 2 then
        MsgBox "Usage: [CScript | WScript] diff-sbp.vbs base.sbp new.sbp", vbExclamation, "Invalid arguments"
        WScript.Quit 1
    end if
    
    sBaseFile = objArgs(0)
    sNewFile = objArgs(1)
    
    Dim SourceControl
    Dim WindowTitleBase, WindowTitleNew
    if num = 4 then
        ' If used with TortoiseSVN/TortoiseGit
        SourceControl = 1
        WindowTitleBase = objArgs(2)
        WindowTitleNew = objArgs(3)
    Else
        SourceControl = 0
        WindowTitleBase = sBaseFile
        WindowTitleNew = sNewFile
    end if
    
    Set objScript = CreateObject("Scripting.FileSystemObject")
    Set objShell2 = CreateObject("Scripting.FileSystemObject")
    Set objShell3 = CreateObject("Scripting.FileSystemObject")
    
    If objScript.FileExists(sBaseFile) = False Then
        MsgBox "File " & sBaseFile & " does not exist.  Cannot compare the SetupBuilder projects.", vbExclamation, "File not found"
        Wscript.Quit 1
    Else
        sBaseFile = objScript.GetAbsolutePathName(sBaseFile)
    End If
    If objScript.FileExists(sNewFile) = False Then
        MsgBox "File " & sNewFile & " does not exist.  Cannot compare the SetupBuilder projects.", vbExclamation, "File not found"
        Wscript.Quit 1
    Else
         sNewFile = objScript.GetAbsolutePathName(sNewFile)
    End If
    
    'On Error Resume Next
    Dim tfolder, tnameBase, tnameNew
    Dim tBaseFile, tNewFile
    Dim oExec1, oExec2, oExecBC
    Dim iTimeout
    Const TemporaryFolder = 2
    
    Set tfolder = objScript.GetSpecialFolder(TemporaryFolder)
    
    tnameBase = objScript.GetTempName & "_base.txt"
    tBaseFile = tfolder & "\" & tnameBase
    tnameNew = objScript.GetTempName & "_new.txt"
    tNewFile = tfolder & "\" & tnameNew
    
    Set objShell = CreateObject("WScript.Shell")
    cmdline = sb10 & " /SAT """ & sBaseFile & """ /F """ & tBaseFile & """"
    Set oExec1 = objShell.Exec(cmdline)
    
    Set objShell2 = CreateObject("WScript.Shell")
    cmdline2 = sb10 & " /SAT """ & sNewFile & """ /F """ & tNewFile & """"
    Set oExec2 = objShell2.Exec(cmdline2)
    
    ' Wait for SetupBuilder to extract the text file.
    iTimeout = 600	' Wait max. 30 second
    Do While ((oExec1.Status = 0) And (iTimeout > 0))
         WScript.Sleep 50
    	 iTimeout = iTimeout - 1
    Loop
    If iTimeout = 0 then
    	MsgBox "Error extracting to " & tBaseFile
    	Wscript.Quit 1
    End If
    iTimeout = 600 ' Wait max. 30 seconds
    Do While ((oExec2.Status = 0) and (iTimeout > 0))
         WScript.Sleep 50
    	 iTimeout = iTimeout - 1
    Loop
    If iTimeout = 0 then
    	MsgBox "Error extracting to " + tNewFile
    	Wscript.Quit 1
    End If
    
    ' Show the differences with Beyond Compare
    Set objShell3 = CreateObject("WScript.Shell")
    cmdline3 = bc4 + " """ + tBaseFile + """ """ + tNewFile + """ /title1=""" + WindowTitleBase + """ /title2=""" + WindowTitleNew + """ /readonly"
    Set oExecBC = objShell.Exec(cmdline3)
    
    ' Wait for Beyond Compare to be closed
    iTimeout = 3600 ' Wait max. one hour
    Do While ((oExecBC.Status = 0) and (iTimeout > 0))
         WScript.Sleep 1000
         iTimeout = iTimeout - 1
    Loop
    If iTimeout = 0 then
        Wscript.Quit 0
    End If
    
    ' Remove the extracted text files.
    If objScript.FileExists(tBaseFile) then
        objScript.DeleteFile(tBaseFile)    
    End If
    If objScript.FileExists(tNewFile) Then
        objScript.DeleteFile(tNewFile)    
    End If
    Hope you can use it! Please post comments, improvements and error reports in this thread.

    Allan

  2. #2
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: How to use TortoiseSVN and TortoiseGit with SetupBuilder

    Wow! Very interesting. Thanks so much for sharing this, Allan.

    Friedrich

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •