4

据我了解,在 Subversion 中处理分支和合并的最常见(也是推荐的)方法是:

  • 创建分支作为主干的副本
  • 在分支上进行破坏性开发,在主干上进行常规开发
  • 这样做时,定期合并更改主干 - > 分支,以避免分支过于分散。使用合并跟踪(svn:mergeinfo),我可以运行svn merge ^/trunk,SVN 会自动从主干获取所有未合并的更改。
  • 分支上的工作完成后,将所有内容合并回来(在主干上:)svn merge --reintegrate ^/branch/foo,然后丢弃分支。

(例如,在 SVN 书籍的Basic Merging章节中进行了描述)。

现在我的问题:虽然这适用于“功能分支”,但有时还需要“发布分支”,它代表正在发布/即将发布的版本。

对于发布分支,根据我的经验,合并必须在两个方向上发生:

  • 来自发布分支的错误修复必须合并到主干(分支 -> 主干)
  • 但有时来自主干的错误修复(甚至是新功能)被认为对发布版本(或发布的更新)至关重要,因此必须合并主干 - >分支

我还没有发现任何关于 SVNsvn:mergeinfo将如何处理这个问题的确切信息。我可以双向合并(“双向合并”),并且仍然让 svn 跟踪合并的修订吗?

有什么陷阱吗?有什么特别要注意的吗?

4

2 回答 2

2

我可以双向合并(“双向合并”),并且仍然让 svn 跟踪合并的修订吗?

是的,您可以合并单个功能(通过合并特定的修订版),SVN 会对此进行跟踪。

于 2012-01-09T13:08:41.053 回答
2

Actually merging in both direction in SVN often causes much more pain (as compared to git). The problem is that if you merge trunk into branch and then later try to merge the changes on the branch back into trunk, SVN will try to merge the changes from trunk which were merged into the branch again which will cause many unnecessary conflicts. To work around the issue, you can "record-only" the commit(s) where you merged the trunk into branch before merging the branch into trunk. See Advanced Merging - Blocking Changes chapter in the SVN book for a general approach (but the sample they provide is not for that particular use case).

Example:

  1. Assume your merge of the trunk into branch created two commits r3857 and r3858 (I see that often when using NetBeans, it first creates directories and then the files).
  2. Then you did some additional fixes on that release branch.
  3. Now you want to merge it back into trunk. Before doing that do the following in your trunk directory:

    svn merge "^/project/branches/release-0.1" -r3857:3858 --record-only

  4. After that merge from the release-0.1 branch as usual. That will result in a lower number of conflicts as compared to a direct merge attempt.

  5. Before committing I sometimes revert some of the introduced changes (in particular SVN might for some reasons introduce svnmerginfo at file level when there are resolved tree conflicts).
于 2017-09-08T19:40:15.357 回答