Subversion is a popular open-source source control system. In my last blog “Intro
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”.
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.
The results of the commit are shown below:
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.
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.
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.
the file called Sample1_Merge.ps1 looks like this:
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”.
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.
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.
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”.
When you “Resolve”, notice that the .r7, .r8. and .mine files are removed.
Enter your commit comments…
And now see that the version went form revision 8 to revision 9 – and that completes the process.
Filed under: SVN