SVN - unable to merge branch back into trunk - numerous tree-conflicts
Asked Answered
L

6

55

I have what I thought was a simple scenario - using TortoiseSVN:

1) I made a branch (B2) of an application (to work on implementing image sprites & JAWR).

2) Testing & development went on as normal on the trunk.

3) I re-based the branch a couple of times over the last few days by:

3.1) Merged trunk (by range of revisions) to my branch-b2 working copy, resolving conflicts during the merge.

3.2) (after testing branch-b2), I commit the re-based branch-b2.

This all worked as I expected. But merging the branch back into the trunk is having its way with me:

4) After all updates committed in branch-b2; I make sure I do an SVN Update on trunk and branch-b2.

5) Then, I try to merge (range of revisions) from branch-b2 into the trunk. However, for any new file that had been added to the trunk, and subsequently added to branch-b2 when I rebased it, I get a tree-conflict. I'm not sure what the proper way is to resolve these conflicts.

The most typical advice I've seen is to either delete the tree-conflict files from the trunk, then merge the branch over; or delete the entire trunk, copy the branch files over, and then commit them as a new version in the trunk. Neither of those options seems like a good idea- first one is a pain, and both seem like they would lose file revision histories.

What'd I do wrong, and how do I fix it?

Legislation answered 17/6, 2009 at 18:6 Comment(0)
H
74

Sounds like you're using the pre-1.5 merge style and trying to reintegrate the branch into trunk. In that case, what you want to do is first ensure all the trunk changes have been merged in to the branch, and then instead of range-merging the branch to a working copy that points to the trunk, you want to merge "FROM trunk@HEAD TO branch@HEAD" with the working copy pointing to trunk. In essence:

"Give me all the changes I'd need to make trunk identical to branch".

This works if you've already merged all the trunk changes to the branch, because then the only difference between trunk and branch are the changes made in the branch.

Make sense? :)

Humectant answered 17/6, 2009 at 18:32 Comment(9)
That makes sense - will give it a shot first thing in the a.m. Out of curiosity and a desire for sanity in the future, what's the post-1.5 merge style?Legislation
1.5 and onwards you can skip the revision range in the first merge and use something like "svn merge --reintegrate branch" for the second merge (can't recall the TSVN gui specifics). On the downside, after reintegrating you'll have to re-branch because the reintegrate does something funny to the mergeinfo.Humectant
Thanks @Rytmis, I just managed to pull this off, but I want to offer a translation for Tortoise users. 1) Switch your working copy to the branch (if it isn't already) 2) Right-click working copy, TortoiseSVN > Merge > "Merge a range of revisions", click Next 3) URL to merge from = Trunk, click Next, Merge 4) Switch working copy to Trunk 5) Right-click working copy, TortoiseSVN > Merge > "Merge two different trees", click Next 6) From: Trunk (use HEAD revision) To: Branch (use HEAD revision) 7) Click Next, Merge. 8) Commit your working copy. DONEDichotomous
This explanation has resolved several conflicts in our process. Thanks guys :)Nishanishi
In the command line: First, make sure that the branch is fully up to date from the trunk. Then, check out the trunk, and from the root of the working copy say svn merge ^/trunk ^/branches/TheBranch . I tried and failed to merge a bunch of times, and that left behind unversioned files after svn revert -R ., which confused SVN, so I used the svnclean script from here to get rid of them.Fawcett
Svn scares me when its time to merge :(Iny
I always forget about the form/to switch when reintegrating at old SVN server. Many thanks!Ait
After I do that (update branch completely from trunk and then user/trunk> svn merge ../branch@HEAD does merge the content. However if after that I do user/trunk> cd ../branch user/branch> svn merge ../trunk@HEAD it updates tags (but not content) for two screens of files. Is there a way for me to get rid of this annoying tag update -- the new svn is supposed to keep one tag in the upper level for everything, and here I have some individual specializations of that...Maurits
These instructions are not really applicable for versions of SVN >= 1.5, and I have long since given up on using SVN for anything other than simple checkouts from other peoples' systems, so I'm afraid I can't help you here. :(Humectant
C
3

I investigated the same problem. It is "feature" in Tortoise SVN 1.6.5. TortoiseSVN 1.5 works fine with our repositoty (SVN 1.5). TortoiseSVN 1.6.5 when rebasing adds files from mainline as NEW (without saving merge-history).
And reintegrating branch resuls in treating those files as conflicting with mainline.

I solved the problem by using feature of TortoiseSVN 1.6 "reintegrate branch". It's specifically purposed for feature-branches.

-- Alexey Korsun

Catarina answered 7/10, 2009 at 15:33 Comment(1)
Thanks. Out of all the discussion on SO about this "tree conflict" issue, this one helped me fix it properly.Boisvert
A
2

Here's a little more info to contribute to @Rytmis answer that helps me keep this straight.

High-level steps of making the trunk exactly like a branch or tag:

  1. Checkout from the trunk.
  2. Using working copy of trunk, merge from trunk to branch/tag.
  3. Commit.

Example 'svn' command line commands:

svn checkout <trunk url>
cd trunk
svn merge <trunk url> <branch/tag url>
svn commit -m "<message>"
Admiration answered 14/11, 2014 at 16:34 Comment(1)
This is a "2-URL" merge, which according to the docs, is meant to merge two branches into one (working directory). So the two URLs are sources, and the destination is the working dir. Probably not what OP wanted.Gerbil
G
1

I could not really figure out how the above solution was to work so my work around is different. First I made sure the branch contained all the changes from the trunk.

1)I got a fresh copy of the trunk. 2)I exported the branch to a temporary location using the tortoise svn export. 3)I used windows explorer to copy the entire branch tree over to the trunk and overwrote all files 4)I used the check for changes command on tortoise and included all unrevisioned files checkbox. 5)I selected all the files and clicked add.

You should use solutions that have not been built so the unrevisioned files do not include output.

I cant wait until we upgrade to 1.5+

Gerena answered 23/10, 2009 at 18:17 Comment(0)
E
1

Select revisions to Merge while selecting "Merge a range of rivisions" option using TortoiseSVN. This will prevent tree conflicts for same files coming again for each merge operation.

Ermaermanno answered 16/7, 2012 at 10:5 Comment(0)
B
0

I think I solved that problem. 1. Right click "branch" which you merged. 2. Click Tortoise SVN >> Merge 3. "Merge a range of revisions" and Next 4. !!!CHECK "Reverse Merge"!!! , URL to Merge from "branch", specific range "recently merged revision", and Next 5. Next 6. SVN Commite

After that I can merge from branch into trunk.

Brockman answered 28/6, 2017 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.