处理 SVN 分支重复合并的正确方法是什么?

发布于 2024-08-08 12:01:56 字数 725 浏览 7 评论 0原文

这里我们有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我的痛♀有谁懂 2024-08-15 12:01:56

以下内容摘自本章末尾SVN 书的

在 Subversion 1.5 中,一旦从分支到主干完成了 --reintegrate 合并,该分支就不再可用于进一步的工作。它无法正确吸收新的主干更改,也无法再次正确地重新集成到主干。因此,如果您想继续处理您的功能分支,我们建议您销毁它,然后从主干重新创建它

The following is from the end of this chapter of the SVN book:

In Subversion 1.5, once a --reintegrate merge is done from branch to trunk, the branch is no longer usable for further work. It's not able to correctly absorb new trunk changes, nor can it be properly reintegrated to trunk again. For this reason, if you want to keep working on your feature branch, we recommend destroying it and then re-creating it from the trunk

柏拉图鍀咏恒 2024-08-15 12:01:56

在这种情况下,在您完成开发之前,我不会将代码从分支合并到主干。

会从主干合并到分支,以确保您的分支与应用于主干的任何修复保持最新。定期执行此活动以确保您的开发分支包含所有修复。然后,在开发成为实时发布时,将分支合并到主干作为一次性活动。

我的回答做了一些假设,包括:

  • 你有实时主干和开发
    分支
  • 你只有一个活着
    版本(即不维护遗留版本
    版本)

希望有帮助。

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:

  • You have live trunk and dev
    branches
  • You have only one live
    version (i.e. not maintaining legacy
    versions)

Hope that helps.

没︽人懂的悲伤 2024-08-15 12:01:56

现在实际上可以进行重复的双向合并

请注意。这个答案解释了它是如何完成的,但如果您错过任何步骤,您将感到抱歉。例如, --reintegrate 合并必须完全微不足道(所有差异都已在分支中解决),否则当您继续在分支中工作时,您将默默地错过在 --reintegrate 合并步骤中所做的更改。另一种方法是每次在 --reintegrate 之后删除并重新创建分支。


至少在 svn 1.6 版及更高版本中,您可以进行重复的双向合并。您可以使用 svn merge 多次从“主”分支合并到子分支,但是每次将分支合并回主分支时,您都必须提供选项

--reintegrate 如其他答案中所述。

您还需要做的是告诉您的分支您已在第二个手动步骤中将其集成(签出并更新该分支),

svn merge --record-only -c 391 ^/calc/trunk

此处的命令 391 代表合并您刚刚在 calc/trunk 中执行的 --reintegrate 分支提交的提交号。

如果您错过了它,它可能仍然有效,或者您可能需要在下次合并时重新解决已经解决的合并冲突。在仅记录步骤之后,您的分支就可以进行进一步的工作或合并。
这很愚蠢(特别是如果您像我一样被 Git 宠坏了,一切都正常工作),但如果您按照这个仪式进行操作,它就会起作用,并且两个分支始终对新提交开放。


整个事情记录在 SVN 书中 重新整合两次

此合并使用了引入的cherry-picking合并语法
在名为“Cherrypicking”的部分中。继续跑步
来自“重新集成分支”部分的示例,其中
修订版 X 是修订版 391:

$ cd my-calc-branch $ svn update Updating '.': Updated to revision
393. $ svn merge --record-only -c 391 ^/calc/trunk
--- Recording mergeinfo for merge of r391 into '.':  U   . $ svn commit -m "Block revision 391 from being merged into my-calc-branch."
 Sending        .

 Committed revision 394.

现在您的分支已准备好再次吸收主干的更改。将分支再次同步到主干后,您甚至可以再次重新集成分支。如有必要,您可以进行另一次仅记录合并以保持分支处于活动状态。冲洗并重复。

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

svn merge --record-only -c 391 ^/calc/trunk

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

This merge uses the cherry-picking merge syntax, which was introduced
in the section called “Cherrypicking”. Continuing with the running
example from the section called “Reintegrating a Branch”, where
revision X was revision 391:

$ cd my-calc-branch $ svn update Updating '.': Updated to revision
393. $ svn merge --record-only -c 391 ^/calc/trunk
--- Recording mergeinfo for merge of r391 into '.':  U   . $ svn commit -m "Block revision 391 from being merged into my-calc-branch."
 Sending        .

 Committed revision 394.

Now your branch is ready to soak up changes from the trunk again. After another sync of your branch to the trunk, you can even reintegrate the branch a second time. If necessary, you can do another record-only merge to keep the branch alive. Rinse and repeat.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文