Linux下的可视化补丁工具

发布于 2024-08-14 08:28:10 字数 150 浏览 9 评论 0原文

我有一个文件和一个补丁。我想直观地应用补丁,看看补丁提出的更改在上下文中的外观如何,进行一些更正,然后保存生成的文件。

什么工具可以做到这一点?

这两个视觉差异工具(即融合、扩散、差异合并)都不能满足我的要求:它们不与补丁一起使用,它们只是合并整个文件。

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 技术交流群。

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

发布评论

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

评论(9

烟酒忠诚 2024-08-21 08:28:11

我真的很喜欢Kompare。它只是 diff 的一个(非常好的)图形界面。

http://www.caffeinated.me.uk/kompare/

sudo apt-get install kompare

创建和应用补丁

Kompare 能够创建补丁文件
仅列出差异
两个比较的文本文件 A 和
B. 此外,Kompare 可以应用补丁
以这种方式创建的文件
原始文件A,以这种方式,
重新计算内容
对应的文件B。这是一个
舒适实用的通过
将文件的更正版本更改为
已经有一个旧的朋友
同一文件的版本,因为只有
(相对较小的)补丁文件有
被交付并且接收者可以
生成更正后的文件
将补丁应用到原始版本上
文件。

创建并应用的补丁
Kompare 与补丁文件兼容
由命令生成或应用
线路接口 diff 实用程序,因为
Kompare 实际上只是一个图形
前端到 diff 和补丁是
由补丁创建并应用,其中
被 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

Creating and applying patches

Kompare is able to create a patch file
which lists only the differences
between two compared text files A and
B. Further, Kompare can apply a patch
file which was created this way to an
original file A and, in this manner,
recompute the contents of the
corresponding file B. This is a
comfortable utility for passing a
corrected version of a file to a
friend who already has an older
version of the same file, because only
the (relatively small) patch file has
to be delivered and the receiver can
generate the corrected file by
applying the patch to the original
file.

The patches created and applied by
Kompare are compatible to patch files
generated or applied by the command
line interface diff utility, because
Kompare is in fact merely a graphical
front end to diff and the patches are
created and applied by patch, which
gets called by Kompare.

零度° 2024-08-21 08:28:11

请参阅将 vimdiff 与 diff 文件结合使用

gvim original.file +'vert diffpa the.patch'

这将打开 GVim 并拆分窗口,原始窗口在左侧,应用的补丁在右侧。然后,您可以添加、删除或更改帅哥,并保存更改。 (好吧,如果您想创建一个 new.patch,您必须再次运行 diff,但这并不困难。)

See use vimdiff with a diff file.

gvim original.file +'vert diffpa the.patch'

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 run diff again, but that's not difficult.)

绾颜 2024-08-21 08:28:11

您可以使用 emacs ediff 模式
它可以让您以交互方式查看和验证每个块。
无论如何,我的 ~/bin 目录中有这个方便的脚本:

#!/bin/bash
if [ "$1" == "--text" ] ; then shift; fi
if diff --brief $1 $2 ; then 
exit 0 
else
emacs -fn 8x13bold --eval '(ediff-files "'$1'" "'$2'")'
fi

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:

#!/bin/bash
if [ "$1" == "--text" ] ; then shift; fi
if diff --brief $1 $2 ; then 
exit 0 
else
emacs -fn 8x13bold --eval '(ediff-files "'$1'" "'$2'")'
fi
夏至、离别 2024-08-21 08:28:11

另一种选择:如果您使用 Eclipse,则可以直观地生成和应用补丁。

Another option: if you use Eclipse, you can generate and apply patches visually.

水水月牙 2024-08-21 08:28:11

使用视觉差异工具的想法是,您可以:

  1. 制作修补文件的备份副本(或整个树的新原始签出)
  2. 应用补丁
  3. 使用视觉差异工具查看上下文中的更改
  4. 对文件进行任何所需的更改视觉差异工具中的修补文件。

某些工具(例如 meld 或 diff)会自动与文件的先前提交版本进行比较。

关键的见解是,您可以应用补丁,只要您有备份副本,或者您正在进行干净的结账,他们就会丢弃您不喜欢的所有内容。

如果您对阅读和修改统一差异感到更自在,并且只想了解差异的更多上下文,那么 emacs 有一个相当独特的功能,即 next-error-follow-mode 查看 diff 文件(diff 主要模式)时。这显示了目标文件中差异行的上下文。

The idea with visual diff tools is that you can:

  1. make a backup copy of the patched file (or a new pristine checkout of the whole tree)
  2. apply the patch
  3. use the visual diff tool to review the changes in context
  4. make any desired change to the patched file within the visual diff tool.

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.

落花随流水 2024-08-21 08:28:11

在 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.

半山落雨半山空 2024-08-21 08:28:11

我通常使用 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.

何止钟意 2024-08-21 08:28:11

xxdiff 是否符合您的要求?

Does xxdiff do what you are looking for?

凑诗 2024-08-21 08:28:11

我会用融合。

创建文件的两份副本,一份没有补丁,另一份带有补丁。使用 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?

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