是否可以根据已提交的更改在 Eclipse 中创建补丁?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1749356/
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
Is it possible to Create Patch in Eclipse from changes that have already been committed?
提问by mikej
I've used the Create Patch facility in Eclipse to create patches for uncommitted changes. I'm looking for a way to create patches in Eclipse for changes that have already been committed to the VCS.
我已经使用 Eclipse 中的 Create Patch 工具为未提交的更改创建补丁。我正在寻找一种在 Eclipse 中为已经提交给 VCS 的更改创建补丁的方法。
Unless I've missed something I don't think this is possible, but is there a plugin that adds this capability? e.g. enabling you to select two versions in the History view and create a patch between them or comparing two branches and being able to create a patch from the results in the Synchronize view?
除非我遗漏了一些东西,否则我认为这是不可能的,但是是否有插件可以添加此功能?例如,允许您在历史视图中选择两个版本并在它们之间创建补丁或比较两个分支并能够从同步视图中的结果创建补丁?
I'm happy creating such patches from the command line but am looking for a way to streamline/integrate the process if possible.
我很高兴从命令行创建这样的补丁,但如果可能的话,我正在寻找一种简化/集成过程的方法。
Thanks for any help.
谢谢你的帮助。
Update:if any suggestions are specific to a particular source control system I'm particularly interested in CVS, SVN and Mercurial. Thanks again.
更新:如果有任何针对特定源代码控制系统的建议,我对 CVS、SVN 和 Mercurial 尤其感兴趣。再次感谢。
回答by Thomas Jung
With subclipse you can select two revisions of a directory in the history view, compare them and save the patch as a unified diff.
使用 subclipse,您可以在历史视图中选择一个目录的两个修订版,比较它们并将补丁保存为统一的差异。
回答by Marcio Romualdo
I just made a patch SVN after a commit! :)
我只是在提交后做了一个补丁 SVN!:)
- Enter in "SVN Repository"
- Go to the root of the project.
- Click on "Compare"
- Select "Unified diff to output file"
- Click on "Select" and choose the name and location of the file
- Click "Ok"
- 进入“SVN存储库”
- 转到项目的根目录。
- 点击“比较”
- 选择“统一差异到输出文件”
- 单击“选择”并选择文件的名称和位置
- 点击“确定”
回答by Nicholas DiPiazza
I did some extensive research... and I've found out that there is no way to use the actual Eclipse Comparison Editor to generate a .patch file based on the differences in the "Local History" section.
我做了一些广泛的研究......我发现没有办法使用实际的 Eclipse 比较编辑器根据“本地历史”部分的差异生成 .patch 文件。
I am going to create a new feature request for this.
我将为此创建一个新的功能请求。
回答by Jidehem
It's possible to do it using the "SVN Repository explorer" perspective.
可以使用“SVN Repository explorer”视角来完成。
- Navigate to the root element you want to compare (typically the trunk folder)
- Show "History view" (if not already displayed)
- Select two revisions from "History view"
- Right-click on one of the two revisions and select "Create Patch..." in the contextual menu.
- 导航到要比较的根元素(通常是主干文件夹)
- 显示“历史视图”(如果尚未显示)
- 从“历史视图”中选择两个修订
- 右键单击两个修订版本之一,然后在上下文菜单中选择“创建补丁...”。
回答by RedYeti
As per the other answers, no, it is not currently possible.
根据其他答案,不,目前不可能。
But for now, here's a manual work-around with SVN as the example (I imagine other VCSs will allow very similar comparisons):
但是现在,这里有一个以 SVN 为例的手动解决方法(我想其他 VCS 将允许非常相似的比较):
- Create a second Eclipse Workspace; Workspace 2.
- Ensure that Workspace 2 has the right code for the "target" of the merge and the original Workspace 1, has the code you forgot to take a patch from.
- Manually compare Workspace 1 and 2 using a merge tool capable of comparing directories (On Windows, I like Araxis Merge, but WinMerge works too).
- Open each file and ensure only your changes are in it, if there are other changes, you'll have to take each of your changed lines across, if no one else has changed the target file, you can copy the whole file across.
- Synchronise Workspace 2 (but do not check in!) so you can see the changes you've now got there.
- In Workspace 1, open "SVN Repository Exploring Perspective"
- Right click the folder where the code was checked in (something under "branches" or "trunk" probably) -> "Compare..." and it should already have filled in the revision number just beforeyour check in.
- You can now see the changes from the code you checked in (which you forgot to take a patch of) with the version before you checked it in.
- Have Workspaces 1 and 2 open side by side and run each changed file visually to ensure they match everything from 1 now appears in 2.
- 创建第二个 Eclipse 工作区;工作区 2。
- 确保工作区 2 具有用于合并“目标”的正确代码,而原始工作区 1 具有您忘记从中获取补丁的代码。
- 使用能够比较目录的合并工具手动比较工作区 1 和 2(在 Windows 上,我喜欢 Araxis Merge,但 WinMerge 也可以工作)。
- 打开每个文件并确保其中只有您所做的更改,如果有其他更改,则必须将更改的每一行都进行一遍,如果没有其他人更改了目标文件,则可以复制整个文件。
- 同步工作区 2(但不要签入!),这样您就可以看到您现在所做的更改。
- 在工作区 1 中,打开“SVN Repository Exploring Perspective”
- 右键单击签入代码的文件夹(可能在“分支”或“主干”下)->“比较...”,它应该已经在签入之前填写了修订号。
- 现在,您可以在签入之前查看版本中签入的代码(您忘记打补丁)的更改。
- 让工作区 1 和 2 并排打开,并直观地运行每个更改的文件,以确保它们与现在出现在 2 中的 1 中的所有内容相匹配。
Very, very tedious but it should pick up all the changes.
非常,非常乏味,但它应该接受所有的变化。
回答by Kuba
When I couldn't make this in Eclipse (I needed to work with CVS only), I tried other software available and found that SmartCVS can do it. However, this function is available only in the Pro paid version and it takes a bit of time (kind of slow in comparison) when you have more code.
当我无法在 Eclipse 中做到这一点时(我只需要使用 CVS),我尝试了其他可用的软件,发现 SmartCVS 可以做到。但是,此功能仅在 Pro 付费版本中可用,并且当您有更多代码时需要一些时间(相比之下有点慢)。
I would like to know about some open source software with this ability, if someone knows about it. Thanks
我想知道一些具有这种能力的开源软件,如果有人知道的话。谢谢