d
Amit DhamuSoftware Engineer
 

Autoupdate Subversion Repository with TortoiseSVN

4 minute read 00000 views

I have recently started using Subversion as my VCS after starting a new position as a Software Developer at the Carphone Warehouse.

Just a bit of background about my toolbox. I use TortoiseSVN, which is a Windows Shell Extension for SVN. I like the way it integrates into Windows Explorer and gives me Dropbox like status icons on the files to let me know if it needs adding, committing or is up to date. It also comes with a command line interface which can be handy. The diff tools are also pretty good although I use a Sublime Text plugin called Modific for that.

One of the things that bugs me about SVN however, is having to update my repositories manually after getting in to work and throughout the day. To overcome this, I have created a batch file which has a set of update commands for each of my repositories. I then create a new scheduled task with Windows Task Scheduler that first runs when I login and then every hour for the rest of the day.

Here's the steps to take:

1. Open a text editor and enter the following

TortoiseProc.exe /command:update /path:"C:\code\repo1" /closeonend:1
TortoiseProc.exe /command:update /path:"C:\code\repo2" /closeonend:1

2. Save the file

Save the text above as something.bat - i.e. a windows batch file

To explain, the lines in the batch file will update two repositories. The first part is using the command line interface of TortoiseSVN which is TortoiseProc.exe. The second part is the update command, then the path to the repo and then whether to autoclose the update window after completion.

The closeonend parameter has five available options:

/closeonend:0 don't close the dialog automatically
/closeonend:1 auto close if no errors
/closeonend:2 auto close if no errors and conflicts
/closeonend:3 auto close if no errors, conflicts and merges
/closeonend:4 auto close if no errors, conflicts and merges for local operations

3. Test out the batch file To test out the batch file to see if it works, simply find where you saved it and double click it. It should launch a TortoiseSVN update window for each repository. If you chose 0 for the closeonend parameter, the windows should close automatically, otherwise you may have to OK each update before it moves on to the next repository.

4. Schedule It To Run At Intervals Open up Windows Task Scheduler. On the right hand side in the Actions pane, click Create Task. Enter a name and description then click the Triggers tab.

Here is where you set the schedule of your updates so go ahead and click New. I selected Begin the task At log on. Then under Advanced settings, I selected Repeat task every 1 hour and left all other options. Click OK and select the Actions tab.

Click New. Select the Action as Start a program and then browse to the batch file we created earlier under Program/script. Once you have selected the batch file, click OK.

You can amend the scheduled task further if you wish by changing the options under the Conditions and Settings tab but I left them all as default and just clicked OK.

That's it! You have created your SVN Update Repo task which should run at the intervals you selected. On the left hand side pane of Windows Task Scheduler, click Task Scheduler Library and you should see your newly created task. You can right click and Run the task to ensure it is working.

If you need to change the batch file in any way (adding/removing repo's etc), you can simply open it up in a text editor, make some changes and edit it and the task will pick it up next time it runs.