在 Eclipse 中进行 Subversion 合并的正确方法是什么?

发布于 2024-07-05 10:36:19 字数 239 浏览 6 评论 0原文

我非常习惯如何在 Eclipse 中进行 CVS 合并,而且我对 Subclipse 和 Subversive 与 SVN 存储库一起工作的方式感到满意,但我不太确定如何正确进行合并。

当我进行合并时,它似乎想要将合并的文件粘贴在我的项目中的单独目录中,而不是像我在 CVS 中习惯的那样覆盖要在合并中替换的旧文件。

这个问题并不是 Subclipse 或 Subversive 特有的。

谢谢您的帮助!

I'm pretty used to how to do CVS merges in Eclipse, and I'm otherwise happy with the way that both Subclipse and Subversive work with the SVN repository, but I'm not quite sure how to do merges properly.

When I do a merge, it seems to want to stick the merged files in a seperate directory in my project rather than overwriting the old files that are to be replaced in the merge, as I am used to in CVS.

The question is not particular to either Subclipse or Subversive.

Thanks for the help!

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

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

发布评论

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

评论(9

冷情妓 2024-07-12 10:36:19

将整个分支合并到主干

  1. 检查分支项目历史记录以确定分支的版本

    • 默认情况下,Eclipse 团队“历史记录”仅显示过去 25 个修订,因此您必须单击该视图中标记为“显示全部”的按钮
    • 当您说“显示全部”时,它会将您带回到分支日期之后,并显示主干的所有历史记录,因此您必须在分支位置搜索评论
    • 注意:如果您使用 Tortise SVN 执行相同的任务(导航到分支并选择“显示日志”),它将仅显示分支历史记录,以便您可以准确地知道分支开始的位置
  2. 所以现在我知道 82517 是该分支的第一个版本 ID分支历史。 因此,82517 之后的分支的所有版本都有我想要合并到主干中的更改

  3. 现在转到 Eclipse 工作区中的“主干”项目,然后选择“右键单击 - 团队 - 合并”

  4. 默认视图是 1 url 合并

    • 选择您要合并的分支的 URL
    • 在“修订”下选择“全部”
    • 按“确定”
  5. 这将带您进入“团队同步”视角(如果没有)您应该自己去那里)以解决冲突(见下文)

将更多分支更改重新合并到主干

  1. 检查主干项目历史记录以确定上次合并到主干的时间(您应该对此进行评论)

    • 为了便于讨论,我们假设这个版本是 82517
  2. 所以现在我知道任何大于 82517 的版本分支需要合并到主干

  3. 现在转到 Eclipse 工作区中的“主干”项目并选择“右”单击 - Team - Merge”

  4. 默认视图是 1 url 合并

    • 选择您要合并的分支的 URL
    • 在修订版下选择“修订版”单选按钮,然后点击“浏览”
    • 这将打开最新 25 个分支修订的列表
    • 选择所有编号大于 82517 的修订
    • 按“确定”(您应该在单选按钮旁边的输入字段中看到修订列表)
    • 按“确定”
  5. 这将带您进入“团队同步”视角(如果没有,您应该您自己去那里)以解决冲突(见下文)

< strong>解决冲突

  1. 你应该站在“团队同步”的角度。 这看起来就像用于提交目的的任何常规同步,您会看到新文件和有冲突的文件。

  2. 对于每个看到冲突的文件,选择“右键单击 - 编辑冲突”(不要双击该文件,它会弹出提交差异版本工具,这是非常不同的)< /p>

    • 如果您看到类似“<<<<<<.working”或“>>>>>>>.merge-right.r84513”的内容,那么您处于错误的编辑模式
  3. 解决了该文件中的所有冲突后,告诉文件“标记为合并”

  4. 一旦所有文件都没有冲突,您就可以同步您的 Eclipse 项目并将文件提交到 SVN

Merging an entire branch into trunk

  1. Inspect the Branch project history to determine the version from which the branch was taken

    • by default Eclipse Team "History" only shows the past 25 revisions so you will have to click the button in that view labeled "Show All"
    • when you say "Show All" it will take you back past the branch date and show you all the history for trunk as well so you'll have to search for your comment where you branched
    • NOTE: if you use Tortise SVN for this same task (navigate to the branch and select "Show Log") it will show you only the branch history so you can tell exactly where the branch began
  2. So now I know that 82517 was the first version ID of the branch history. So all versions of the branch past 82517 have changes that I want to merge into trunk

  3. Now go to the "trunk" project in your Eclipse workspace and select "right click - Team - Merge"

  4. The default view is the 1 url merge

    • select the URL of the branch from which you are merging
    • under Revisions select "All"
    • press OK
  5. This will take you to the "Team Synchronizing" perspective (if it doesn't you should go there yourself) in order to resolve conflicts (see below)

Re-Merging more branch changes into trunk

  1. Insepct the trunk project history to determine the last time you merged into trunk (you should have commented this)

    • for the sake of argument let's say this version was 82517
  2. So now I know that any version greater than 82517 in the branch needs to be merged into trunk

  3. Now go to the "trunk" project in your Eclipse workspace and select "right click - Team - Merge"

  4. The default view is the 1 url merge

    • select the URL of the branch from which you are merging
    • under Revisions select "Revisions" radio button and click "Browse"
    • this will open up a list of the latest 25 branch revisions
    • select all the revisions with a number greater than 82517
    • press OK (you should see the revision list in the input field beside the radio button)
    • press OK
  5. This will take you to the "Team Synchronizing" perspective (if it doesn't you should go there yourself) in order to resolve conflicts (see below)

Resolving Conflicts

  1. You should be at the "Team Synchronizing" perspective. This will look like any regular synchronization for commit purposes where you see files that are new and files that have conflicts.

  2. For every file where you see a conflict choose "right click - Edit Conflicts" (do not double click the file, it will bring up the commit diff version tool, this is VERY different)

    • if you see stuff like "<<<<<<< .working" or ">>>>>>> .merge-right.r84513" then you are in the wrong editing mode
  3. once you have resolved all the conflicts in that file, tell the file to "mark as merged"

  4. once all the files are free of conflicts you can then synchronize your Eclipse project and commit the files to SVN

甜妞爱困 2024-07-12 10:36:19

我通常检查两个分支,然后使用相互比较选项,对两个源树进行类似同步的比较。 将更改集成到一个分支后,您可以重新提交回存储库。

I typically check out both branches and then use the compare to each other option which does a synchronize-like compare of the two source trees. After integrating the changes into one branch, you can recommit back to the repository.

感情废物 2024-07-12 10:36:19

请记住,使用 svn 将修改后的树恢复到干净状态是相当容易的。 只需在合并目标分支上有一个干净的工作区,然后运行合并命令以从合并源分支导入修改,然后同步您的工作区,您将获得通常的 Eclipse 比较窗口,显示所有合并修改的文件和冲突。

如果由于某种原因你无法解决冲突,你可以在项目上使用 svn revert 并返回到干净的状态,否则你就就地进行合并,一旦完成就可以提交。 请注意,您不必提交,一旦处理完冲突,您还可以返回到开发视图,验证代码是否编译,运行单元测试等,然后再次同步并提交(一旦冲突在本地发生)解决了他们不会回来)

我上次看时,当您使用 subclipse merge 命令时,它将覆盖合并的文件(使用冲突标记来显示冲突区域)并将合并的原始左侧和右侧放在同一位置。 它不应该将任何东西放在不同的目录中。

根据经验,最好在一次提交中提交所有合并修改,并且仅在提交中包含合并修改,以便您可以在以后需要时回滚合并。

Remember that with svn reverting a modified tree to a clean state is fairly easy. Simply have a clean workspace on the merge destination branch and run the merge command to import the modifications from the merge source branch, then synchronize your workspace and you will get your usual eclipse comparison window showing all the merge modified files and the conflicts.

If for some reason you can't solve the conflicts you can svn revert on the project and go back to a clean state, otherwise you do the merge in place and once you are done you can commit. Note that you don't have to commit, once you are done handling the conflicts you can also return to the dev view, verify that the code compiles, run your unit tests, whatever and then synchronize again and commit (once the conflict are locally resolved they won't come back)

last time I looked, when you use subclipse merge command it will overwrite the merged file (using conflict markers to show conflicting areas) and put the original left and right side of the merge in the same place. it shouldn't put anything in different directories.

As a rule of thumb, it is best to commit all merge modifications in a single commit and to only have the merge modifications in the commit so that you can rollback the merge later if needed.

月依秋水 2024-07-12 10:36:19

首先,如果您看到“>>” 当您在 Eclipse 中查看文件时,这可能意味着您没有使用正确的比较编辑器查看文件。 尝试右键单击“项目”视图或“同步”视图中的文件,然后选择“编辑冲突”以打开比较编辑器,该编辑器将以图形方式而不是文本方式显示冲突区域。 请注意,“编辑冲突”出现的比较编辑器与您在“同步”视图中双击文件时获得的比较编辑器不同——双击比较编辑器显示当前文件与其存在方式之间的差异当您上次签出或更新它时,“编辑冲突比较”对话框显示两个更改源之间的差异(例如,您合并的更改与合并之前工作区中存在的更改)。

其次,您可能希望了解某些版本的 Eclipse subversive 插件中的一个错误,该错误会导致所有接受合并更改的文件被错误地标记为存在冲突。 这个错误已经被修复了,但是很多人似乎还没有更新来修复这个问题。 更多详细信息请参见:

https://bugs.eclipse.org/bugs/show_bug.cgi ?id=312585

Firstly, if you are seeing ">>>>>" and such in your files when you view them in Eclipse, this probably means that you are not looking at the file with the proper compare editor. Try right-clicking on the file in the Project view or Synchronize view and selecting "Edit Conflicts" to bring up a compare editor that will show you the conflicting regions graphically rather than as text. Note that the compare editor that comes up for "Edit Conflicts" is different from the one that you get when you just doubleclick on a file in the Synchronize view -- the doublieclick compare editor shows the differences between your current file and the way it existed when you last checked it out or updated it, while the Edit Conflicts compare dialog shows the differences between two sources of changes (for instance, the changes you merged versus the changes that existed in your workspace before you merged).

Secondly, you may wish to be aware of a bug in some versions of the Eclipse subversive plugin which causes all files that accepted merge changes to be incorrectly marked as having conflicts. This bug has been fixed, but a lot of people don't seem to have updated to get the fix yet. Further details here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=312585

独享拥抱 2024-07-12 10:36:19

使用Eclipse集成,它工作得很好。

与 CVS 的主要变化是,您仅合并分支中的增量,即从一个修订版本更改为另一个修订版本。
也就是说,您必须以某种方式跟踪正确的起始修订版(除非您有 svn 1.5 合并历史记录)。

如果您做对了,则只能由您使用比较编辑器来获得正确的更改。

Use Eclipse integration, it works perfectly fine.

The main change from CVS, is that you only merge deltas from a branch, ie changes from one revision to another.
That is to say you have to track the correct start revision somehow (unless you have svn 1.5 merge history)

If you got that right, it's only up to you to get the changes right with the compare editor.

绳情 2024-07-12 10:36:19

我建议不要尝试使用 Eclipse 的插件作为对 Subversion 的主要访问。

如果您在 Windows 上进行开发,TortoiseSVN 是我见过的用于 Subversion 访问的最佳程序。 浏览到您要合并的目录,右键单击它并使用 Tortoise SVN 合并选项。 假设是非交互式合并,一旦出现冲突,您必须仔细检查每个冲突文件并编辑冲突,然后再将其标记为已解决。 对于此过程,我推荐一个名为 KDiff3 的程序,它显示您的本地存储库副本(合并之前存储在 .svn 中的内容)、您的本地副本(包括任何更改)以及来自存储库的副本,并允许您轻松查看(甚至可以根据需要手动修改)合并的结果。 它还自动处理一堆小冲突。

KDiff3 是可移植的,TortoiseSVN 是 Windows shell 扩展,因此如果您使用其他环境,我会尝试仅使用 SVN 进行合并。 但这会更痛苦:)

I would advise not trying to use Eclipse's plugins as your primary access to Subversion.

If you are developing on Windows, TortoiseSVN is the best program that I have seen for Subversion access. Explore to the directory of which you wish to merge, right click on it and use the Tortoise SVN merge option. Assuming a non-interactive merge, once you get conflicts, you'll have to go through each conflicted file and edit the conflicts before marking them as resolved. For this process I recommend a program called KDiff3, which shows your local repository copy (what was stored in the .svn before the merge), your local copy (including any changes), and the copy coming from the repository, and allows you to easily see (and even hand-modify if needed) the result of the merging. It also handles a bunch of minor conflicts automatically.

KDiff3 is portable, TortoiseSVN is a windows shell extension, so if you're using another environment, I would try to just use SVN to merge. But that would be much more of a pain :)

£噩梦荏苒 2024-07-12 10:36:19

Eclipse 中的同步视图缺少的一件事是签入功能。 在团队同步视图中,我可以查看所有更改并解决冲突,因此在那里签入会相当直观,而不是返回 java 视图并进行签入。

The one thing that syncrhonize view in eclipse lacks is check-in capability. In Team synchronization view I can view all my changes and resolve conflicts, so it would be rather intuitive to check-in right there instead of going back to java view and do check-in.

风尘浪孓 2024-07-12 10:36:19

openCollabNet 的 subclipse 合并工具非常简洁。 有许多可用的合并类型,我刚刚用它无缝地执行了合并。 我推荐它。

openCollabNet's merge tool for subclipse is pretty neat. There are many merging types available and the merging I just performed with it when seamlessly. I recommend it.

极度宠爱 2024-07-12 10:36:19

我来到这里是因为我正在寻找一种在外部合并编辑器(KDIFF3)中合并的方法,但从 eclipse 开始合并。 我对上面提供的答案不满意。 所以这里是如何在 Eclipse 中将 kdiff3 配置为 SVN 的合并和差异编辑器:

转到 Windows -> > 首选项 → 团队 -> SVN-> 差异查看器
添加新配置(添加按钮):
扩展名或 mimetype:* - 如果您希望可以为不同的编辑器指定不同的 mimetype,我不需要这样,因此 alquantor。

差异
程序路径 C:\Program Files\KDiff3\kdiff3.exe (或任何您有合并编辑器的地方 - 对于 Windows 路径,请随意在评论中添加 Linux 版本或编辑此答案。)

参数:
${base} ${mine} ${theirs}

合并
程序路径 C:\Program Files\KDiff3\kdiff3.exe

参数:
${base} ${mine} ${theirs} -o ${merged}

这可能适用于其他合并编辑器,但使用不同的参数语法(弄清楚并让我们知道:))。

用法与往常一样(团队->编辑冲突)用于合并,比较->foo用于差异视图。

干杯

I landed here because I was looking for a way to merge in an external merge editor (KDIFF3) but start the merge from eclipse. I wasn't satisfied with the answers provided above. So here is ho to configure kdiff3 as merge and diff editor for SVN in eclipse:

go to Windows -> Preferences → Team -> SVN -> Diff Viewer
Add a new config (add button):
Extension or mimetype: * - if you wish you can specify different mimetypes for different editors, I didn't need that thus the alquantor.

Diff:
Program path C:\Program Files\KDiff3\kdiff3.exe (or wherever you have your merge editor - sry for the windows path, feel free to add a linux version in the comments or edit this answer.)

Arguments:
${base} ${mine} ${theirs}

Merge:
Program path C:\Program Files\KDiff3\kdiff3.exe

Arguments:
${base} ${mine} ${theirs} -o ${merged}

This will probably work as well for other merge editors, but with a different argument syntax (figure it out an let us know :) ).

The usage is as usual (team->edit conflicts) for merging and compare->foo for the diff view.

Cheers

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