I had to make another bunch of updates to a large website this week… took about 5 days and changes were made to about 50+ files in different parts of the code base. As usual I was committing the changes as I went and along came the day when I needed to upload all the change to the live site. So I right click on my project in Eclipse, go to team and show history. Here is a list of all the commits and below all the files affected by each commit and need to upload. In this case 50 files in different parts of the website where multiple changes have occurred over multiple commits, going through this list one by one and ftp’ing them into place is nothing short of a torture and just plain expensive from a development point of view, who has half an hour or more to spare uploading and checking a list let alone any issues resulting from files that were missed by this process??
So I thought buggar this, time to code up something quickly to help achieve a much needed but missing feature for SVN. Below is a coldfusion template. Simply run it and fill in the details and voof! you have created a nice export pack to simply upload over the top of the existing files in a site. You just need to get a copy of the SVN change log from Eclipse by simply:
- Right click on the project
- Select team>show history
- Select the revisions to include in your export from the list
- Right click on the list and select ‘generate change log’
- From the Generate Change menu select ’svn log with affected paths’ and ‘clipboard’
- Run the script and paste the clipboard into the ‘SVN History Log’ text area’
- Fill in the rest of the details in the form
- Submit and let the script create the export pack for you into the selected export folder
- Upload changes to site! – Congrats, you have just saved your company some big $ and you deserve an early minute, go and tell your boss!
Good luck!
<cfoutput>
<html>
<head>
<title>SVN Revisions Exporter</title>
<style type="text/css">
body{
font-family: verdana;
}
</style>
</head>
<body>
<h2>SVN Revisions Exporter</h2>
<cfif isDefined("form.filePathToProject")>
<cfset filePathToProject = form.filePathToProject />
<cfset filePathToExportFolder = form.filePathToExportFolder />
<cfset svnPathToFiles = form.svnPathToFiles />
<cfset svnHistoryLog = form.svnHistoryLog />
<cfset aSVNData = listToArray(svnHistoryLog,chr(13)) />
<cfloop from="1" to="#arrayLen(aSVNData)#" index="i">
<cfset sData = trim(aSVNData[i]) />
<cfif left(sData,2) IS "M " OR left(sData,2) IS "A ">
<cfset filePath = replaceNoCase(sData,"M #svnPathToFiles#","","ALL") />
<cfset filePath = replaceNoCase(filePath,"A #svnPathToFiles#","","ALL") />
<cfset filePath = replaceNoCase(filePath,"/","\","ALL") />
<cfset dirPath = replaceNoCase(filePath,listLast(filePath,"\"),"","ALL") />
</cfif><cfif len(dirPath) AND directoryExists("#filePathToExportFolder##dirpath#") IS 0>
<cfdirectory action="create" directory="#filePathToExportFolder##dirpath#" />
</cfif>
<cfif fileExists("#filePathToProject##filePath#")>
<cffile action="copy" source="#filePathToProject##filePath#" destination="#filePathToExportFolder##filePath#" />
</cfif>
<cfoutput>#filePath#
</cfoutput>
</cfloop></cfif>
<cfelse>
<form name="svn" method="POST">
<label for="filePathToProject">
File Path To Project:
<input type="text" name="filePathToProject" value="C:\websites\" />
</label>
<label for="filePathToExportFolder">
File Path To Export Folder:
<input type="text" name="filePathToExportFolder" value="C:\temp\" />
</label>
<label for="svnPathToFiles">
SVN Path To Files:
<input type="text" name="svnPathToFiles" value="/trunk/website/" />
</label>
<label for="svnHistoryLog">
SVN History Log:
<textarea name="svnHistoryLog" cols="120" rows="20"></textarea>
</label>
<input type="submit" />
</form>
</cfelse></body>
</html>
</cfoutput>