Resolving CVS conflicts

A conflict occurs in one of two ways. It can happen when you're editing a file under CVS control, someone else edits the same file in a different location, they commit their changes, and you then try to update your tree from the repository. Normally, CVS will handle this transparently by merging your changes with their changes, but if you make changes to the same portion of the file, your changes may conflict.

The other (and more common) place when conflicts can happen is when doing merges between branches. The most frequent example of this is tracking external source on a vendor branch. If we fix a bug locally, and then the maintainers of the package fix the same bug in the next version but in a slightly different way, those changes will probably conflict when we attempt to merge our local tree with the new version.

cvs update warns when conflicts happen; the file that contains conflicts shows up with a "C" mark, and CVS says that the conflicts have to be resolved by hand.

Inside a file with conflicts, there are one or more conflict sections. Each one begins with "<<<<<<<", followed by the section as found in your local file (or the first argument to cvs checkout if you're doing a merge), followed by "=======", followed by the other conflicting version, followed by ">>>>>>>".

To resolve a conflict, search for these markers in the file. Look at the two conflicting versions and either pick the more appropriate one or, if rather than two ways of solving the same problem they're actually overlapping but separate changes, manually merge the changes together. Be sure to remove the conflict markers too while making those changes. Then, use cvs commit to commit the merged file that no longer has conflicts.

If the tree you're working on is one with a vendor branch (where we're making local modifications to externally-maintained files), it's usually best to always prefer the vendor's change if their change and ours are equivalent. That reduces the number of differences between our tree and the canonical one, which makes further conflicts less likely and easier to resolve.

Last spun 2022-02-06 from thread modified 2014-08-17