开发者

SVN merge renamed projects into trunk

I'm currently trying to merge some changes from a branch back into the trunk, the changes in the branch debrand the name of each project in the trunk. So for simplicities sake开发者_高级运维 lets say the root of the trunk looks like this...

company-name-services
company-name-security
company-name-web

and the branch looks like so...

services
security
web

The following commands were run in the branch in order to get it into its current state...

svn mv company-name-services services
svn mv company-name-security security
svn mv company-name-web web

Following that code changes have occured in both the branch and the trunk. Now that I'm performing the merge, within my working copy for the trunk I have used Tortoise SVN to merge selecting 'Reintegrate a branch' as merge type and selecting the path to the branch as the 'From URL' as a result of running this I now have in my working copy...

company-name-services
company-name-security
company-name-web    
services
security
web

Folders company-name-* are marked for deletion and the other debranded folders are marked to be added. The problem being all files in the debranded project folders have no history infomation associated with them, and even worse changes that have occured in the trunk are not present in the debranded folders. I thought SVN would be intelligent enough to bring in changes from trunk and preserve history after a merge given that the folders were renamed using the svn command line tool. Are the results I'm reciving to be expected or is there some other way I should be performing the merge?


To understand why this happened you have to understand how svn does merging.

When you merge your branch back into trunk you actually merge every change that was done in the branch into trunk. When merging, svn will take every commit from your branch and, one by one, perform the same changes to your trunk.

Since the first change and probably the first commit you did to your branch was to rename the root directories, svn will do the same on trunk.

I believe you can overcome this by manually merge each sub-folder from your branch to the corresponding sub-folder in your trunk. I don't know the Tortois commands for this, but the command line would be like this (assuming you start on the root folder in trunk):

> cd company-name-services
> svn merge -r <insert first revision after rename>:HEAD <insert url to sub-folder in branch> .

and so on for each sub-folder


svn mv was the incorrect way to create the branches; that does a move. You should have used svn cp, which makes a copy of the trunk into the branch. Alternatively, you should have also used TortoiseSVN to create the branches first, and then used it again to do the merge.

What you did was move the trunk to the branch, work on the branch, and then moved the branch back to the trunk. There is no separate history to maintain.

See the SVN book, specifically Chapter 4, Branching and Merging, sub-heading Creating a Branch.


Apologies for replying in an answer I don't have the required rep to comment yet.

@Ken I may have not been clear in my post, I did not use svn mv to create the branch I used Tortoise to branch issueing a command which I believe would be the equivalent to something like this...

svn cp http://my.server/repos/myRepo/trunk \
    http://my.server/repos/myRepo/branches/my-branch 

on the command line, then from within the branch I issued the svn mv commands to rename the folders in the root of the repository.

@sstendal I'll try your suggestion when I get to work in the morning and reply with the outcome.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜