/ acm / sigsoft / cvs workshop / Nov '96
Dealing with Conflicts
If two developers change a file in such a way that the changes cannot
be merged, a conflict will occur during update. Let's say there's a
file hello.c:
main()
{
puts("Hello World");
}
And one developer changes the puts() to a printf() and commiys it:
main()
{
printf("Hello World");
}
$ cvs update
cvs update: Updating .
M hello.c
$ cvs commit -m "printf is better"
cvs commit: Examining .
cvs commit: Committing .
Checking in h.c;
/work/cvsroot/hello/h.c,v <-- h.c
new revision: 1.2; previous revision: 1.1
done
Meanwhile, elsewhere, another developer adds some punctuation:
main()
{
puts("Hello, World!");
}
There will be a problem during update:
$ cvs update
cvs update: Updating .
RCS file: /work/cvsroot/hello/h.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
Merging differences between 1.1.1.1 and 1.2 into hello.c
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in hello.c
C hello.c
main()
{
<<<<<<< hello.c
puts("Hello, World!");
=======
printf("Hello World");
>>>>>>> 1.2
}
The <<<<<<< and >>>>>>>'s mark the area where changes overlap. This must be resolved by hand.
Conflicts will only occur if two (or more) developers are changing the same
section of the same file. Usually this is a result of poor communication
and can be easily avoided.