为什么将分支提交到仍未触及的主干会导致冲突?

发布于 2024-10-29 13:46:10 字数 878 浏览 1 评论 0原文

我的第一次大目录合并经历了一段艰难的时光,希望能找到关于为什么我会收到这些错误的线索。

一周前,我对 trunk/ 中的代码进行了分支,并对branches/myBranch 中的代码进行了很多更改,并决定是时候将它们合并到 trunk/ 中了。此后主干中没有任何代码被触及,它与新代码分支时完全相同,所以我认为这意味着不会出现冲突。

似乎是错误的假设,据我所知,当尝试将新代码合并到主干和丢失文件的报告时会出现一堆冲突。有人可以澄清为什么会发生这种情况吗?

这是基本事实:

  • 代码在修订版 19466 中进行了分支。
  • 此后主干一直未受影响。没有变化(最后更改版本:19453)。
  • 该分支(不幸的是?)是在本地完成的,并进行了一些更改。
  • 我尝试使用以下命令合并分支介绍主干中的更改:svn merge -r19466:HEAD Branches/myBranch trunk/。 (无论我是站在后备箱中并跳过最后一个参数,还是只是执行上述操作,都没有关系)
  • Subversion 抱怨缺少文件 fooDao。 <代码>! C trunk/fooDao.java

    <代码>>本地缺失,合并时传入编辑

    该文件在创建分支的同一提交(19466)中被重命名,但我认为 subversion 应该选择它,因为它是使用 svn move 发出的。日志显示了它的祖先:

    ... /branches/myBranch/fooDao.java(来自 /branches/myBranch/fooDato.java:19452)

  • 如果您想知道为什么即使没有代码更改,修订号也会增加,这是因为它是一个包含许多其他(活动项目)的共享存储库)。

Having a rough time with my first big directory merge and was hoping for clues as to why I am getting these errors.

I branched off the code in trunk/ a week ago and made a lot of changes to the code in branches/myBranch, and decided that it was time to merge them into trunk/. No code has since been touched in the trunk, it is exactly the same as when the new code branched of, so I thought that this meant no conflicts could arise.

False assumption, it seems, as I know get a heap of conflicts when trying to merge the new code into trunk and reports of missing files. Could someone clarify why this is happening?

This is the basic facts:

  • The code was branched in revision 19466.
  • The trunk has since been untouched. No changes (Last Changed Rev: 19453).
  • The branch was (unfortunately?) done locally, incorporating some changes.
  • I tried merging the changes from the branch intro trunk using the following command: svn merge -r19466:HEAD branches/myBranch trunk/. (It didn't matter if I was standing in trunk and skipping the last argument, or just doing the above)
  • Subversion complains about a missing file, fooDao.
    ! C trunk/fooDao.java

    > local missing, incoming edit upon merge

    This file was renamed in the same commit that the branch was created (19466), but I thought that subversion should pick this up since it was issued using svn move. The log shows its ancestry:

    ...
    A /branches/myBranch/fooDao.java (from /branches/myBranch/fooDato.java:19452)

  • If you are wondering why the revision numbers increase even without code changes, it is because it is a shared repository containing many other (active projects).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

2024-11-05 13:46:10

我遇到的错误的主要原因是由于以不健全的方式创建分支。如果您正确进行分支,branch点将具有与主干(在该版本中)完全相同的文件。如果要在修订版 100 中创建的分支合并到主干中,我可以使用 svn merge -r100:HEAD ../branches/myBranch ./trunk 并获取对这些文件的更改修订。

不幸的是,在创建分支之前,我在 trunk/ 中进行了本地修改。这些修改被复制到新分支中然后提交。因此,myBranch 和 trunk 中的文件在创建分支时是不同的。为了纠正这种情况,我必须在创建分支之前找到一个修订版本以进行合并(例如:rev99)并从那里进行合并。
出现的任何冲突都可以通过选择“tf”(完整)从冲突的分支获取完整文件来解决。我可以做这个快速修复,因为树干没有被碰过,也没有发生任何变化。

总结一下:为了避免出现问题,请通过确保

The main cause of the errors I experienced were due to creating the branch in a unsound way. If you do branching correctly the brainch point will have exactly the same files as in the trunk (in that revision). If a branch created in revision 100 were to be merged into trunk I could then just use svn merge -r100:HEAD ../branches/myBranch ./trunk and get just the changes to the files in those revisions.

Unfortunately I had local modifications in trunk/ before creating the branch. These modifications were copied into the new branch and then committed. Thus the files in myBranch and trunk were different at the point of creation of the branch. To remedy the situation I had to find a revision before the branch creation to merge from (say: rev99) and do the merge from there.
Any conflicts that appeared were simply solved by choosing "tf" (their full) to get the full file from the branch in a conflict. I could do this quick fix because the trunk was untouched and had no changes.

To sum it up: to avoid problems, do branching correctly by making sure

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