Linux下的可视化补丁工具
我有一个文件和一个补丁。我想直观地应用补丁,看看补丁提出的更改在上下文中的外观如何,进行一些更正,然后保存生成的文件。
什么工具可以做到这一点?
这两个视觉差异工具(即融合、扩散、差异合并)都不能满足我的要求:它们不与补丁一起使用,它们只是合并整个文件。
I've got a file and a patch for it. I'd like to visually apply the patch, t.i. see how the changes proposed by the patch look in context, make some corrections, and save the resulting file.
What tool can do that?
Neither of the visual diff tools (i.e. meld, diffuse, diffmerge) do what I want: they don't work with patches, they merely merge whole files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我真的很喜欢Kompare。它只是 diff 的一个(非常好的)图形界面。
http://www.caffeinated.me.uk/kompare/
sudo apt-get install kompare
I really like Kompare. It is just a (very nice) graphical interface for diff.
http://www.caffeinated.me.uk/kompare/
sudo apt-get install kompare
请参阅将 vimdiff 与 diff 文件结合使用。
这将打开 GVim 并拆分窗口,原始窗口在左侧,应用的补丁在右侧。然后,您可以添加、删除或更改帅哥,并保存更改。 (好吧,如果您想创建一个 new.patch,您必须再次运行 diff,但这并不困难。)
See use vimdiff with a diff file.
This will open GVim and split the window, with the original on the left and the patch applied on the right. You can then add, remove, or change hunks, and save the changes. (Well, if you want to create a
new.patch
you'll have to rundiff
again, but that's not difficult.)您可以使用 emacs ediff 模式。
它可以让您以交互方式查看和验证每个块。
无论如何,我的 ~/bin 目录中有这个方便的脚本:
You may use the emacs ediff mode.
It lets you see and validate each chunk interactively.
For what it's worth, I have this handy script in my ~/bin directory:
另一种选择:如果您使用 Eclipse,则可以直观地生成和应用补丁。
Another option: if you use Eclipse, you can generate and apply patches visually.
使用视觉差异工具的想法是,您可以:
某些工具(例如 meld 或 diff)会自动与文件的先前提交版本进行比较。
关键的见解是,您可以应用补丁,只要您有备份副本,或者您正在进行干净的结账,他们就会丢弃您不喜欢的所有内容。
如果您对阅读和修改统一差异感到更自在,并且只想了解差异的更多上下文,那么 emacs 有一个相当独特的功能,即 next-error-follow-mode 查看 diff 文件(diff 主要模式)时。这显示了目标文件中差异行的上下文。
The idea with visual diff tools is that you can:
Some tools, such as meld or diffuse will automatically diff against the previous committed version of the files.
The key insight is that you CAN apply the patch, they discard everything you don't like as long as you have a backup copy, or if you are working on a clean checkout.
If you feel more comfortable with reading and modifying unified diffs, and just want to have more context for the diff, emacs has a fairly unique feature, which is next-error-follow-mode while viewing a diff file (diff major mode). That shows the context of a diff line in the target file.
在 Kompare(如果您喜欢 KDE,这是一个相当不错的软件)的平台上,我同意 Eclipse 是一个不错的选择。
我一直是一个不情愿的 Eclipse 用户,而且这些工具的工作效果一直给我留下了深刻的印象(一旦平台最终启动)。
在 Fedora 上,我几乎为每个主要版本控制引擎安装了每个前端(SVN - 也为我的 Windows 机器、Mercurial、git 等提供服务);
Meld 非常好(虽然没有补丁界面)。
淹没效果也很好。
但由于 Eclipse 确实知道如何应用补丁,并且一旦我想出在包含工作副本的文件夹中创建项目,工作副本项目就会自行创建,因此它可能会成为我最喜欢的 SVN 前端。
On platforms where Kompare (a fairly nice piece of software if KDE is your cup of tea), I agree that Eclipse is a great option.
I have consistently been a reluctant Eclipse user AND I am consistently impressed by how well the tools work (once the platform finally starts up).
On Fedora, I've got just about every front end installed for each of the main version control engines (SVN - also serving my Windows machines, Mercurial, git, etc.);
Meld is quite nice (no patch interface though).
Submerge works well also.
But since Eclipse does know how to apply patches and Working Copy project created itself once I figured out to create the project in the folder containing my working copy, it may become my favorite SVN front end.
我通常使用 GitExtensions(.NET 和 Mono),它也支持交互式应用补丁。我希望您已经熟悉 git。
编辑:此行下面提到的所有内容似乎都不能直接在 KDiff3 中使用。正如我之前提到的:我还没有尝试过。
GitExtension通常使用KDiff3作为diff工具,它可以查看补丁。
http://kdiff3.sourceforge.net/doc/kpart.html
将其用于补丁它只有两个窗口视图(编辑)并且不支持合并:(但它也支持完整文件夹等上的3路差异。
实际上我从未尝试过使用补丁。
I normally use GitExtensions (.NET and Mono) which also supports applying patches interactively. I hope you are already familiar with git.
Edit: Everything mentioned below this line doesn't seem to be available directly in KDiff3. And as I mentioned before: I haven't tried it yet.
GitExtension normally uses KDiff3 as diff tool, which is able to view patches.
http://kdiff3.sourceforge.net/doc/kpart.html
Using it for patches it has only a two window view, (edit) and doesn't support merging :( but it also supports 3 way diff on complete folders etc.
Actually I never tryed it with patches.
xxdiff
是否符合您的要求?Does
xxdiff
do what you are looking for?我会用融合。
创建文件的两份副本,一份没有补丁,另一份带有补丁。使用 meld 来比较它们,您可以准确地看到补丁正在更改的内容并根据需要进行更改。
说真的,为什么这么难?
I'd use meld.
Create two copies of the files, one without and another with the patch. Use meld to compare them, and you can see exactly what the patch is changing and make changes as necessary.
Seriously, why is this so hard?