Using CVS
From Tauwiki
Contents |
[edit] Overview
CVS stands for Concurrent Versioning System, a commonly used method of maintaining modification history for files, allowing many users to collaborate in an organized fashion. You can browse our CVS repository through the viewCVS interface. CVS is available for free and it is a part of all popular linux/unix distributions. For additional help regarding the options available for any command, type:
cvs --help <command>
The general form of CVS commands is:
cvs [global options] command [command-specific options]
Some flags, the global options need to be given before the command and the command specific options follow the command they apply to.
[edit] Using TAUVEX cvs
Software Developers in the Tauvex group have read-write access to the cvs area (they better have!). Anyone else can get a read-only access.
[edit] Developers
If you are a developer in the Tauvex Software Team, add the following to your shell init file (eg. ~/.bashrc for bash):
export CVSROOT=":pserver:<user>@tauvex.iiap.res.in:/software/cvs"
Source the file and see if the ENV is defined now. You need to login to the repository on first time use.
cvs login
Type in the password when prompted to do so. This is a one time job per client machine. Login information is stored on your local machine, so you need to relogin if you change computer. Note that defining CVSROOT is not the only way to logon to cvs, but it is probably the most convinient.
[edit] Starting a New Project
If you have some code with you and would like to add it as a new project to cvs, you need to start the whole business by importing it to cvs. Command for that is "cvs import". You are expected to use that command with more arguments like:
cvs import -m "informational log msg" <your_project> \ <vendortag > <releasetag>
Note that:
- You did that import while inside the directory called <your_project>
- <your_project> will be the name of your project
- <vendortag> = "uvs"
- <releasetag> = "first" or "start" or whatever makes you feel better
An example is given below..
- You wrote a program called "yo_world.c"
- Location of your program is /home/me/my_first_code/yo_world.c
- /home/me/my_first_code/some_subdir contains some more files that are part of your project
[me@hal:] cd /home/me/my_first_code [me@hal:~/my_first_code ] ls some_subdir/ README.txt yo_world.c [me@hal:~/my_first_code ]
- Do the import:
[me@hal:~/my_first_code ] cvs import -m "initial import to cvs" \ my_first_code uvs start N my_first_code/README.txt N my_first_code/yo_world.c cvs import: Importing /home/me/my_first_code/some_subdir N myproj/some_subdir/some_code.c No conflicts created by this import [me@hal:~/my_first_code ]
Now comes the most important part. Go over to some other directory
[me@hal:~/my_first_code ] cd /tmp [me@hal:/tmp ]
Do a cvs checkout of your recently imported project
[me@hal:/tmp ] cvs checkout my_first_code cvs checkout: Updating my_first_code U my_first_code/README.txt U my_first_code/yo_world.c cvs checkout: Updating my_first_code/some_subdir U my_first_code/some_subdir/some_code.c [me@hal:/tmp ] cd my_first_code [me@hal:/tmp/my_first_code ] [me@hal:/tmp/my_first_code ] ls CVS/ some_subdir/ README.txt yo_world.c
Make sure all your files are there, along with a directory called "CVS" in each folder. That is the place where CVS keeps information on your file versions, cvs area etc. Do not fiddle with its contents!
If everything is fine, then remove the folder from where you did the import.
[me@hal:/tmp ] cd /home/me [me@hal:~ ] rm -rf my_first_code
Now checkout the copy from cvs.
[me@hal:~ ] cvs checkout my_first_code cvs checkout: Updating my_first_code U my_first_code/README.txt U my_first_code/yo_world.c cvs checkout: Updating my_first_code/some_subdir U my_first_code/some_subdir/some_code.c
Thats all.. Now you can continue working on the code. Make sure to commit to cvs whenever you make changes. Be in sync with other developers working alongside by doing a cvs update or a cvs checkout whenever possible.
[edit] Daily Usage
Several developers may work on same project, so make sure to update your folder everyday when you reach office. Continuing with the example in previous section:
[me@hal:~ ] cd /home/me [me@hal:~ ] cvs checkout my_first_code
That will make it up to date. While working on the code, commit your changes after making significant improvements.. Make sure you do commit the code at least once before you leave office.
[me@hal:~ ] cd /home/me/my_first_code [me@hal:~/my_first_code ] cvs commit
You may use the cvs command "update" to make everything up to date. For eg. some fellow developer modified the file yo_world.c, and you need to get those changes incorporated in your local copy.
[me@hal:~/my_first_code ] cvs update yo_world.c
Thats it. Now you have an updated version. Often people would like to see if your local copy if different from the one on cvs server. You can do a "diff"
[me@hal:~/my_first_code ] cvs diff yo_world.c
use the command "cvs add <file_name>" to add new files and "cvs remove <file_name> to remove a file. You need to remove the file from disk before you do a cvs remove. Make sure to commit after you have added or deleted file(s), so that changes are reflected in the cvs server.
More commands may be found in the section on Quick Reference.
[edit] Others
Only software developers are allowed to submit files to cvs, but others can always view/download files (anonymous access). To do so, add the following to your shell init file (eg. ~/.bashrc for bash):
export CVSROOT=":pserver:anonymous@tauvex.iiap.res.in:/software/cvs"
Source the file and see if the ENV is defined now. You need to login to the repository on first time use.
cvs login
Just hit enter when prompted for password. As I said earlier, this is a one time job per client machine. You need to login only once for an account. Some of the frequently used commands with explanations are given in the quick reference section.
[edit] Connecting through a Proxy Server
If you are behind a proxy server and need to access CVS, then you need to define $CVSROOT as:
PROXY="pserver;proxy=<proxyhostname>;proxyport=<port_number>" export CVSROOT=":$PROXY:<user>@tauvex.iiap.res.in:/software/cvs"
For eg. If your proxy server is 192.168.1.1 and port is 3128. You need to specify:
PROXY="pserver;proxy=192.168.1.1;proxyport=3128" export CVSROOT=":$PROXY:<user>@tauvex.iiap.res.in:/software/cvs"
[edit] cvs commands: Quick Reference
- Initialize a new project: cvs import -d <project_name> <vendor_tag> <release_tag>
- Check out sources from repository: cvs checkout <project_name>
Note: Rest of the commands are performed inside the project directory. If no file names are given, then command is applied to all files (in most cases).
- Compare changes made in local copy: cvs diff <file_name>
- History of all changes for a file: cvs log <file_name>
- check the current status of a file: cvs status <file_name>
- Update local file: cvs update <file_name>
- Commit all changes to repository: cvs commit <file_name>
- Add a directory to an existing project: cvs add <directory_name>
- Remove a directory from an existing project: Contact your system admin!
- Add a file to an existing project:
- cvs add <file_name>
- cvs commit <file_name>
- Remove a file from an existing project:
- rm <file_name>
- cvs remove <file_name>
- cvs commit
- Move/Rename a file:
- rename the local copy
- cvs remove <file>
- cvs add <renamed_file>
- cvs commit
[edit] Getting more help
- cvs --help
- cvs --help-commands
- cvs --help-options
- cvs --help checkout
- cvs --help update
- cvs --help commit
