[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: how to avoid text and tree conflict

From: Bob Archer <Bob.Archer_at_amsi.com>
Date: Mon, 4 Apr 2011 14:10:11 -0400

> On Mon, 2011-04-04 at 10:26 -0400, Bob Archer wrote:
> > > I read the SVN book, as there are three type conflicts: text,
> > > tree and
> > > properties conflict. However, I wanna know why it is a
> conflict.
> > > For
> > > example, if there is a text conflict when I do merging code, I
> just
> > > know
> > > there is an conflict but don't know why it is a conflict.
> >
> > It is a conflict because two people changed the same line of
> code. So, the software can't know which line of code you want to
> remain after it merges them... you have to tell it. You could
> choose one line, the other line, or even combine them in some way.
> >
> > BOb
> >
> >
> >
> > >
> > > So could u provide me some resource or hints what are the
> judge
> > > rules
> > > for SVN to address it is a conflict, in this case, I can avoid
> more
> > > conflict when I'm coding or merging. I concert the text and
> tree
> > > conflict more.
> > >
> > > Regards,
> > > Su Heng
> > >
> > > --
> > > QQ : 49757862
> > > MSN: suh.steven_at_hotmail.com
> > > Mobile: (0512)60780554
> > >
> >
>
> Hi Bob,
>
> What about different lines?
> trunk file node_at_r1
> node:
> -----
> line1
> -----
>
> create branch node1(node_at_r2), node2(node_at_r3)
>
> edit node_at_r2 under branch node1
> -----
> line1
> line2
> -----
> submit and get node_at_r3
>
> edit node_at_r3 under branch node2
> -----
> line1
>
> line3
> -----
> submit and get node_at_r4
>
> edit node_at_r1(or merge branch node1) under trunk
> -----
> line1
> line2
> -----
> submit and get node_at_r5
>
> finally, merge branch node2_at_r4 to trunk can get conflict.
>
> <<<<<<< .working
> line1
> line2=======
> line1
>
> line3>>>>>>> .merge-right.r4
>
>
> I though node2_at_r4 will be merged to node_at_r5 like this:
> -----
> line1
> line2
> line3
> -----
>
> but not.
>

Because...

...in the node1 branch you modified line2 making it read "line2".

...in the node2 branch you modified line2 making it "" and line 3 making it "line3"

When you try to bring these together svn is going to look at the base (r1) of each file. It is going to see that line2 is different from base in both the merge target and the merge source. It also sees that those changes are different. That is a conflict. svn doesn't know whether to use the "line2" content from node1 branch or the "" content from node2.

It may seem obvious to you that you don't want the blank like and you want it to say "line2"... but svn has no way to know this. Perhaps the blank line is what you want in the result.

BTW: This happens even in normal use... since an update it also essentially a merge.

Let's assume we have a file call it test.txt in a repository with the following lines:

line1
line2
line3
line4

We each have it checked out to our working copies.

I make a change to the file so it looks like this, and check it in:

line1

line3
line4

(I have blanked line2, well really it contains a line feed).

You make a change to the file so it looks like this:

line1
line2a
line3
line4

You try to commit and you get an error that it is out of date. So you do an update. svn sees that you changed line2 as did the latest HEAD version be comparing them to the common base. This is a conflict... a person has to resolve it. svn can just assume, oh a line with text is more important (or correct) than a line with just a line feed. And if it did do this you would not be very happy.

That all said, we have found in our day to day use of svn we rarely see conflicts like this.

Of course, the above is different than tree conflicts which occur for path change reasons rather than file content reasons.

BOb

 
Received on 2011-04-04 20:10:44 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.