Java 如何使用 Eclipse 合并工具将 CVS 分支合并到 HEAD 中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/530209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 15:52:31  来源:igfitidea点击:

How do I merge a CVS branch into HEAD using the Eclipse merge tools?

javaeclipsemergecvs

提问by Alex Argo

I'm currently working in a branch I created using the Team-->Branch. How do I use Team-->Merge to merge my changes to the branch back to head?

我目前在我使用 Team-->Branch 创建的分支中工作。如何使用 Team-->Merge 将我对分支的更改合并回头部?

回答by Alex Argo

Ensure that the destination is loaded into your workspace. This is the most important part and the part I missed when trying to do it a couple of times.

确保目标已加载到您的工作区中。这是最重要的部分,也是我尝试做几次时错过的部分。

For example, if you wish to merge your changes into HEAD, make sure the project is shared with HEAD in your workspace(not the branch you have been working on). To do this, select the project and choose Team > Replace With > Another Branch or Versionfrom the context menu. Then select the branch to replace with.

例如,如果您希望将更改合并到 HEAD,请确保在您的工作区(而不是您一直在处理的分支)中与 HEAD 共享该项目。为此,请选择项目并Team > Replace With > Another Branch or Version从上下文菜单中进行选择。然后选择要替换的分支。

From this point, choose Team > Mergeand then select the branch you want to merge into HEAD.

从这一点开始,选择Team > Merge然后选择要合并到 HEAD 中的分支。

回答by Alex Argo

I struggled with this also and the above answer was not helpful until I checked the "Perform the merge into local workspace" radio button.

我也为此苦苦挣扎,直到我选中“执行合并到本地工作区”单选按钮之前,上述答案都没有帮助。

Unfortunately, I was not able to preview my merge before the two files were merged.

不幸的是,在合并两个文件之前我无法预览我的合并。

回答by Anshu Jain

Frankly, there is no easy, clean way unless you have been anticipating and planning for this merge right from the time you branched.

坦率地说,没有简单、干净的方法,除非您从分支时就一直在预期和计划此合并。

However, I found a hack that works perfectly, which I've described in a blog post.

但是,我发现了一个完美运行的 hack,我在博客文章中对此进行了描述

回答by Clarkey

I just had to do this. While the answers above were similar, I found they weren't specific to what I needed to do.

我只是不得不这样做。虽然上面的答案很相似,但我发现它们并不是我需要做的事情。

  • As already stated, ensure your detination branch (usually head) is already checked out.
  • Then, highlight the files you know have changed in your branch (or the whole project, whatever), and select Team -> Merge. In the dialog box that pops up, choose for "Branch or version to be merged (end tag)", the source branch you want to take your files from.
  • In my case this auto populated the "Common base version (start tag)", but if it isn't, then this will be the tag that was created when the branch was created.
  • 如前所述,确保您的 detination 分支(通常是 head)已经被检出。
  • 然后,突出显示您知道在您的分支(或整个项目,无论如何)中已更改的文件,然后选择Team -> Merge. 在弹出的对话框中,为“ Branch or version to be merged (end tag)”选择要从中获取文件的源分支。
  • 在我的例子中,这个自动填充了“ Common base version (start tag)”,但如果不是,那么这将是创建分支时创建的标签。

When you preview the changes they will appear in the normal CVS synchronise view. When you merge the files, they will be brought into your local workspace (which from earlier is your destination branch) as changes. At this point you will need to check them into CVS.

当您预览更改时,它们将出现在正常的 CVS 同步视图中。当您合并文件时,它们将作为更改被带入您的本地工作区(从前面开始是您的目标分支)。此时,您需要将它们检入 CVS。

回答by Brian

I was having trouble with this too. Here are the steps I take to merge (mostly taken from the online Eclipse help):

我也遇到了这个问题。以下是我合并的步骤(主要来自在线 Eclipse 帮助):

  1. When making my development branch (Team -> Branch) I ensure I have a root tag created for the branch, this is the tag CVS will use to determine what changes are due to the branch and what might have been committed from other efforts
  2. I complete my development on the branch and commit (Team -> Commit) all changes back to the repository
  3. Now that all my changes for the branch are in the repository I load the destination branch that I want to merge into, typically HEAD (Team -> Switch to Another Branch or Version)
  1. 在创建我的开发分支(Team -> Branch)时,我确保为该分支创建了一个根标记,这是 CVS 将用来确定哪些更改是由于该分支以及其他工作可能已提交的更改的标记
  2. 我在分支上完成了我的开发并将所有更改提交回存储库(团队 -> 提交
  3. 现在我对分支的所有更改都在存储库中,我加载要合并到的目标分支,通常是 HEAD(团队 -> 切换到另一个分支或版本

You are now ready to begin the actual Merging process. Here you will be picking which changes should come over and which should be discarded. Think of this process as a semi-automated development cycle, effectively a checkout, make changes, commit cycle. Only instead of manually inserting your changes you have compare tools to assist you along. After all you've already made all the code changes in your branch!

您现在已准备好开始实际的合并过程。在这里,您将选择哪些更改应该发生,哪些应该丢弃。将此过程视为一个半自动化的开发周期,实际上是一个结帐、更改、提交周期。只有您有比较工具来帮助您,而不是手动插入您的更改。毕竟,您已经在分支中进行了所有代码更改!

To Merge:

合并:

  1. Team -> Merge
  2. Branch or Version to be Merged (end tag): This is the name of your development branch tag
  3. Common Base Version: This is the name of your root tag for the branch (remember step 1 from the earlier section?). This should have been auto populated by the tool, but if not, add it yourself
  4. I like to Preview the merge in synchronize viewso I can ensure that nothing is getting in that shouldn't be. Depending on your bravery, this is the option I would suggest. Click the Finishbutton
  5. The Synchronize Perspective will come up and any differences found between your destination branch and your source branch will be shown in an expandable list in the left
  6. For any file you can open it in a comparison tool to see what it was before and merge changes individually (remember to save the file when done!) or you can right click on the file and select merge from the expandable list. If you manually merge with the comparison tool, you can select "Mark as Merged" in the expandable list to remove the file from your todo list.
  7. Once you've decided what to do with the file it will be removed from the list. The goal is to action each file
  8. Now that all your changes have been merged, switch back to the Java perspective and select Team -> Synchronize with Repository, the Synchronize Perspective will come back up.
  9. This time select Commit to push all your changes into the repository.
  10. Fin!
  1. 团队 -> 合并
  2. 要合并的分支或版本(结束标记):这是您的开发分支标记的名称
  3. 通用基础版本:这是分支的根标记的名称(还记得前面部分的第 1 步吗?)。这应该由工具自动填充,但如果没有,请自行添加
  4. 我喜欢在同步视图中预览合并,所以我可以确保没有任何不应该的东西。根据您的勇敢,这是我建议的选项。单击完成按钮
  5. Synchronize Perspective 将出现,目标分支和源分支之间发现的任何差异都将显示在左侧的可扩展列表中
  6. 对于任何文件,您可以在比较工具中打开它以查看它之前的内容并单独合并更改(完成后请记住保存文件!)或者您可以右键单击文件并从可扩展列表中选择合并。如果您使用比较工具手动合并,您可以在可扩展列表中选择“标记为已合并”,将文件从您的待办事项列表中删除。
  7. 一旦您决定如何处理该文件,它将从列表中删除。目标是操作每个文件
  8. 既然您的所有更改都已合并,请切换回 Java 透视图并选择Team -> Synchronize with Repository,同步透视图将重新出现。
  9. 这次选择 Commit 将所有更改推送到存储库中。
  10. 鳍!

Hope that helped. Provided below for reference is the contents of the help document that guided me to victory!

希望有所帮助。下面提供的参考是引导我走向胜利的帮助文档的内容!

Eclipse SDK Help - Merging a Branch

Eclipse SDK 帮助 - 合并分支

回答by Marcin Wasiluk

I agree this is working other way around, if changes in YOUR_BRANCH needs to be updated to HEAD,

我同意这是另一种方式,如果您的_BRANCH 中的更改需要更新为 HEAD,

1) commit changes to YOUR_BRANCH 2) swap local branch to HEAD 3) merge HEAD witch changes made in YOUR_BRANCH

1) 提交对 YOUR_BRANCH 的更改 2) 将本地分支交换到 HEAD 3) 合并在 YOUR_BRANCH 中所做的更改

therefore you need to be in HEAD and "take" changes from YOUR_BRANCH(instead of sending changes from YOUR_BRANCH to HEAD).

因此,您需要在 HEAD 中并从 YOUR_BRANCH 中“进行”更改(而不是将更改从 YOUR_BRANCH 发送到 HEAD)。