Commits

Nathan Durnan  committed 15cba45 Merge

Merge with Release Beta 0.1

  • Participants
  • Parent commits ba59aa4, 4f95d70
  • Tags Beta 0.1.0.5

Comments (0)

Files changed (4)

File .hgtimestamp

-_HgPreBackup.au3,1325901532.92
-HgPreBackup_x86.exe,1325901523.0
-HgPreBackup_x64.exe,1325901530.05
+HgPreBackup.ico,1325031982.39
+HgPreBackup_x86.exe,1326140610.0
+HgPreBackup_x64.exe,1326140616.98
 .hgsub,1325791137.19
 HgPreBackupSettings.ini,1325896705.95
 .hgsubstate,1325791876.03
-.hgtags,1325901803.73
-HgPreBackup.ico,1325031982.39
+README.rst,1325791389.33
+_HgPreBackup.au3,1326140619.53
 HgPreBackup.svg,1325032006.66
 .hgignore,1325796114.66
-README.rst,1325791389.33
-.hgtimestamp,1325901803.75
+.hgtimestamp,1326140637.05

File HgPreBackup_x64.exe

Binary file modified.

File HgPreBackup_x86.exe

Binary file modified.

File _HgPreBackup.au3

 #AutoIt3Wrapper_Compression=4
 #AutoIt3Wrapper_Res_Comment=Automated tool to create/update Mercurial Repository clones for backups.
 #AutoIt3Wrapper_Res_Description=Mercurial Repository Pre-Backup Tool
-#AutoIt3Wrapper_Res_Fileversion=0.1.0.4
+#AutoIt3Wrapper_Res_Fileversion=0.1.0.6
 #AutoIt3Wrapper_Res_Field=FileVersion Notes|Beta Test
 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
 #AutoIt3Wrapper_Res_Language=1033
 Global Const $HG_OPT_CLONENOUPDATE = ' -U'	;Clone will have an empty working directory.
 Global Const $HG_OPT_CLONEPULL = ' --pull'	;Copy all metadata without creating hardlinks.
 
-Global $GS_SETTINGSFILENAME = 'HgPreBackupSettigns.ini'	;base name for settings file.
+Global $GS_SETTINGSFILENAME = 'HgPreBackupSettings.ini'	;base name for settings file.
 Global $GS_LOGFILENAME = 'HgPreBackup.log'	;base name for log file.
 
 ;***** Declare Variables *****
 	If FileExists($CmdLine[1]) Then
 		$Gs_SettingsPath = $CmdLine[1]
 	Else ;no valid file in argument.
-		$Gs_SettingsPath = $GS_SETTINGSFILENAME
+		$Gs_SettingsPath = $G_objFSO.BuildPath(@ScriptDir, $GS_SETTINGSFILENAME)
 	EndIf ;Check for settings file in arguments.
 Else ;no command line parameters
 	ConsoleWrite("No Command Line Params" & @CRLF)
-	$Gs_SettingsPath = $GS_SETTINGSFILENAME
+	$Gs_SettingsPath = $G_objFSO.BuildPath(@ScriptDir, $GS_SETTINGSFILENAME)
 EndIf ;Check command line argument for settings file specification
 ;Read in settings from file:
 _ReadGlobalSettings($Gs_SettingsPath)
 	_LogFileAddMessage($Gh_LogFile, "Searching for Repositories at " & $Gs_RepoHomeDir)
 	_SearchFolderForRepositories($Gs_RepoHomeDir, $Ga_RepoList, $Ga_RepoValidErr)
 	_LogFileAddMessage($Gh_LogFile, "* " & $Ga_RepoList[0] & "Repositories Found *")
-	#EndRegion - Evaluate Source Repositories	
+	#EndRegion - Evaluate Source Repositories
 	ConsoleWrite("========== Backup ==========" & @CRLF)
 	_LogFileAddMessage($Gh_LogFile, "Beginning Clone/Pull Operations")
 	;Check for backup directory:
 		;Update back to zero to clean out working directory for cleaner backups
 		_MercurialCommand( _
 			$HG_CMD_UPDATE & $HG_OPT_CLEAN & $HG_OPT_REPOSITORY, _
-			$sBackupPath, $HG_OPT_REVISION & ' 0') 
+			$sBackupPath, $HG_OPT_REVISION & ' 0')
 		#EndRegion - Backup Actions
 	Next ;$ii - loop through source repositories.
 	#Region - Evaluate Backup Repositories
 #EndRegion - Error Reporting
 ;Clean Up Log Folder Before Leaving...
 _LogFileRemoveOldLogs($Gs_LogFileDir, $Gi_KeepLogCount, $Gi_KeepLogDays)
+;Create settings file with validated settings if it doesn't exist.
+_CreateSettingsFile($Gs_SettingsPath)
 
 ;=End-of-Script========================================================
 
 ;******************************************************************************
 Func OnAutoItStart()
 	;MsgBox(0, "OnAutoItStart", "Script Starting...")
-	
+
 EndFunc
 
 ; #FUNCTION# ....:	OnAutoItExit **********************************************
 Func OnAutoItExit()
 	;MsgBox(0, "OnAutoItExit", "Script Ending...")
 	FileClose($Gh_LogFile)	;Should already happen, but just to be safe...
-	
+
 EndFunc
 
 #EndRegion AutoIt Functions
 ; =============================================================================
 #Region Support Functions
 
+; #FUNCTION# ....:	_CreateSettingsFile ***************************************
+; Date Added ....:	20120107
+; Author ........:	Nathan Durnan
+; Description ...:	Create default script settings INI file.
+; Remarks .......:	Intended to be called at END of script to pick up validated values.
+; Syntax ........:	_CreateSettingsFile($IN_sSettingsFilePath)
+; Parameters ....:	$IN_sSettingsFilePath - Path of INI file to create.
+; Return values .: N/A
+; *****************************************************************************
+
+Func _CreateSettingsFile( _
+		$IN_sSettingsFilePath)
+	Local $hFile, $myResult
+
+	If FileExists($IN_sSettingsFilePath) Then Return
+	$hFile = FileOpen($IN_sSettingsFilePath, ($FO_OVERWRITE + $FO_CREATEDIR))
+	ConsoleWrite("FileOpen: hFile, @error: " & $hFile & ', ' & @error & @CRLF)
+	$myResult = FileWriteLine($hFile, "; HgPreBackup Settings File")
+	$myResult = $myResult And FileWriteLine($hFile, "[paths]")
+	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
+	$myResult = $myResult And FileWriteLine($hFile, ";This section is where file paths are specified.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  hgPath .....: Command path for Mercurial application.")
+	$myResult = $myResult And FileWriteLine($hFile, ";                Typically just 'hg' if Mercurial is installed.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  RepoPath ...: Path to search for source repositories.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  BackupPath .: Path where backup repositories are to be located.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  LogPath ....: Path where log files are to be created.")
+	$myResult = $myResult And FileWriteLine($hFile, ";                Typically, this is the same as BackupPath.")
+	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
+	$myResult = $myResult And FileWriteLine($hFile, "hgPath = " & $Gs_HgPath)
+	$myResult = $myResult And FileWriteLine($hFile, "repopath = " & $Gs_RepoHomeDir)
+	$myResult = $myResult And FileWriteLine($hFile, "backuppath = " & $Gs_BackupDir)
+	$myResult = $myResult And FileWriteLine($hFile, "logpath = " & $Gs_BackupDir)
+	$myResult = $myResult And FileWriteLine($hFile, ";End of Paths")
+	$myResult = $myResult And FileWriteLine($hFile, "[settings]")
+	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
+	$myResult = $myResult And FileWriteLine($hFile, ";This section is where general preferences are specified.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  Report ..: Send email of log file if errors are encountered.")
+	$myResult = $myResult And FileWriteLine($hFile, ";             Expected Values: 'True' or 'False'")
+	$myResult = $myResult And FileWriteLine($hFile, ";                 True  -> send email with error report")
+	$myResult = $myResult And FileWriteLine($hFile, ";                 False -> no email")
+	$myResult = $myResult And FileWriteLine($hFile, ";             NOTE: When True, Email setting MUST be specified!!!")
+	$myResult = $myResult And FileWriteLine($hFile, ";  KeepLogCount ..: Keep at least this number of log files. ")
+	$myResult = $myResult And FileWriteLine($hFile, ";                   0 will keep no logs (KeepLogDays must also be 0) ")
+	$myResult = $myResult And FileWriteLine($hFile, ";                   -1 will keep all logs.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  KeepLogDays ...: Keep at least this many days of log files. ")
+	$myResult = $myResult And FileWriteLine($hFile, ";                   0 will keep no logs (KeepLogCount must also be 0) ")
+	$myResult = $myResult And FileWriteLine($hFile, ";                   -1 will keep all logs.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  NOTE - The KeepLog... settings work in combinaton with each other: ")
+	$myResult = $myResult And FileWriteLine($hFile, ";       e.g. at least 30 days worth of logs, AND at least 10 logs.")
+	$myResult = $myResult And FileWriteLine($hFile, ";       The more generous condition will always take precedence to ")
+	$myResult = $myResult And FileWriteLine($hFile, ";       preserve the maximum amount of historical log informatino.")
+	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
+	$myResult = $myResult And FileWriteLine($hFile, "Report = " & $Gb_ReportErrors)
+	$myResult = $myResult And FileWriteLine($hFile, "KeepLogCount = " & $Gi_KeepLogCount)
+	$myResult = $myResult And FileWriteLine($hFile, "KeepLogDays = " & $Gi_KeepLogDays)
+	$myResult = $myResult And FileWriteLine($hFile, ";End of Settings")
+	$myResult = $myResult And FileWriteLine($hFile, "[email]")
+	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
+	$myResult = $myResult And FileWriteLine($hFile, ";This section is where email settings are specified.")
+	$myResult = $myResult And FileWriteLine($hFile, ";All of the following MUST be specified if Report is True")
+	$myResult = $myResult And FileWriteLine($hFile, ";  SMTPServer ....: Name or IP of SMTP server to use. (e.g. smtp.gmail.com)")
+	$myResult = $myResult And FileWriteLine($hFile, ";  SMTPPort ......: Port number to use, typically 25 (note: gmail uses 465)")
+	$myResult = $myResult And FileWriteLine($hFile, ";  SMTPssl .......: Use Secure Socket Layer protocol or not.")
+	$myResult = $myResult And FileWriteLine($hFile, ";                   0 = no ssl, 1 = use ssl (required for gmail)")
+	$myResult = $myResult And FileWriteLine($hFile, ";  SMTPUser ......: Username for SMTP login")
+	$myResult = $myResult And FileWriteLine($hFile, ";  SMTPPassword ..: Password for SMTP login (IMPORTANT: SEE NOTE BELOW)")
+	$myResult = $myResult And FileWriteLine($hFile, ";***********************************************************")
+	$myResult = $myResult And FileWriteLine($hFile, ";*!!*  NOTE: This setting is a known security issue!!! ")
+	$myResult = $myResult And FileWriteLine($hFile, ";*!!*  Password is stored as plain text, unencryped.  ")
+	$myResult = $myResult And FileWriteLine($hFile, ";*!!*  Use at your own risk!!!  Keep this file in a safe location.")
+	$myResult = $myResult And FileWriteLine($hFile, ";*************************************************************")
+	$myResult = $myResult And FileWriteLine($hFile, ";  FromName ......: Name to identify sender of Email (can be blank)")
+	$myResult = $myResult And FileWriteLine($hFile, ";  FromAddress ...: Email address of sender, typical format: name@domain.com")
+	$myResult = $myResult And FileWriteLine($hFile, ";  ToAddress .....: Comma separated list of addresses to send message to.")
+	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
+	$myResult = $myResult And FileWriteLine($hFile, "SMTPServer = " & $Gs_SMTPServer)
+	$myResult = $myResult And FileWriteLine($hFile, "SMTPPort = " & $Gs_SMTPPort)
+	$myResult = $myResult And FileWriteLine($hFile, "SMTPssl = " & $Gs_SMTPssl)
+	$myResult = $myResult And FileWriteLine($hFile, "SMTPUser = " & $Gs_SMTPUser)
+	$myResult = $myResult And FileWriteLine($hFile, "SMTPPassword = " & $Gs_SMTPPassword)
+	$myResult = $myResult And FileWriteLine($hFile, "FromName = " & $Gs_MailFromName)
+	$myResult = $myResult And FileWriteLine($hFile, "FromAddress = " & $Gs_MailFromAddress)
+	$myResult = $myResult And FileWriteLine($hFile, "ToAddress = " & $Gs_MailToAddress)
+	$myResult = $myResult And FileWriteLine($hFile, ";End of Email ")
+	FileClose($hFile)
+EndFunc ;==> _CreateSettingsFile
+
 ; #FUNCTION# ....:	_ReadGlobalSettings ***************************************
 ; Date Added ....:	20120104
 ; Author ........:	Nathan Durnan
 ; Description ...:	Read script settings from specified INI file.
 ; Syntax ........:	_ReadGlobalSettings($IN_sSettingsFilePath)
 ; Parameters ....:	$IN_sSettingsFilePath - Path of INI file to read settings from.
-; Return values .: N/A (settings will be filled with default values if any errors occur) 
+; Return values .: N/A (settings will be filled with default values if any errors occur)
 ; *****************************************************************************
 
 Func _ReadGlobalSettings( _
 		$IN_sSettingsFilePath)
-	;Read Path Items:
-	$Gs_HgPath = IniRead($IN_sSettingsFilePath, 'paths', 'hgpath', "hg")
-	$Gs_RepoHomeDir = IniRead($IN_sSettingsFilePath, 'paths', 'repopath', @ScriptDir)
-	$Gs_BackupDir = IniRead($IN_sSettingsFilePath, 'paths', 'backuppath', _
+	#Region Read Path Items:
+	Local $sPath, $aTestPath, $szDrive, $szDir, $szFName, $szExt
+	;Read in Mercurial Path
+	$sPath = IniRead($IN_sSettingsFilePath, 'paths', 'hgpath', "hg.exe")
+	;Check for valid Mercurial Path Specification
+	$aTestPath = _PathSplit($sPath, $szDrive, $szDir, $szFName, $szExt)
+	If ($szFName = '') Then
+		$szFName = 'hg'
+	EndIf ;check for filename
+	If ($szExt = '') Then
+		$szExt = 'exe'
+	EndIf ;check for extension
+	$Gs_HgPath = _PathMake($szDrive, $szDir, $szFName, $szExt)
+	;Read in Source Path
+	$sPath = IniRead($IN_sSettingsFilePath, 'paths', 'repopath', @ScriptDir)
+	;Check for valid Source Path Specification
+	$aTestPath = _PathSplit($sPath, $szDrive, $szDir, $szFName, $szExt)
+	If ($szDrive = '') Or ($szDir = '') Then
+		$szDir = @ScriptDir
+	EndIf ;check for drive & directory name
+	If ($szExt <> '') Then
+		$szFName = ''
+	EndIf ;check for extension in path specification.
+	$Gs_RepoHomeDir = _PathMake($szDrive, $szDir, $szFName, '')
+	;Read in Backup Path
+	$sPath = IniRead($IN_sSettingsFilePath, 'paths', 'backuppath', _
 			$G_objFSO.BuildPath(@ScriptDir, "HgBackup"))
-	$Gs_LogFileDir = IniRead($IN_sSettingsFilePath, 'paths', 'logpath', $Gs_BackupDir)
-	
-	;Read Settings:
+	;Check for valid Backup Path Specification
+	$aTestPath = _PathSplit($sPath, $szDrive, $szDir, $szFName, $szExt)
+	If ($szExt <> '') Then
+		$szFName = ''
+	EndIf ;check for extension in path specification.
+	If ($szDrive = '') Or ($szDir = '') Then
+		If ($szFName = '') Then
+			$szDir = $G_objFSO.BuildPath(@ScriptDir, "HgBackup")
+		Else
+			$szDir = @ScriptDir
+		EndIf ;check for missing file spec.
+	EndIf ;check for drive & directory name
+	$Gs_BackupDir = _PathMake($szDrive, $szDir, $szFName, '')
+	;Read in Log Path
+	$sPath = IniRead($IN_sSettingsFilePath, 'paths', 'logpath', $Gs_BackupDir)
+	;Check for valid Backup Path Specification
+	$aTestPath = _PathSplit($sPath, $szDrive, $szDir, $szFName, $szExt)
+	If ($szExt <> '') Then
+		$szFName = ''
+	EndIf ;check for extension in path specification.
+	If ($szDrive = '') Or ($szDir = '') Then
+		If ($szFName = '') Then
+			$szDir = $G_objFSO.BuildPath(@ScriptDir, "HgBackup")
+		Else
+			$szDir = @ScriptDir
+		EndIf ;check for missing file spec.
+	EndIf ;check for drive & directory name
+	$Gs_LogFileDir = _PathMake($szDrive, $szDir, $szFName, '')
+	#EndRegion Read Path Items
+	#Region Read Settings
 	Local $bValue = IniRead($IN_sSettingsFilePath, 'settings', 'Report', False)
+	;Validate Setting Value
 	If IsBool ($bValue) Then
 		$Gb_ReportErrors = $bValue
 	ElseIf IsString($bValue) Or IsNumber($bValue) Then
 	Else
 		$Gb_ReportErrors = False
 	EndIf
-	$Gi_KeepLogCount = IniRead($IN_sSettingsFilePath, 'settings', 'KeepLogCount', -1)
-	$Gi_KeepLogDays = IniRead($IN_sSettingsFilePath, 'settings', 'KeepLogDays', -1)
-	
-	;Read Email Configuration:
+	Local $iValue = IniRead($IN_sSettingsFilePath, 'settings', 'KeepLogCount', -1)
+	;Validate Setting Value
+	If (IsString($iValue) And _
+			StringIsDigit($iValue) Or StringIsFloat($iValue)) _
+	Or (IsNumber($iValue)) Then
+		$Gi_KeepLogCount = Number($iValue)
+	Else ;use default value
+		$Gi_KeepLogCount = -1
+	EndIf ;check for valid value in setting
+	$iValue = IniRead($IN_sSettingsFilePath, 'settings', 'KeepLogDays', -1)
+	;Validate Setting Value
+	If (IsString($iValue) And _
+			StringIsDigit($iValue) Or StringIsFloat($iValue)) _
+	Or (IsNumber($iValue)) Then
+		$Gi_KeepLogDays = Number($iValue)
+	Else ;use default value
+		$Gi_KeepLogDays = -1
+	EndIf ;check for valid value in setting
+	#EndRegion Read Settings
+	#Region Read Email Configuration:
 	;NOTE: The default settings will probably not work if the IniRead command fails to retrieve data from the file.
 	Global $Gs_SMTPServer = IniRead($IN_sSettingsFilePath, 'email', 'SMTPServer', "localhost")
 	Global $Gs_SMTPPort = IniRead($IN_sSettingsFilePath, 'email', 'SMTPPort', "25")
 	Global $Gs_MailFromName = IniRead($IN_sSettingsFilePath, 'email', 'FromName', @ScriptName)
 	Global $Gs_MailFromAddress = IniRead($IN_sSettingsFilePath, 'email', 'FromAddress', @ScriptName & "@localhost")
 	Global $Gs_MailToAddress = IniRead($IN_sSettingsFilePath, 'email', 'ToAddress', @UserName & "@localhost")
-	
+	#EndRegion Read Email Configuration:
 EndFunc ;==> _ReadGlobalSettings
 
 
 ; Remarks:
 ;	The assumtion is make that once a repository folder is found, any further
 ;	recursion into subfolders should be unncessary.  Any subfolders inside a
-;	repository should already be part of the repository itself, or be 
-;	subrepositories that are referenced by the repository and will be cloned 
+;	repository should already be part of the repository itself, or be
+;	subrepositories that are referenced by the repository and will be cloned
 ;	or updated with the primary repository.
 ; *****************************************************************************
 
 	Local $myReturn = 0, $myError = 0, $myExtended = 0 ;These variables will be used for the function's return statement.
 	Local $myobjFolder ;Local Folder object created by the global FileSystemObject.
 	Local $myResult ;For evaluating return values of functions called inside this function.
-	
+
 	If ($optIN_iRecurseLevel > $Gi_RecurseLimit) Then
 		ConsoleWrite("_SearchFolderForRepositories Recursion = " & $optIN_iRecurseLevel & "!!!" & @CRLF)
 		$myExtended = 4
 
 Func _VerifyMercurial()
 	Local $myReturn = 0, $myError = 0, $myExtended = 0 ;These variables will be used for the function's return statement.
-	Local $myExitCode 
+	Local $myExitCode
 
 	$myExitCode = RunWait($Gs_HgPath, @ScriptDir, @SW_HIDE)
 	$myError = @error ;NOTE: check @error IMMEDIATELY after function call!!!
 	Local $myReturn = 0, $myError = 0, $myExtended = 0 ;These variables will be used for the function's return statement.
 	Local $sConsoleCommand, $sConsoleOutput = "", $sTemp = ""
 	Local $hMyApp, $myHandle, $myExitCode
-	
+
 	$sConsoleCommand = $Gs_HgPath & ' ' & $IN_sCommand & ' "' & $IN_sRepoPath & '"' & $optIN_sOptions & $HG_OPT_TIME
 	If Not $optIN_bQuiet Then
 		ConsoleWrite($sConsoleCommand & @CRLF)
 		$myExitCode = _ProcessGetExitCode($myHandle)
 		_ProcessCloseHandle($myHandle)
 		;Evaluate ExitCode...
-		Switch $myExitCode 
+		Switch $myExitCode
 			Case 0 ;Success
 				$myReturn = 1
 				If Not $optIN_bQuiet Then
 	Local $sFileName, $sFileExt
 	Local $sTimeStamp
 	Local $hFile, $iError
-	
+
 	;Capture Current Timestamp Value
 	If IsArray($optIN_aTimeStamp) Then
 		$sTimeStamp = "_" & StringFormat("%04d%02d%02d-%02d%02d%02d", _
 		$optIN_aTimeStamp = '')
 	Local $sTimeStamp
 	Local $myResult
-	
+
 	If ($IN_hLogFile <= 0) Then Return SetError(1,1,0) ;Can't do anything with an invalid file handle.
 	If IsArray($optIN_aTimeStamp) Then
 		$sTimeStamp = " Starting " & StringFormat("%04d/%02d/%02d, at %02d:%02d:%02d", _
 	EndIf ;Check for timestamp array.
 	$myResult = FileWriteLine($IN_hLogFile, "+---------------------------------------------------------------------")
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|  HgPreBackup Log File" & $sTimeStamp)
-	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|  Computer Name  : " & @ComputerName)
+	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|  Computer Name  : " & @ComputerName & _
+			" (" & @OSVersion & "_" & @OSArch & " " & @OSServicePack & ")")
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|  User Name      : " & @UserName)
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "+--------+------------+-----------------------------------------------")
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|  Date  |    Time    | Message     ")
 		$IN_sMessage)
 	Local $aTimeStamp, $sTimeStamp
 	Local $myResult
-	
+
 	If ($IN_hLogFile <= 0) Then Return SetError(1,1,0) ;Can't do anything with an invalid file handle.
 	$aTimeStamp = _GetTimeStampArray()
 	$sTimeStamp = StringFormat("|%04d%02d%02d|%02d:%02d:%02d.%03d", _
 Func _LogFileWriteFooter( _
 		$IN_hLogFile)
 	Local $myResult, $ii
-	
+
 	If ($IN_hLogFile <= 0) Then Return SetError(1,1,0) ;Can't do anything with an invalid file handle.
 	$myResult = FileWriteLine($IN_hLogFile, "+--------+------------+-----------------------------------------------")
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "+---------------------------------------------------------------------")
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "| ~~ SUMMARY ~~ " )
-	$myResult = $myResult And FileWriteLine($IN_hLogFile, "| Elapsed Time..: " & StringFormat('%.3f',_Timer_Diff($Gf_TimeStart)/1000) & " seconds")
+	$myResult = $myResult And FileWriteLine($IN_hLogFile, "| AutoIt Verion......: " & @AutoItVersion)
+	If @Compiled Then
+		$myResult = $myResult And FileWriteLine($IN_hLogFile, "| Script Verion......: " & FileGetVersion(@ScriptFullPath))
+	Else ;running from script - no version number
+		$myResult = $myResult And FileWriteLine($IN_hLogFile, "| Script Verion......: (not compiled)" )
+	EndIf ;check for compiled script
+	If Not $Gb_HgErr Then
+		$myResult = $myResult And FileWriteLine($IN_hLogFile, "| Mercurial Verion...: " & FileGetVersion($Gs_HgPath))
+	Else ;error detected with Mercurial
+		$myResult = $myResult And FileWriteLine($IN_hLogFile, "| Mercurial Verion...: (could not verify Mercurial!)")
+	EndIf ;check for Mercurial error
+	$myResult = $myResult And FileWriteLine($IN_hLogFile, "| Elapsed Time.......: " & StringFormat('%.3f',_Timer_Diff($Gf_TimeStart)/1000) & " seconds")
 	;__________________
 	;==== SETTINGS ====
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "| ________")
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "| SETTINGS")
+	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Settings Path..: " & $Gs_SettingsPath)
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Mercurial Path.: " & $Gs_HgPath)
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Source Path....: " & $Gs_RepoHomeDir)
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Backup Path....: " & $Gs_BackupDir)
 		$myResult = $myResult And FileWriteLine($IN_hLogFile, "| ___________________")
 		$myResult = $myResult And FileWriteLine($IN_hLogFile, "| SOURCE REPOSITORIES")
 		$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Total Found.........: " & $Ga_RepoList[0])
-		If ($Ga_RepoValidErr[0] > 0) Then
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Validation Errors...: " & $Ga_RepoValidErr[0])
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       Review the following repositories:")
-			For $ii = 1 To $Ga_RepoValidErr[0]
-				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       > " & $Ga_RepoValidErr[$ii])
-			Next ;loop through list of repos
-		Else ;No Validation Errors
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Validation Errors...: none (yaay!)")
-		EndIf ;Check for Validation Errors
+		If ($Ga_RepoList[0] <= 0) Then ;check for any repositories found.
+			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Total Found.........: none (huh?)")
+		Else ;At least one repository was found.
+			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Total Found.........: " & $Ga_RepoList[0])
+			If ($Ga_RepoValidErr[0] > 0) Then
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Validation Errors...: " & $Ga_RepoValidErr[0])
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       Review the following repositories:")
+				For $ii = 1 To $Ga_RepoValidErr[0]
+					$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       > " & $Ga_RepoValidErr[$ii])
+				Next ;loop through list of repos
+			Else ;No Validation Errors
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Validation Errors...: none (yaay!)")
+			EndIf ;Check for Validation Errors
+		EndIf ;check for any repositories found.
 		;_____________________________
 		;==== BACKUP REPOSITORIES ====
 		$myResult = $myResult And FileWriteLine($IN_hLogFile, "| ___________________")
 				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       > " & $Ga_BackupRepoPullErr[$ii])
 			Next ;loop through list of repos
 		EndIf ;Check for Pull Errors
-		$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Total Found.............: " & $Ga_BackupRepoList[0])
-		If ($Ga_BackupRepoValidErr[0] > 0) Then
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Validation Errors...: " & $Ga_BackupRepoValidErr[0])
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       Review the following repositories:")
-			For $ii = 1 To $Ga_BackupRepoValidErr[0]
-				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       > " & $Ga_BackupRepoValidErr[$ii])
-			Next ;loop through list of repos
-		Else ;No Validation Errors
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Validation Errors.......: none (yaay!)")
-		EndIf ;Check for Validation Errors
+		If ($Ga_RepoList[0] <= 0) Then ;check for any repositories found.
+			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Total Found.........: none (huh?)")
+		Else ;At least one repository was found.
+			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Total Found.........: " & $Ga_BackupRepoList[0])
+			If ($Ga_BackupRepoValidErr[0] > 0) Then
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Validation Errors...: " & $Ga_BackupRepoValidErr[0])
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       Review the following repositories:")
+				For $ii = 1 To $Ga_BackupRepoValidErr[0]
+					$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       > " & $Ga_BackupRepoValidErr[$ii])
+				Next ;loop through list of repos
+			Else ;No Validation Errors
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Validation Errors.......: none (yaay!)")
+			EndIf ;Check for Validation Errors
+		EndIf ;check for any repositories found.
 	Endif ;Check for mercurial installation/path errors.
 	$myResult = $myResult And FileWriteLine($IN_hLogFile, "+---------------------------------------------------------------------")
 	Return $myResult
 ; Author ........:	Nathan Durnan
 ; Description ...:	Remove old log files, leaving a specified number of logs in the directory.
 ; Remarks........:	Log files are removed to the Recycle Bin, not permanently deleted.
-;	The number of log files to be left in the directory depends on both the 
-;		number of files and the number of days worth of files to keep.   
-;		The more generous parameter takes priority.  
+;	The number of log files to be left in the directory depends on both the
+;		number of files and the number of days worth of files to keep.
+;		The more generous parameter takes priority.
 ;	For example, assume 10 logs per day for 5 days for a total of 50 files.
-;	If this function is told to keep 10 files and 4 days of logs, 
-;		it will leave 40 log files in the folder.  
-;	If it is told to keep 1 day of logs and 25 files, 
-;		it will leave 25 files in the folder.  
+;	If this function is told to keep 10 files and 4 days of logs,
+;		it will leave 40 log files in the folder.
+;	If it is told to keep 1 day of logs and 25 files,
+;		it will leave 25 files in the folder.
 ;	If either parameter is negative, ALL files will always be kept.
 ;	In order to delete all logs, both parameters must be set to zero (0).
 ; Syntax ........:	_LogFileRemoveOldLogs($IN_sLogFileDir, $IN_iKeepLogs, $IN_iKeepDays)
 	Local $myError
 	If Not FileExists($IN_sLogFileDir) Then Return SetError(0, 1, 0);Can't clean a folder that doesn't exist!
 	If ($IN_iKeepLogs < 0) And ($IN_iKeepDays < 0) Then Return SetError(0, 1, 0);Negative value means keep everything, so nothing to do.
-	
+
 	$aFileList = _FileListToArray($IN_sLogFileDir , _
 			$G_objFSO.GetBaseName($GS_LOGFILENAME) & '*.' & _
 			$G_objFSO.GetExtensionName($GS_LOGFILENAME), _