CVS and Visual Studio - The Basics

21. January 2009 01:43

Ok so I had to use CVS as a source code repository and I had trouble on a good way to use it and use it with Visual Studio.  My enviroment is the following:

Windows Vista
WinCVS
Python (WinCVS uses it)
CVSNT
Visual Studio 2005

Here is a little "How To Doc" to get you started using the above tools. There are some nice tools out there that integrate with Visual Studio but not an option yet so I went with this stuff below:

###############################
Create a CVSROOT on Windows
###############################


1.Create a System Variable called CVSROOT
2.Value will equal a path on the computer (i.e., C:\MyCVSRoot)

Open WinCVS and you should be good now.

################################
Add a Project To CVSROOT
################################

1. Open command prompt via start->run
2. cd to the directory (project) you want to add
 *Example command: cd C:\Users\John\Documents\Visual Studio 2005\WebSites\TestCVS
 *TestCVS is the project/website folder on your machine that Visual Studio uses

3. Type the following: cvs import TestCVS vendorTag start
 *vendorTag can be whatever you want (i.e., company you work for)
 *start is required

A notepad window will come up for you to type your notes in regarding the check in. Type anything you want below the dotted lines and save and close it.

You should see the status of what happened in the command prompt of what files and directories got added.

Now you can browse to your CVSROOT (C:\MyCVSRoot) and see the files/folders got added

#################################
CHECKING OUT/UPDATING A PROJECT
#################################

Now to checkout a project you are basically ignoring the folder in the VS Projects directory. You are now going off the files you created from the step above.

So to avoid confusion I made another folder on my machine called CVSProjects.
 (i.e., C:\Users\John\Documents\Visual Studio 2005\WebSites\CVSProjects)


This way you have your originals in C:\Users\John\Documents\Visual Studio 2005\WebSites\

So here are the steps to checkout a project via WinCVS and command prompt

1. Browse to the new folder called CVSProjects in WinCVS
2. Click on it
3. Admin -> Command Line
4. check the box Execute for Directory
5. type: checkout TestCVS in the command window
6. Click OK
7. Now you will notice the TestCVS project in your CVSProjects folder
8. Right Click It and click Update (this will put the files into your project now

9. Now open Visual Studio and go to File -> Open -> Web Site
10. Browse to the CVSProjects\TestCVS folder and open it
11. Now it will create a solution for this one as well
12. Edit a file and run debug to make sure it works.
13. Since you debugged it the files were already saved.
14. Now browse back to WinCVS and go to the CVSProjects\TestCVS folder
 you will notice the files that got changed are now red
15. In WinCVS select the files that are now marked red and right click and select commit
 type in a log message if you choose too

Now the most updated version is now in CVS

###################################
ADD FILES / DIRECTORIES TO PROJECT
###################################

1. Add a new web page to the project you are using in Visual Studio
2. Flip back over to WinCVS and you will now notice that file in there with a question mark next to it
3. Add a new directory to the project in Visual Studio
4. Flip back over to WinCVS and you will notice the directory in there as well
5. In WinCVS highlight the new files only and go to Modify -> Add or click the Add icon
6. Now with those same files selected go to Modify -> Commit or right click and select commit
7. Still in WinCVS highlight the new directory you made and Add it via the same method above
8. Now commit it as well

Now the new files and images are now in CVS

####################################
REVERT TO OLDER VERSION OF A FILE
####################################

To revert to an older version of a file you have to know which version you want to go from and to which from you want to end up at.


1. In WinCVS browse to the project you are working on (I'll stay with the example of CVSProjects\TestCVS)
2. Go to Admin -> Command Line
3. Check the box Execute for Directory (and make sure it is the full path to your project folder above in step 1)
4. Type: cvs update -j 1.3 -j 1.1 default.aspx
 the first version is the version you are starting at, the next version is the version you will end up at
 So in this example I'm taking default.aspx and putting it back to version 1.1

Here is the output from the console

cvs update -j 1.3 -j 1.1 default.aspx (in directory C:\Users\John\Documents\Visual Studio 2005

\WebSites\CVSProjects\TestCVS)
RCS file: C:\MyCVSRoot/TestCVS/default.aspx,v
retrieving revision 1.3
retrieving revision 1.1
Merging differences between 1.3 and 1.1 into default.aspx


Now you will notice the file is red again in WinCVS and if you flip back to visual Studio it will ask you to reload it because it got changed outside the editor

5. Now commit it in WinCVS if that's what you want to do at this point

You will also notice a new file called .#default.aspx.1.3 in WinCVS.  This will also show up in Visual Studio as well.  You may want to make a new folder in the project called OLD_FILES or something so they don't clutter your solution in Visual Studio and also in WinCVS.  Feel free to open the old file as well and as it is a plain text file.

Ok I will add onto this the more I learn but this is the basics so far so good luck. The Wikis and Docs weren't that good because they were directed to Unix/Linux which is fine since that is what this is mean to run on anyway.

UPDATE 1-21-09

###########################################
HOW TO TELL IF FILE(S) ARE/AREN'T
CHECKED OUT
###########################################

Would have to be through WinCVS looking at the status of the files

###########################################
HOW TO CHECKOUT AND LOCK A FILE WITHIN
WITHIN VISUAL STUDIO SO NO ONE ELSE CAN
EDIT
###########################################

- Once you modify a file via Visual Studio it changes the state in CVS and this can be noticed via WinCVS

So in a sense this can't be done effectively enough. It's better to look at the status of files before modifying them via Visual Studio if multiple developers are working on the same project.


############################################
UPDATE YOUR LOCAL COPY ONLY-NOT CHECK IT OUT
############################################
Through WinCVS browse to the working directory of your project. Right Click the Folder and Click Update
 
Notable Options Available:
Get Clean Copy = Overwrites your local copy even if local copy files are modified
 ***note: a new file will be created .#pageName.aspx.x.x
Create Missing Directories = create directories on your local copy if they are in the respository and not in your local copy

UPDATE 1-22-09

############################################
COPY A PROJECT (EXPORT)
############################################
1. Connect to CVS Root
2. Checkout Project to a different directory on your local machine
3. In WinCVS browse to your local working directory (the one you just checked out the project too)
4. Click On in it (highlight it)
5. Trace -> Release
6. Check the box that says "Delete CVS Control Files in the given directory"
7. And Select the CVSROOT in the drop down this project is connected too.
8. Hit OK
9. Answer "YES" to the question (it asks to export it)

This will "de-link" the files from the CVS Server and it will be a copy of the project.

Tags: , ,

Software




My Random Thought

I think the OCW is a great thing to have available to those who are in school, just finished school or just want to educate themself

http://ocwconsortium.org/

John On Twitter

Discounts