处理 SVN 分支重复合并的正确方法是什么?
这里我们有一个 SVN 存储库,其中有一个主干和一个用于新版本开发的分支。
该分支现在即将发布,因此我决定将分支重新集成回主干。显然,其中发生了一些冲突。包括很多来自主干中已删除的文件的树冲突。
我很高兴地解决了所有冲突并提交了行李箱。
问题是,我们随后对分支进行了一些较小的更改,因此我再次重新集成分支,并且发生了所有相同的树冲突。解决它们不是问题,但是问题很多,需要一段时间才能手动检查和解决它们,而且我不想每次进行更改和重新集成时都必须经历相同的解决过程。我原以为 SVN 会识别出该分支已经重新集成过一次,并且仅从上次重新集成发生的点开始合并。
当我打开修订图时,它显示主干和分支被拆分的点,但不显示合并。应该吗?
服务器:WinServer2003(R2sp2)、VisualSVNServer(1.7.2)。 客户端:WindowsXP(sp3),我一直使用TortoiseSVN(1.6.5)来完成所有这些,但我还安装了命令行客户端。
我通过确保主干是最新的并使用 TortoiseSVN 进行合并来进行合并,并在出现选项对话框时选择“重新集成分支”。我将合并深度设置为“工作副本”
我是否错误地处理了这种情况?我应该做一些不同的事情吗?
(也许我们的存储库布局错误。我们从主干分支,在分支中对新版本进行了所有更改,现在版本是由于我们将分支合并回主干。也许这是错误的方法,我读过一些人以相反的方式做这件事,在主干中进行所有更改,并仅在您几乎准备好发布并且分支成为受支持的发行版本时才创建分支)
Here we have have an SVN repository with a trunk and a branch for development on a new release.
The branch is nearing ready for release now so I decided to reintegrate the branch back down to the trunk. Obviously there were some conflicts. Including quite a lot of tree conflicts from files that had been deleted in the trunk.
I resolved all the conflicts happily enough and committed the trunk.
The problem is that we then made a few more minor changes to the branch, so I went to reintegrate the branch again and all the same tree conflicts occurred. Resolving them isn't a problem, but there are quite a lot and it takes a while to check and resolve them all manually and I don't want to have to go through the same resolution processes every time I make a change and reintegrate. I had expected SVN to recognise that the branch had already been reintegrated once and only merge from the point the last reintegration had occurred.
When I open up the revision graph, it shows the trunk and the point that the branch was split off, but it doesn't show the merge. Should it?
Server: WinServer2003 (R2sp2), VisualSVNServer (1.7.2).
Client: WindowsXP(sp3), I've been using TortoiseSVN (1.6.5) to do all of this, but I also have the command line client installed.
I do the merge by making sure I have the trunk up to date, and using TortoiseSVN to do a merge, and I select "Reintegrate a branch" when presented with the option dialog. I set the merge depth to "Working copy"
Am I handling this scenario incorrectly? Should I be doing something differently?
(Perhaps we have our repository layout wrong. We branched from the trunk, made all the changes for the new release in the branch, now the release is due we are merging the branch back down to the trunk. Perhaps this is the wrong approach, I've read about some people doing it the other way round, make all the changes in the trunk, and make the branch only when you are nearly ready for release and the branch becomes the supported release version)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下内容摘自本章末尾SVN 书的:
The following is from the end of this chapter of the SVN book:
在这种情况下,在您完成开发之前,我不会将代码从分支合并到主干。
我会从主干合并到分支,以确保您的分支与应用于主干的任何修复保持最新。定期执行此活动以确保您的开发分支包含所有修复。然后,在开发成为实时发布时,将分支合并到主干作为一次性活动。
我的回答做了一些假设,包括:
分支
版本(即不维护遗留版本
版本)
希望有帮助。
In this situation I would not merge code from the branch to the trunk until after you've completed the development.
I would merge from trunk to branch to ensure your branch is up to date with any fixes applied to the trunk. Carry out this activity periodically to ensure your dev branch contains all fixes. Then at the point at which the development becomes the live release do the merge from branch to trunk as a one off activity.
My answer makes a few assumptions including:
branches
version (i.e. not maintaining legacy
versions)
Hope that helps.
现在实际上可以进行重复的双向合并
请注意。这个答案解释了它是如何完成的,但如果您错过任何步骤,您将感到抱歉。例如, --reintegrate 合并必须完全微不足道(所有差异都已在分支中解决),否则当您继续在分支中工作时,您将默默地错过在 --reintegrate 合并步骤中所做的更改。另一种方法是每次在 --reintegrate 之后删除并重新创建分支。
至少在 svn 1.6 版及更高版本中,您可以进行重复的双向合并。您可以使用 svn merge 多次从“主”分支合并到子分支,但是每次将分支合并回主分支时,您都必须提供选项
--reintegrate 如其他答案中所述。
您还需要做的是告诉您的分支您已在第二个手动步骤中将其集成(签出并更新该分支),
此处的命令 391 代表合并您刚刚在 calc/trunk 中执行的 --reintegrate 分支提交的提交号。
如果您错过了它,它可能仍然有效,或者您可能需要在下次合并时重新解决已经解决的合并冲突。在仅记录步骤之后,您的分支就可以进行进一步的工作或合并。
这很愚蠢(特别是如果您像我一样被
Git
宠坏了,一切都正常工作),但如果您按照这个仪式进行操作,它就会起作用,并且两个分支始终对新提交开放。整个事情记录在 SVN 书中 重新整合两次
It is now actually possible to do repeated bi-directional merging
A word of caution. This answer explains how it is meant to be done, but if you miss any step you will be sorry. For example, the --reintegrate merge must be completely trivial (all differences already resolved in the branch) since else you will silently miss getting the changes you did in the --reintegrate merge step when you continue working in your branch. The alternative is to instead delete and re-create the branch each time after --reintegrate .
In at least svn version 1.6 and later you can do repeated bi-directional merging. You can merge from the 'main' branch to the child branch as many times as you like with just svn merge, but each time you merge the branch back to main, you have to give the option
--reintegrate as mentioned in the other answers.
What you also have to do is to tell your branch that you integrated it in a second manual step (with that branch checked out and updated) with the command
391 here represents the merge commit number from the --reintegrate branch commit you just did in calc/trunk .
If you miss it, it may still work, or you may need to re-resolve merge conflicts you already resolved next time you merge. After the record-only step your branches are ready for further work or merging.
It's silly (especially if you are spoiled by
Git
like me, where things just work), but if you do it according to this ritual it works, and both branches are always open for new commits.The whole thing is documented in the SVN book under reintegrate twice