You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by thomas mauch <Th...@swisslog.com> on 2005/06/30 10:34:25 UTC

Bug in svn merge when files are commited with changes into the branch

More than two weeks ago I posted a message with subject "Problems with
svn merge on merging a whole branch to another" describing the problems
I encountered when merging just a small branch back to the main trunk.
After a response from Dale Worley I made further investigations and
posted a test case to produce the bug. The messages mentioned can be
found in the thread
http://subversion.tigris.org/servlets/BrowseList?list=users&by=thread&fr
om=335000.

Unfortunately, I got no further comments. As I still think, the behavior
is due to a bug and this bug limits the easy use of branches, I repost
the description with the test case again.

I try exactly to do what is described as common-use for merging in the
Subversion book in the section "Merging a Whole Branch to Another", but
I'm
encountering a lot of conflicts where I think the merge should be able
to
process the files silently and correctly without user intervention.

As the branch has not been existing very long and few development was
done
on the same file in the trunk and the branch, I expected to get only
status
'Updated' during the merge, but I get more 'Conflicts' than 'Updates' -
even
on files which have not been modified in the trunk in the mean time!
If I look in such a file, I see only conflicts like the one below where
there is really nothing conflicting:

<<<<<<< .working
	// some lines
	// of code
	// are her
=======
>>>>>>> .merge-right.r542

Some files which have about the same changes applied are ok.

As I have found out now, all files with conflicts raised have been
commited into
the branch with changes on them. Other files, having about the same bit
of changes 
applied to but without having changes alreay when creating the branch,
worked fine.

I attach 3 files and describe how to reproduce the problem:

- You have a repository test with directories trunk/src and branches
- Copy attached file uni_druck_gp12.c.r502 into
trunk/src/uni_druck_gp12.c
  and commit it - this is the version before the branch is created
- Copy attached file uni_druck_gp12.c.r503 into
trunk/src/uni_druck_gp12.c -
  the file now contains the changes which have been made when the branch
  was created
- Create the branch: svn copy src
svn://server//test/branches/test-branch
- Checkout the branch and copy attached file uni_druck_gp12.c.r540 into
  trunk/branches/test-branches/uni_druck_gp12.c - the file now contains
the
  changes made when the branch was active
- Commit the branch
- Now checkout a new trunk directory and execute the command
  svn merge -r <revision-when-branch-was-created>:HEAD
  svn://test/branches/test-branch and the file uni_druck_gp12.c will
  have erroneously a status of conflict

Thomas

____________________________________________________________
This message may contain legally privileged or confidential 
information and is therefore addressed to the named persons only. 
The recipient should inform the sender and delete this message, 
if he/she is not named as addressee. 
The sender disclaims any and all liability for the integrity 
and punctuality of this message. 
The sender has activated an automatic virus scanning by 
Messagelabs, but does not guarantee the virus free 
transmission of this message.

Re: Bug in svn merge when files are commited with changes into the branch

Posted by Dominic Anello <da...@danky.com>.
On 2005-06-30 12:34:25 +0200, thomas mauch wrote:
----8<---- 
> I attach 3 files and describe how to reproduce the problem:
> 
> - You have a repository test with directories trunk/src and branches
> - Copy attached file uni_druck_gp12.c.r502 into
> trunk/src/uni_druck_gp12.c
>   and commit it - this is the version before the branch is created
> - Copy attached file uni_druck_gp12.c.r503 into
> trunk/src/uni_druck_gp12.c -
>   the file now contains the changes which have been made when the branch
>   was created
> - Create the branch: svn copy src
> svn://server//test/branches/test-branch
> - Checkout the branch and copy attached file uni_druck_gp12.c.r540 into
>   trunk/branches/test-branches/uni_druck_gp12.c - the file now contains
> the
>   changes made when the branch was active
> - Commit the branch
> - Now checkout a new trunk directory and execute the command
>   svn merge -r <revision-when-branch-was-created>:HEAD
>   svn://test/branches/test-branch and the file uni_druck_gp12.c will
>   have erroneously a status of conflict

This last step may be your problem. For simplicity's sake, let's say
that revision-when-branch-was-created=503

You're merge command is 
svn merge -r 503:HEAD svn://test/branches/test-branch

This will apply the differences between 503 and HEAD.  However, it will
no include the differences *in* r503, so those changes get left out and
you can get conflicts.

If you were to do 
svn log -q -v -r 503 svn://test/branches/test-branch
You would probably see this:
------------------------------------------------------------------------
r503 | tmauch | 2005-06-30 10:34:05 -0500 (Thu, 30 June 2005)
Changed paths:
   A /branches/test-branch (from /trunk:502)
   M /branches/test-branch/uni_druck_gp12.c
------------------------------------------------------------------------

So your merge command should be
svn merge -r 502:HEAD svn://test/branches/test-branch

Most examples show starting with the branch creating rev because the
common case is to just create a branch with no modified files in the
commit.  I do the same thing to bump version numbers when I branch, and
I have to remember to start with branch_creation-1 when merging back to
trunk.

HTH,

-Dominic

Re: Bug in svn merge when files are commited with changes into the branch

Posted by Ryan Schmidt <su...@ryandesign.com>.
I see no bug; I see pilot error:

On 30.06.2005, at 12:34, thomas mauch wrote:

> - You have a repository test with directories trunk/src and branches
> - Copy attached file uni_druck_gp12.c.r502 into
> trunk/src/uni_druck_gp12.c
>   and commit it - this is the version before the branch is created
> - Copy attached file uni_druck_gp12.c.r503 into
> trunk/src/uni_druck_gp12.c -
>   the file now contains the changes which have been made when the  
> branch
>   was created
> - Create the branch: svn copy src
> svn://server//test/branches/test-branch

Right here. You've created a branch not from trunk, but from a  
modified copy of trunk. The way I understood it, if you ever intend  
to merge your branch back into trunk, you should make a copy of an  
unmodified trunk. Meaning: you should either make the change in the  
trunk working copy, then commit it to trunk, and then create the  
branch from trunk; or you should create the branch from trunk, then  
get a working copy of the branch, then make the change in the branch,  
then commit the change to the branch (depending on whether you wanted  
the change to be in the trunk or in the branch).

> - Checkout the branch and copy attached file uni_druck_gp12.c.r540  
> into
>   trunk/branches/test-branches/uni_druck_gp12.c - the file now  
> contains
> the
>   changes made when the branch was active
> - Commit the branch
> - Now checkout a new trunk directory and execute the command
>   svn merge -r <revision-when-branch-was-created>:HEAD
>   svn://test/branches/test-branch and the file uni_druck_gp12.c will
>   have erroneously a status of conflict

The conflict is not erroneous; it is completely expected. The problem  
is that uni_druck_gp12.c in branch @ <revision-when-branch-was- 
created> does not match the state of uni_druck_gp12.c in trunk @  
<revision-when-branch-was-created>. When you do a merge, you must  
always do so on like objects, and you're not. The diff your merge is  
generating does not contain the steps necessary to get  
uni_druck_gp12.c from r502 (which is what you have in trunk) to r503  
(which is what your branch started with).

So, again, the solution is this: the revision that creates a branch  
should do only that. Do not try to do anything else in the same  
revision, such as make changes to uni_druck_gp12.c.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org