[cvsnt] But... (was: No conflict when merging, where one is expected)

John Peacock jpeacock at rowman.com
Thu Sep 4 15:24:27 BST 2003


Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.


Mike Lehmann wrote:

> Well, deleting the file is nearly the same as removing all lines from 
> it. Removing all lines, means "modifying" all lines. So in the 
> main-trunk and the branch, the same lines were touched and CVS *cannot* 
> know, how to solve it. Just ignoring the changes of the branch is wrong, 
> because there is loss of information.

At the risk of continuing this discussion even further, I think there is some 
misunderstanding about the nature of merge and conflict handling (in general, 
not just CVS).  An empty line has no text, hence it cannot cause a conflict; 
only the same line in both files with different textual changes can cause a 
conflict.  A deleted file, under some circumstances, can be considered to be a 
file with only empty lines.

When you merge changes from a branch to HEAD(1), essentially what CVS does is 
find the difference between the branch's root (where it split from HEAD) and the 
tip of the branch (where it is today).  That diff file is then applied to the 
files in HEAD.  If HEAD has not had any independent changes, this diff should 
never cause a conflict.  If a file in HEAD has changed (and been committed since 
the branch was made), a conflict will occur only if the same line has two 
different non-null text values.  A deleted line in one file, will not(2) cause 
any conflict, since the text only exists in the other file.

Similarly, if a file is deleted on a branch, then when applying those changes to 
HEAD, the file will be deleted on HEAD.  If a file is deleted on HEAD, but not 
on the branch, it will be recreated on HEAD during the merge, since it does 
exist on the branch.  There is no conflict in either case since the "other" file 
is empty, and hence cannot cause a conflict.

Rereading your original posting, the problem is that you created the tag, then 
deleted the file from HEAD.  The branch now contains a file which no longer 
exists on the HEAD branch.  If you are going to use branching to perform large 
scale changes (like deleting or moving files), you should not also make changes 
to HEAD, as it will cause exactly the kind of conflict you see here.

The following links discuss conflicts and merging quite lucidly:

http://cvsbook.red-bean.com/cvsbook.html#Detecting_And_Resolving_Conflicts
http://cvsbook.red-bean.com/cvsbook.html#Merging_Changes_From_Branch_To_Trunk
http://cvsbook.red-bean.com/cvsbook.html#Going_Out_On_A_Limb__How_To_Work_With_Branches_And_Survive_

That last link has especially useful information for dealing with branches.

HTH

John
--
1) Repetitive merges from a branch requires special handling, because you only 
want to apply changes that were not already made, see

http://cvsbook.red-bean.com/cvsbook.html#Multiple_Merges

2) In the general case; it is possible to find conflicts if the patching is very 
complex, i.e. lots of lines added to one file and a couple of lines deleted from 
that file at the same time.  The patch program has a -F fuzz option which makes 
the code search farther afield to try and find the matching code.  If the text 
in the file is very similar, it is possible for the patching code to get 
confused about where to apply the changes.



More information about the cvsnt mailing list
Download the latest CVSNT, TortosieCVS, WinCVS etc. for Windows 8 etc.
@CVSNT on Twitter   CVSNT on Facebook