Home > Articles > Programming

  • Print
  • + Share This

Merging Your Changes

Since each developer uses his own working directory, the changes you make to your working directory aren't automatically visible to the other developers on your team. CVS doesn't publish your changes until you're ready. When you're done testing your changes, you must commit them to the repository to make them available to the rest of the group. We'll describe the cvs commit command below.

However, suppose another developer has changed the same files you have, or the same lines. Whose changes should prevail? It's generally impossible to answer this question automatically; CVS certainly isn't competent to make that judgment.

Thus, before you can commit your changes, CVS requires your sources to be in sync with any changes committed by the other team members. The cvs update command takes care of this:

$ cvs update
cvs update: Updating .
U Makefile
RCS file: /u/src/master/httpc/httpc.c,v
retrieving revision 1.6
retrieving revision 1.7
Merging differences between 1.6 and 1.7 into httpc.c
M httpc.c
$ 

Let's look at this line by line:

U Makefile 

A line of the form U file means that file was simply Updated; someone else had made a change to the file, and CVS copied the modified file into your home directory.

RCS file: ... retrieving revision 1.6 
retrieving revision 1.7 
Merging differences between 1.6 and 1.7 into httpc.c 

These messages indicate that someone else has changed httpc.c; CVS merged their changes with yours, and did not find any textual conflicts. The numbers 1.6 and 1.7 are revision numbers, used to identify a specific point in a file's history. Note that CVS merges changes into your working copy only; the repository and the other developers' working directories are left undisturbed. It is up to you to test the merged text, and make sure it's valid.

M httpc.c 

A line of the form M file means that file has been Modified by you, and contains changes that are not yet visible to the other developers. These are changes you need to commit. In this case, httpc.c now contains both your modifications and those of the other user.

Since CVS has merged someone else's changes into your source, it's best to make sure things still work:

$ make
gcc -g -Wall -Wmissing-prototypes  -lnsl -lsocket  httpc.c   -o httpc
$ httpc GET http://www.cyclic.com
... HTML text for Cyclic Software's home page follows ...
$ 

It seems to still work.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.