Question
I would have expected a merge conflict in file a.txt
because its line 2 was changed on trunk
and branch/featurex
simultaneously.
svn diff
?Example to reproduce the situation
To reproduce the tree conflict, you can make a change on trunk
and branches/featurex
and try to merge trunk
to branches/featurex
.
Create a branch:
PS C:\> mkdir demo
PS C:\> cd demo
PS C:\demo> svnadmin create svnrepo
PS C:\demo> cd workspace
PS C:\demo\workspace> mkdir trunk
PS C:\demo\workspace> mkdir branches
PS C:\demo\workspace> mkdir tags
PS C:\demo\workspace> svn add trunk
PS C:\demo\workspace> svn add branches
PS C:\demo\workspace> svn add tags
PS C:\demo\workspace> svn ci -m "Create SVN default folders"
PS C:\demo\workspace> cd trunk
PS C:\demo\workspace\trunk> echo "trunk: line1" > a.txt
PS C:\demo\workspace\trunk> svn add .\a.txt
PS C:\demo\workspace\trunk> svn ci -m "1st commit on trunk"
PS C:\demo\workspace\trunk> svn copy . ..\branches\featurex
PS C:\demo\workspace\trunk> cd ..
PS C:\demo\workspace> cd .\branches
PS C:\demo\workspace\branches> svn ci -m "Create branch for feature x"
Adding featurex
Adding (bin) featurex\a.txt
Commit a change on trunk:
PS C:\demo\workspace\trunk> echo "trunk: line2" >> .\a.txt
PS C:\demo\workspace\trunk> svn ci -m "2nd commit on trunk"
Commit a change on branch (on the same line to create a merge conflict):
PS C:\demo\workspace\branches\featurex> svn up
PS C:\demo\workspace\branches\featurex> echo "branch: line2" >> .\a.txt
PS C:\demo\workspace\branches\featurex> svn ci -m "1st commit on branch"
Merge trunk to branch:
PS C:\demo\workspace\branches\featurex> svn up
PS C:\demo\workspace\branches\featurex> svn merge file:///c:/demo/svnrepo/trunk
--- Merging r2 through r5 into '.':
C a.txt
--- Recording mergeinfo for merge of r2 through r5 into '.':
U .
Summary of conflicts:
Tree conflicts: 1
PS C:\demo\workspace\branches\featurex>
And there it is: the unexpected tree conflict.
The content of a.txt
doesn't show any merges with merge conflicts, it just shows the "branch version" with this content:
trunk: line1
branch: line2
Version
Subversion version 1.7.8 (r1419691) compiled Dec 12 2012, 21:11:09
PS C:\demo\workspace\trunk> svn copy . ..\branches\featurex PS C:\demo\workspace\trunk> cd .. PS C:\demo\workspace> cd .\branches PS C:\demo\workspace\branches> svn ci -m "Create branch for feature x"
is not correct way to create a branch as evidenced by the fact that
Adding featurex Adding (bin) featurex\a.txt
does not mention they are copies. To make them copies, the source must be a repository URL (and the target should be as well). Try creating the branch using:
PS C:\demo\workspace\trunk> svn copy -m "Create branch for feature x" "^/trunk" "^/branches/featurex"
(the ^
is alias for repository root when you are inside working copy) Followed by svn update
. Or much rather svn switch
— you are not supposed to check out more than one branch except to create the initial structure in one commit instead of three!