Introduction to ToirtoseSVN (Subversion Source Control)

Subversion is a popular open-source source control system.  In my last blog “Intro to SVN“, I gave some examples of how the SlikSVN commands work from the Windows Command Line.  ToirtoseSVN is a window shell menu and GUI for SVN.  After installing TortoiseSVN, you simply right-click on the file or directory, and the TortoiseSVN command appear.

Instead of using Windows Explorer, I use a handy tool called “Total Commander” which makes life easier and faster, so in the screen shots below, that is what you will be seeing.

I changed a file, then right-clicked on it, and selected “SVN Commit”.

Tortoise_SVN_Commit

 

Below, I’m showing the code in my short Powershell program, along with the TortoiseSVN Commit screen.  I typed in the reason for my commit (this is the same as doing SVN Commit -m “Add ABCTest to force future conflicts”.  I have a C:\Code\Demo copy of the source programs, and a C:\Code\Demo2 copy.  I needed two copies so I could simulate two people updating the same program, in order to simulate a conflict.

Tortoise_SVN_Commit_Message

 

The results of the commit are shown below:

Tortoise_SVN_Commit_Finished

 

Now below, I try to do an “SVN Update” in the C:\Code\Demo directory. “SVN Update” is similar to “Get Latest” in TFS. It pulls the new code and code changes from the SVN database/library to your local disk/workspace.

 

Tortoise_SVN_UpdateConflict

 

The update fails because I had changed line 6 of C:\Code\Demo\Sample1.ps1 to conflict with the changes made and commited from C:\Code\Demo2\Sample1.ps1.  Thus the code in C:\Code\Demo\Sample1.ps1 needs resolution, usually by a Merge process.

 

Tortoise_SVN_UpdateConflictDetected

 

I did a right-click, chose “Tortoise SVN” then “Merge” (menu selection not shown here).  Forgot to save that one.

I was kind of surprised by what it did.  It actually created several files in the C:\Code\Demo directory.

 

Then, in the directory, it preserved my code as Sample1.ps1.mine, and then added the last two releases (or commits) of that program, suffixed with “.r##” where the version number was 7 and 8 in my scenario.

Tortoise_SVN_UpdateConflictAfter

the file called Sample1_Merge.ps1 looks like this:

Tortoise_SVN_MergeResult1

At this point, you can use any external merge tool, such as WinCompare or the merge tool built into Total Commander.  Or, to use the tool built-in to TortoiseSVN, right click the source code file, select “TortoiseSVN” then “Edit Conflicts” (not Merge).   NOTE: if you use an external merge tool, then after you rmerge is done, you must select “TortoiseSVN” and then “Resolve”.

 

Tortoise_SVN_EditConflicts

 

In my case, the built-in merge tool shows Sample1.ps1.r8 (release 8 from the repository) on the left, and Sample1.ps1.mine on the right.

 

Tortoise_SVN_EditConflicts_Compare

Highlight the code you want, then click “Use Blocks” and select “Mine” or “Theirs” or the desired choice (screen shot not shown).

Then at the bottom, you see the results of the merge.

 

Tortoise_SVN_EditConflicts_MergeResultsAtBottom

When happy with the results, click “Save” , then you have an option to “Mark as Resolved” or “Leave as Conflicted”.  If you are really done with the merge, click “Mark as Resolved”, and the files will be cleaned up (as shown in the following screen shot.  Perhaps you only had time to merge 1/2 the file, and you want to save it and continue tomorrow.  In that case, you could select “Leave as conflicted”.

Tortoise_SVN_EditConflicts_SaveResolve

When you “Resolve”, notice that the .r7, .r8. and .mine files are removed.

Tortoise_SVN_EditConflicts_FilesAfterResolve

Enter your commit comments…

Tortoise_SVN_EditConflicts_Commit2

And now see that the version went form revision 8 to revision 9 – and that completes the process.

Tortoise_SVN_EditConflicts_Commit3

 

 

Uncategorized  

Leave a Reply