Seibar
Seibar

Reputation: 70253

SVN - Reintegration Merge error: "must be ancestrally related"

Using TortoiseSVN - when I use Test Merge, I get the error "http://mysvnserver/svn/main/branches/ProjectA must be ancestrally related to http://mysvnserver/svn/main/trunk/ProjectB"

What can I do to resolve this?

Upvotes: 73

Views: 73520

Answers (9)

Dragos
Dragos

Reputation: 21

I had the same problem. I fixed it by correctly cd on which I merged. I was merging in the path directory to project not in the path directory to trunk ( who is the actual ancestor).

Upvotes: 2

Samuel
Samuel

Reputation: 12341

I've had the same error and the reason was about permissions.

The problem was because one developer tries to integrate changes from one branch he has read/write access to another one he also has read/write access but the last one is a branch created from another branch which he just has a read access.

Here is the structure with permissions (r = read, w = write):

trunk (r) develop (r) QA (rw) branches featureBranch1 (rw)

In this case, develop has been created from trunk, QA from develop and featureBranch1 from develop. The fact that he try to reintegrate featureBranch1 into QA which was a branch created from develop and he don't have access in write to develop is in our case the problem why he receive this message when trying to reintegrate featureBranch1 in QA.

Immediately after giving him access in write to develop, the message disappear.

Upvotes: 1

Junaed
Junaed

Reputation: 1957

At first I tried to merge in the root folder and got the error, then I browsed to the specific folder where I wanted to merge and then selected the right folder to merge from.

Example,

In my branch, I have project structure:

 -Root    
    - Code
    - DB

I created a tag and changed into the DB folder of the tag. Now I want to bring the changes of the tag to the branch. So, I switched to my branch and tried to merge and got the error “must be ancestrally related”.

So the solution was,

I browsed to "DB" folder in branch, right click and select Tortoise SVN->Merge-> Merge a range of revisions -> 

Now, from the URL to merge from, I selected:

the "DB" folder from my tag.
Then, "test branch". Everything worked fine :D

So, then I clicked the "Merge" button.

Upvotes: 3

alx
alx

Reputation: 2357

This error might occur if you have a file named exactly like one of the branches (or trunk):

# svn switch ^/trunk
Updated to revision 123.
# ls
file1
file2
v1
# svn merge --reintegrate ^/branches/v1
svn: E195016: ^/branches/v1@123 must be ancestrally related to ^/trunk/v1@123

To solve this add current dir to the command (note the dot):

# svn merge --reintegrate ^/branches/v1 .

This is a real life example, it costed me couple of very unpleasant hours. :(

Upvotes: 2

Zeus
Zeus

Reputation: 6566

I was merging with another project. Caused this issue. I merged with the correct branch then it worked fine. My bad, dyslexia

Upvotes: 1

Memet Olsen
Memet Olsen

Reputation: 4608

We have run into this problem because of the following:

Created a folder with the repo browser of TortoiseSVN and used it as a branch. Afterwards we tried to merge the manually created folder into the work folder.

Solution is: Don't create a branch manually in first place, instead use the TortoiseSVN -> Branch/tag... option to create a branch.

Hopefully this will be helpful.

Upvotes: 7

jevon
jevon

Reputation: 3274

As davebytes mentioned, this problem can occur when you branch trunk\X into branches\Y, but then move X into a new folder Z, i.e. trunk\X\Z.

If you just try to merge a change on branches\Y into trunk\X, you will get lots of conflicts; if you just try to merge branches\Y into trunk\X\Z, you will get the "ancestrally related" error.

But, the SVN manual describes the underlying problem: svn merge should really be called svn diff-and-apply. What you should instead be trying to describe in this scenario, is that you are trying to sum up the changes that occured from r100 to r200 of branches\Y, and apply these changes to trunk\X\Z\.

In TortoiseSVN, this is the merge two different trees scenario to your local working copy of trunk\X\Z, with r100 of branches\Y set as "from", and r200 of branches\Y set as "to".

Upvotes: 9

davebytes
davebytes

Reputation: 925

I just went through a similar problem, wanted to add the issue and solution I hit. The branch was made from a SUBFOLDER of trunk and not the entire tree. Thus, when I tried to reintegrate, I was mismatching hierarchies. Simply restructuring the integrate to be to the proper subfolder of my trunk WD allowed the process to proceed.

Adding in hopes this might aid someone who hits this Q/A. :)

Upvotes: 81

Leonidas
Leonidas

Reputation: 2438

Let me guess: the projects are not related? Look up the history, if one of them ever was branched or not.

Immediate solution: either merge per hand or try command line with "svn merge --ignore-ancestry"

Upvotes: 21

Related Questions