Pages

Thursday, November 18, 2010

Version Controlling : Working with Subversion in Visual Studio 2008

This is the second article to discuss about how to use Subversion version controlling system in Visual Studio. First part of this article discussed about how to install and configure subversion to work with Visual Studio. Also we discussed how to add a solution to the subversion repository. Now, the next step is to learn how to use this version controlling facility effectively. If you hadn’t read the first article yet, I recommend you to have a look at it before continue reading this one.

When you add a solution to the subversion repository, icon of the original project folder changed to a folder icon with a green check mark (See the picture). Also the solution hierarchy in the solution explorer get changed with separate icons in front of each file to display its’ state.







Open a Solution from Subversion


To open a solution from the repository, you can either use File –> Open –> Subversion Project or File –> Subversion –> Open from Subversion. There is an important fact to note is, this opening a solution from subversion (rather called as “Check out a solution from repository”) repository is different from opening a solution directly from its folder. When you open your local project folder, you are opening your own copy. But if you are working on a project where more than one people committing to the same source codes, you need to get start with the latest code when you start work. Because other people might have done changes to the solution. So, “Checking out a Solution” will make a copy of the current version (or any other specific version) available in the repository.

Therefore when you try to open the project from a subversion repository, it asks for a “Local Directory”, where you want to get the new copy. In the Version field, select the repository revision you want to check out. By default, the latest revision is checked out.



If you are working in a team, where other members have the access to the codes, they might have made changes to items in the solution as well. Therefore you must update your working copy in order to see those changes. You can do it in two ways.

  • To get the latest version, right-click the item and select Update to Latest Version.
  • To update to a specific version, right-click the item, select Subversion > Update to Specific Version and specify a revision.




Commit Your Changes


When you have made changes to an item in the solution a red ‘tick’ will appear next to them.



That means your code has changes which is not in the version available in the repository. You will have to commit your changes if you want them to available in the repository. To commit a change, in the Solution Explorer, right-click on the item you modified and select Commit. Then the Commit to subversion dialog box will display the files which have changes and you have the facility to select the files you need to commit among them.



Branching


While the development, if you want to start working on a new feature or a sub-section in the project without affecting the main line of the development, you must create a Branch. Branch starts as a copy of a main line of development, but after that in continues as an independent line of development, with its own changes. To create a branch in the working project, go to the Solution Explorer, right-click an item and select Subversion > Branch Solution.


Branch is not necessarily to be created from the current version, instead you can select the appropriate version from the “Branch Project” Dialog box.

To switch your working copy from the line of development to a branch, use the Switch Solution option. To change the branch, go to the Solution Explorer, right-click an item and select Subversion > Switch Solution.



After some time when your developments come to a particular milestone, you may need to merge the development lines. To perform that task, right-click a solution in the Solution Explorer and select Subversion > Merge Solution. It will guide you through a wizard which allows you to perform a merging task.

So, hope you learn to use the basic functions of subversion through Visual Studio. But you’ll have to, and you can lot more when you apply these practices in real world. Good Luck !

No comments:

Post a Comment

Had to enable word verification due to number of spam comments received. Sorry for the inconvenience caused.