CVS Co-operative Mode
Note that these instructions refer to using the command line version of CVS on Windows as available from the FreeBMD web site. They do not cover WinCVS, a Windows interface version.
You can learn more about CVS and the development process from the following links:
What is CVS?
Development Process Overview
With the co-operative method of working, the files on your machine are read-only and you will not be able to change them until you have used the cvs edit command as described below.
Using DOS Commands
All of the CVS commands mentioned in this tutorial are executed at the command prompt in a DOS window.
If you are unfamiliar with DOS you should find this section helpful:
The file system on any disk begins with the root (top-level) directory, represented as a backslash. Thus C:\ represents the root directory on the C: drive. Each additional nested directory can be represented as another element in the path, with a backslash used to separate each one. C:\Windows\System\Colour, means that the Colour folder is in the System folder in the Windows folder on the C: drive.
To open a DOS window in Windows 98, click on Start - Programs - MS-DOS Prompt. In Windows XP, Start - All Programs - Accessories - Command Prompt.
When you open a DOS window you should see a command prompt such as C:\>. The first letter indicates which drive is currently in use - the 'active' drive.
If you want to change to a different directory, say to the colour directory, you would type cd c:\system\colour and press 'Enter'. The command prompt will then change to C:\system\colour>, showing that you are now in the colour directory.
Note: File names for the CVS repository, on UNIX, are case sensitive. Therefore, to make things simple for yourself always treat the file names in CVS as case sensitive.
Each time DOS starts, it reserves a section of your computer's memory it calls the environment to store information accessible to DOS commands and your applications. Whenever you use CVS, you have to type in three variables each time:
- Set home=c:/freebmd (this lets CVS know that freebmd is the 'home' directory in which the files are to be stored). Note: The forward slashes are intentional.
- Set cvs_rsh=c:\program files\cvs\ssh (this lets CVS know where the secure shell files are).
- Path=%path%;c:\program files\cvs (the path is searched for executable files) Note: the percentage signs ensure that the 'Path' is added to any existing path command, and does not replace it.
Note: The environment variables above assume that you will name the folders as in the 'Sample session' section below. If you name the folders differently, then you need to change freebmd and cvs in the environment variables accordingly.
Presetting environment variables
Setting the environment variables each time you want to use CVS can be tedious, but there are ways you can avoid this. In some versions of Windows, (XP for example), you can set environmental variables in the following way:
-
Right click on My Computer - Properties - Advanced - Environment variables - New.
-
Enter the variables in the top pane thus: HOME, CVS_RSH and PATH.
-
In the bottom pane add the rest of the variable, for example: c:\program files\cvs
Windows 98 has a System Configuration Utility (\Windows\System\msconfig.exe), which allows you to set environment variables.
Click on the Autoexec.bat tab and
look for a 'PATH' command. If there is one, click on edit and add your PATH command to the end of the existing one. If you don't see a PATH command, click on new and add the command. Add the HOME and CVS_RSH variables here as well.
A Sample Session
As a way of introducing CVS, we'll go through the process of setting up a working directory, downloading the source files from the repository, and making changes to a FreeBMD project file, before committing the changes back into the repository.
-
The first thing you need to do is create a new folder on your hard drive. The naming of this folder is arbitrary, but for this example we will call it 'freebmd'. The folder will contain the FreeBMD files that you will download from the repository. The path to this folder will be C:\freebmd
-
Next, create a folder in the Program Files folder on your hard drive and name it 'cvs', so the path to this folder will be C:\Program Files\cvs.
-
Now you are ready to download the cvs_ssh.zip file containing the CVS software and associated routines including SSh (secure shell).
-
When you have downloaded cvs_ssh.zip, extract the files to the cvs folder you created in step 2.
Creating Keys
You are now ready to log on to the server, tell it who you are and what password you will use to access and download the FreeBMD project files.
-
Connect to the internet in your usual way.
-
Open a DOS window and navigate to the 'Home' directory, c:\freebmd (if freebmd is the name you are using). You always have to be in the home directory before downloading project files.
-
If you haven't preset the environmental variables as described above, you will have to type them in now, exactly as shown under Environment Variables, but substituting the folder names for the ones you have chosen.
-
At the command prompt, type ssh-keygen. The key generation program will now be executed. When prompted for the file in which to save the key accept the default offered and press enter. It is most important that the file is literally called Identity.pub and is in c:\freebmd\.ssh (if freebmd is the name of your home directory).
-
You will be asked to supply a passphrase (password) that you will need to authenticate your use of SSh. Choose an obscure password that only you will know, and write it down, as you will need it again.
Note: If you haven't entered a password in a DOS window before, it can seem a bit strange. As you type, the cursor doesn't move, giving the impression that nothing has been entered. You will be requested to enter the password twice.
If all has gone well, the file Identity.pub will have been placed in c:\freebmd\.ssh.
-
Send the file called Identity.pub to Dave Mayall. This file contains your public key.
Note: In the same location as identity.pub, ssh-keygen will have stored another file called Identity. This is your private key which enables you, and only you, to authenticate messages signed with your public key.
Once you have run ssh-keygen and have sent identity.pub to Dave, do not run it again, as your key will be overwritten, and you will have to re-send the file to Dave.
-
Dave will set up a login (referred to as yourname below) for you on the FreeBMD development machine. You will receive an e-mail message from Dave notifying you of your login name, and password for PTS.
-
It would be wise to ask Dave to set you up to be mailed with all CVS commits
Getting the Project Files from the Repository.
These instructions refer to the use of SSh - for plink see the section Using plink.
-
Make sure the environment variables are set.
-
Make sure you're in the home directory by typing at the command prompt:
cd c:\freebmd
-
Download the source from the repository by typing the command:
cvs -d yourname@test.freebmd.org.uk:/home/cvs checkout UKGEN-FreeBMD
Note: Remember case sensitivity. Make sure you type UKGEN-FreeBMD exactly as shown. You will be prompted for the passphrase you created earlier with ssh-keygen.
-
Enter your passphrase. The next stage takes some time, and you may think nothing is happening. Be patient! There are a lot of files to download. Eventually the files in the repository will start to download into your home directory. The download will be complete when you are returned to the DOS command prompt.
-
During the download process a folder called UKGEN-FreeBMD will be created inside the home directory, and will hold all the downloaded project files and folders.
Note: Before making any changes to a file, make sure you have allocated the task to yourself in PTS
-
Type cvs update
to ensure that your local copy of the repository is up to date.
- Type cvs editors filename
to find out if someone else is editing a file. If so you will need to negotiate with them, or with whoever is co-ordinating the editing activity before proceeding.
- Type cvs edit filename
to indicate that you are going to edit a file. This makes the file read/write and informs other users that you are going to edit it. If someone else starts to edit the file (they shouldn't) you will be notified by email.
-
Look in the rootsweb-FreeBMD2 folder for the file you want to work on and make the necessary changes.
Note: Use a plain text editor for editing HTML files, as a WYSIWYG (What You See Is What You Get) editor can mess up the code. View HTML files in both Internet Explorer and Netscape Navigator if possible before upload.
- Type cvs update filename in case the file has been changed in the meantime.
- If you decide to abandon the changes you have made, and revert to the orignal version, type cvs unedit filename
You will not be able to edit the file again until you have done a cvs edit file
Committing the Changes
-
Type cvs commit filename to make your changes into the repository. CVS creates the next revision number of the file. You will not be able to edit the file again until you have done a cvs edit filename
-
CVS goes quiet for a moment while it compares the list of files on your computer with those on the server, and then it automatically opens up Notepad showing a list of changed files.
-
At the top of Notepad you will see the cursor. Type in a short comment here to describe the changes to the file(s). Click on File - Save and close Notepad
-
When Notepad closes, CVS automatically sends your edited files to the server. At the same time, an e-mail is generated and sent to everyone on the mailing list telling them what has been changed.
Note: There is an alternative to using Notepad when committing in step one. Replace the command shown with cvs commit -m "message" filename where message is the description you would have typed into Notepad.
Testing the Changes
Having made changes, you will need to get the file(s) installed on the test site.
-
Log on to the Development server . You will see a list of files, including the file you have changed, preceded by a letter 'u' to indicate the file has been uploaded.
-
Test HTML and CGI changes on the Test site. The test site looks and acts like the FreeBMD site. You can navigate through the site and test how your changes look and behave.
-
Once you are happy with your testing, go to PTS and change the task status in PTS to "Ready for Test" and assign it to the person who originally requested it.
Tip Put the development server, the test site and PTS login into your 'Favourites' folder. You can then move easily from one to the other .
-
When the requester is satisfied with the changes, you will receive an e-mail notification that the task has been assigned back to you as "Tested OK"
-
You now have to 'tag' the changed file. Make sure you're in the folder/directory which holds the file. Tag each changed file by typing cvs tag T1234 filename
-
Replace T1234 with the TID from PTS preceded by T
-
Replace filename with the name of the file.
-
Add a followup to the task in PTS, listing which modules have been changed, list any restrictions about when the module must go live (e.g. "To go live after next DB update") and assign it to Dave Mayall in status "Ready to Deploy".
-
The process is complete when Dave puts the changes live.
Additional Information
The most common commands
-
cvs commit - commit your changes into the repository.
-
cvs update - get the latest version of a file from the repository. Your modifications to a file are never lost when you use update. If no newer revision exists, running update has no effect. If you have edited the file, and a newer revision is available, CVS will merge all changes into your working copy.
-
cvs status - find the latest revision in the repository and compare it with yours. When you use status, one of a number of messages will be output. The following are the ones you are most likely to see:
-
Up-to-date: The file is identical with the latest revision in the repository.
- Locally Modified: You have edited the file, and not yet committed your changes.
- Unknown: CVS doesn't know anything about this file. For example, you have created a new file and have not run add.
-
cvs diff - find out how your version of a file differs from what is in the repository. This is useful to see what changes you have made.
-
cvs log - find out what happened to a file.
-
cvs add - create a new file
Note: Using the above commands without stipulating a filename will act on all files. If you want to commit or compare one file, give the filename thus: cvs update filenane
You will be prompted for your passphrase (as defined in ssh-keygen) when you execute each command.
General update
Every so often it is worthwhile doing a general update to get the latest copies from the repository, especially new files. Only changed or new files will be downloaded. To do such an update use the following when in directory cvs-home
cvs update -AdP rootsweb-FreeBMD2
Creating a new executable file
Creating a new file will not occur very often, but when running cvs from Windows there is a catch in creating an executable file, e.g. a perl script. Namely, it will not be executable!
Whatever the Windows permissions are on the file that is created (using cvs add ...), it will not have the executable bit set on the server. If you have access to the development machine you can go into source and add the execute permission manually ... or get Ben, or Dave, or Graham to do it for you!
Binary files
Binary files (e.g. image files such as .gif) are handled specially by cvs. It doesn't try to report differences when you commit a new version, for example.
If you create a binary file, use the -kb option on the add command, thus
However, there is a problem! When you do the first commit on the file CVS puts the whole of the binary in the commit mail message. Therefore, the socially responsible thing to do is to make the first commit a dummy file and then commit the real file as a second commit.
Creating a new directory
It's unlikely you will have to create a new directory in the repository but if you do, first create the directory in your working directory and then use the command: cvs add directory where directory is the name of the new directory.
Note however that the new directory will not be installed onto the test site. You will need to ask Dave for help.
Getting a previous revision
To get a previous revision of a file use
| |
cvs update -r revision -p file
|
which will cause revision of file to be piped to standard output. The command above will display the revision of the file - but you probably want to store it somewhere! So do this:
| |
cvs update -r revision -p file >DestFile
|
where DestFile is the file name you want the revision stored in.
The documentation for cvs 1.11 is available from www.cvshome.org. Although this is a later version of cvs than the one you will be using, this documentation represents a valuable source of information, although it is not the easiest manual in the world to use!
Abbreviations
Although there are abbreviations for the commands it is probably best to avoid them, at least initially. For historical reasons the abbreviation for commit is ci whereas the abbreviation co is used for checkout, so one can get confused!
As mentioned previously, with SSh you will be prompted for your passphrase at each command execution. This can get a bit boring and by using plink (with pageant) you can supply your passphrase only once per session.
Create a PuTTY saved session
Run putty and set up the following parameters:
| | hostname | test.freebmd.org.uk |
| | port | 22 |
| | protocol | SSH |
CliCK on the + next to Connection and then click on SSh
| | Preferred SSh protocol version | 1 |
| | Private key for authentication | cvs-home\.ssh\Identity (or wherever you stored your private key - see here) |
Click on Session and type a name (e.g. cvs) in the Saved Sessions box and click on Save. We will refer to this name as cvs-session below.
Note for Windows XP users: The first time you use PuTTY you should change the default encryption cipher selection policy to 3DES.
Exit by clicking on Cancel
Create a session
Run pageant. In the task bar at the bottom of the screen a computer with a hat on will appear. Right click on this and select Add key. Navigate to your Identity file (this will be cvs-home\.ssh\Identity) and click on Open. Type your passphrase when prompted.
Note that the security of FreeBMD is now dependent on the security of your machine. Ensure you have a secure logon and timeout. Close your machine when not using it.
Change cvs protocol
Change the environment variable CVS_RSH to point to plink, for example:
| |
set CVS_RSH="c:\Program Files\PuTTY\plink.exe"
|
Change cvs directory
You only need to worry about what's in this section if you did a cvs update using ssh and now want to change to plink. In order to run any of the cvs commands using plink instead of ssh include -d cvs-session:/home/cvs where cvs-session is the name you saved your PuTTY session under.
For example:
| |
cvs -d cvs-session:/home/cvs status file
|
If you want to change from ssh to plink permanently you will probably want to make the above directory the default. This is a bit awkward because you have to either change or remove the CVS\root files (i.e. the files named root in the directories named CVS) in each of the directories on your machine below the directory you specified in HOME (as described here). The easiest is probably to delete them all and
| |
set CVSROOT=cvs-session:/home/cvs
|
FreeBMD Main Page
© 1998-2008 The Trustees of FreeBMD (Ben Laurie, Graham Hart, Camilla von Massenbach and David Mayall), a charity registered in England and Wales, Number 1096940.
We make no warranty whatsoever as to the accuracy and completeness of the FreeBMD data. Use of the FreeBMD website is conditional upon acceptance of the Terms and Conditions