next up previous contents
Next: Keeping Track of Who Up: Resolving Conflicts Previous: Automatic Merge   Contents

Manual Merge

In other cases, your recent work on a file might be so different that the CVS needs your help to integrate everyone's work and put it back into the site repository. In this case, CVS sends you back a hybrid version of the file(s) in question, containing special markers to call your attention to differences between your latest work and changes other developers have made to the same file. This section walks you through such a manual merge.

Imagine you've removed some unnecessary HTML <SPACER> tags remaining from an earlier version of a file named activity.htm on the site. Meanwhile, a coworker has removed all sorts of gratuitous HTML <!-- comments --> from the same file, pursuing a similar clean-up assignment of their own. When you go to commit your work into the site repository, you see your coworker has already finished their comments-clean-up and that your work is in conflict:

$ cvs commit activity.htm cvs commit: Up-to-date check failed for
`activity.htm' cvs [commit aborted]: correct above errors first!

Use the cvs update command to bring your local copy of the site up to date and attempt to automatically merge any changes from other authors:

$ cvs update
cvs update: Updating .
RCS file: /usr/local/cvs-repository/camp-kawanhee/activity.htm,v
retrieving revision 1.5
retrieving revision 1.6
Merging differences between 1.5 and 1.6 into activity.htm
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in activity.htm
C activity.htm

In this case, CVS could not automatically merge your work with changes already made by the other author(s). Instead, the CVS program has created a special version of the file in conflict and put it in your working copy of the site in place of the original activity.htm. If you open this file in your HTML editor, you'll find a special marker inserted on a line by itself to show you where the editing conflict begins. This special marker line always begins with a series of eight less-than symbols, followed by the filename:

<<<<<<<< filename

This marker is followed by your version of the text in question, then another marker--this time a series of eight equals signs on a line of their own:


Below this marker comes another version of the text in question that already exists in the site repository. The end of the text-in-conflict is denoted by a final marker, a series of eight greater-than symbols and a version number on a separate line:

>>>>>>>> X.y

You must edit this file until your contribution and any changes made by the other author(s) all work smoothly together. It may be a simple matter of formatting, or a complex content issue that you must resolve with other members of the project in a phone call or meeting. In our simple example, you've removed HTML <SPACER> tags from a file, while another author has removed some <!-- link... --> comment tags from the same file. This is what you see upon opening the file in an editor:

<p align="left">Which activity are you interested in? <br>
<<<<<<< activity.htm
<!-- Link Tag -->    <a href="act/sail.htm">Sailing</a> <br>
<!-- Link Tag -->    <a href="act/baseball.htm">Baseball &amp; Softball</a> <br
<!-- Link Tag -->    <a href="act/basket.htm">Basketball</a> <br>
<spacer type="HORIZONTAL" size="100"><a href="act/sail.htm">Sailing</a> <br>
<spacer type="HORIZONTAL" size="100"><a href="act/baseball.htm">Baseball &amp;
<spacer type="HORIZONTAL" size="100"><a href="act/basket.htm">Basketball</a> <b
>>>>>>> 1.6
<hr align="center">

To resolve the conflict, simply edit the activity.htm file and replace the text between the markers and test the file until it works. You should also delete the markers <<<<<<<<========>>>>>>>> from the file. Here's an excerpt from the edited, tested, and successfully working version of the file-in-conflict above:

<p align="left">Which activity are you interested in? <br>
<a href="act/sail.htm">Sailing</a> <br>
<a href="act/baseball.htm">Baseball &amp; Softball</a> <br>
<a href="act/basket.htm">Basketball</a> <br>
<hr align="center">

Edit any other files that require your attention to resolve a conflict, test your working copy of the site, and use the cvs commit command to put your latest and greatest work back onto the site repository:

$ cvs commit
Checking in activity.htm;
/usr/local/cvs-repository/camp-kawanhee/activity.htm,v  <--  activity.htm
new revision: 1.7; previous revision: 1.6

Remember that conflicts requiring manual editing are rare. The explanation is complicated, but CVS does a great job of recognizing and correcting most of the minor editing collisions without human assistance. When there is a problem, you'll be glad to catch it before overwriting another person's hard work.

next up previous contents
Next: Keeping Track of Who Up: Resolving Conflicts Previous: Automatic Merge   Contents

copyright © 1997-1999 sean dreilinger.