Oct 22, 2007

Compelling features in SVN. But, rarely used.

I have been using SVN for source control more than two years now. But, i haven't bothered to try out some of the features. Typically, we want to use those primitive features that are easy to understand or rather familiar to us. Checkout, Commit, Update, Show log, Diff are primitive and commonly used commands, as we mostly do Update and Commit on a daily basis. Diff is used while merging code. These commands are sufficient for simpler quotidien tasks.

But, definitely not sufficient if you are to merge a history of changes from one branch to another. I stumbled across 100s of checkins on one branch to be merged into another. Another twist was the number people who did these checkins and there were checkins by multiple persons on the same file. As a relief, i was asked to merge only my checkins from one branch to another. Exactly not a relief, but a pain, as many people had done changes to the files i modified over a period of time. I am using Tortoise SVN as client. So, my experience revolves around the tool. Still, i believe the terms and functionality are similar with respect to SVN and CVS immaterial of the client used to access the code repository.

So, the problem definition in one line:
"Pull out all your changes from one branch over a period of time and put it into another branch"

Setup: I have branch Origin and branch Target to merge my files.
Better way to tackle this:
Step 1: Select the source branch folder and go to Show Log to view the history of changes on the branch.
Step 2: Select the range of changes to view based on either Date or Revision no.
Step 3: Sort the list based on Author.
Step 4: Select the entire list of checkins done in your Author name. This action will show a list of files in the lower window. These are the entire list of files that were modified in the selected list of checkins. So, you have all the files that you modified during those checkins. Copy the list to somewhere. And, these are the files u need to merge into the Target branch. Hooray!
Step 5: Having got the list of file you need to be concerned about, next challenge would be seperate out the changes done to the same file by yourself and others. Afterall, you need to be concerned about only your changes done to the file. Previously, i would have went through Diffing two revisions. But, there is these Blame functionality. You can click on a file to be merged and do a Blame with start and end revision number. After a little time munching the bits and bytes, SVN will pull out the line by line changes made every single person on the file over the period. Awesome it is!

Another interesting functionality is the concept of Patching. Creating and Applying patch are two phases of patching. When a dev has made a bunch of code changes and needs to send it to a reviewer or configuration manager, he need not send the files seperately to the recepient. Instead, he can create a Patch which is nothing but a unified diff of working and base copy. After reviewing the unified diff(Patch), the reviewer can simply Apply the patch on the repository.

No comments:

Post a Comment