Back -Adding and Removing Files

Using CVS with Multiple Developers

CVS is an extremely useful tool even when there is only one developer working on a project. If there are multiple developers, a mechanism is provided to allow two or more people to work on the same files simultaneously and subsequently merge their changes. This avoids file locking problems that can occur with other version control software.

To simulate multiple developers, first create a directory for your second developer. We will assume that this is in your home directory and is called devel2. Next check out another copy of testproj and change to the resulting directory.

mkdir ~/devel2
cd ~/devel2
cvs checkout testproj
cd testproj

Now modify the file bar.c in this directory. After the line:

add the following line:
[Or copy bar2.c to bar.c]

Next, check in bar.c as developer two.

cvs commit -m "Added a YOU" bar.c

Now, go back to the original developer directory [Eg. ~/testproj], and look at bar.c. As you can see, the change made by developer one has not been integrated into your version. The output from the command cvs status foo.c indicates that a patch is needed to bring your version up-to-date with the changes made by developer 2 To achieve this you must use cvs update:

cvs update bar.c

CVS should respond with:
U bar.c
Now look at bar.c. It should be the same as developer two's.
Next, edit foo.c as the original developer. After the line:
add the following line:
[Or copy foo2.c to foo.c]

Then check in foo.c

cvs commit -m "Added YOU" foo.c

Next, cd back to developer two's directory, and after the line:
add the following line:
[Or copy foo3.c to foo.c]

You can check the status of the file foo.c with the cvs status command.

cvs status foo.c

The possible status of a file may include the following:

Up-to-date Locally Modified Needing Patch Needs Merge
In this case the output from cvs status indicates that you need to merge your changes to foo.c with the changes made by developer one. To do this:

cvs update foo.c

The output indicates that a conflict was found between the version checked in by developer one and your modified version because the changes overlap.
Since the changes you made to each version were so close together, you must manually adjust foo.c to integrate the conflicting changes. You will find that the cvs update command has modified foo.c to identify the areas of overlap and facilitate a resolution of the conflict (but CVS stores a backup of your original modified file which can be retrieved if you wish). The file foo.c now contains:
void foo()
<<<<<<< foo.c
>>>>>>> 1.2

Notice that the text you added as developer one is between the ======= and the >>>>>>> 1.2.
The text you just added is between the <<<<<<< foo.c and the =======

To fix this, move the
to after the
line and delete the additional lines that CVS inserted.
[Or copy foo4.c to foo.c]
Next, commit foo.c

cvs commit -m "Added TOO" foo.c

Since you issued a cvs update command and integrated the changes made by developer one, the integrated changes are committed to the source tree.

Continue - Branches and Tags in CVS