Derik Whittaker



Automating Merges w/ TortoiseSVN

Our team works off the feature branch concept and because of this the various teams need to do a source-to-branch merge on a consistent interval.  Doing this process is not difficult, but it is reparative and could become error prone if you are not paying attention.  Because of this we have created a simple .bat script which will aid in automating most of the repetitive tasks which should reduce the amount of errors we encounter.

The script (this is v1 of the script so there may be improvements we could make) is as follows:


REM -- These values may need to change, but not all that often
SET TortoiseSvnLocation="C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe"

REM -- Make sure to change these values
SET /p TrunkHead=Please Enter the latest revision for the Trunk (should be HEAD):
SET /p BranchHead=Please Enter the latest revision for the Branch (should be HEAD):
SET /p TrunkStartRevision=Please Enter the Start Revision:
SET /p TrunkEndRevision=Please Enter the End Revision:

REM -- Make sure you have the physical locations correct
SET TrunkLocationOnDisk="C:\Source\Trunk"
SET BranchLocationOnDisk="C:\Source\\Branch"

REM -- Make sure you have the Url's pointing to the correct location on disk

ECHO Chaning To Trunk Location
CD %TrunkLocationOnDisk%

ECHO /* About to update the trunk to the %TrunkHead% */
%TortoiseSvnLocation% /command:update /rev:%TrunkHead% /path:%TrunkLocationOnDisk% /closeonend:1

ECHO Chaning To Branch Location
CD %BranchLocationOnDisk%

ECHO /* About to update the branch to the %BranchHead% */
%TortoiseSvnLocation% /command:update /rev:%BranchHead% /path:%BranchLocationOnDisk% /closeonend:1

%TortoiseSvnLocation% /command:merge /path:%BranchLocationOnDisk% /fromurl:%TrunkUrl% /revrange:%TrunkStartRevision%-%TrunkEndRevision%



The intent of the script is do perform the following actions

  1. CD into the folder for the trunk
  2. Pull latest of the trunk (SVN path provided in TrunkURL)
  3. CD into the folder for the branch
  4. Pull latest of the branch (SVN path provided in BranchURL)
  5. Run the merge command and provide the start-stop revisions (which are provided via user imput)

As you can see the script is not rocket science, but it does work and it does save you having to perform the same repetitive steps over and over again.

Till next time,

Posted 05-13-2010 5:31 AM by Derik Whittaker
Filed under: ,



alberto wrote re: Automating Merges w/ TortoiseSVN
on 05-13-2010 9:40 AM

You don't need any of that to update a branch with changes from trunk.

1.- No need to update trunk.

2.- you can do: svn merge ^/trunk and you are done.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)