如何在Windows上应用差异补丁? [英] How do I apply a diff patch on Windows?
问题描述
那里有很多程序可以创建diff补丁,但是我花了很多时间尝试应用它。我正在尝试分发补丁,我从用户那里收到有关如何应用补丁的问题。因此,我试图自己弄清楚它,但发现自己毫无头绪,而且我能找到的大多数工具都是命令行工具。 (我可以处理命令行,但是如果没有一个友好的图形用户界面,很多人会迷路。因此,这样做对他们没有好处。)
There are plenty of programs out there that can create a diff patch, but I'm having a heck of a time trying to apply one. I'm trying to distribute a patch, and I got a question from a user about how to apply it. So I tried to figure it out on my own and found out that I have no clue, and most of the tools I can find are command-line. (I can handle a command line, but a lot of people would be lost without a nice, friendly GUI. So those are no good for this purpose.)
使用TortoiseSVN。我有想要申请的补丁。我右键单击该补丁,然后在TortoiseSVN子菜单下有一个选项为应用补丁。它所做的只是拉出一个空窗口。
I tried using TortoiseSVN. I have the patch I'd like to apply. I right-click on the patch, and there's an option under the TortoiseSVN submenu that says "Apply patch." All it does is pull up an empty window.
所以我尝试打Open。它有两个选项:合并并应用统一差异。 (幸运的是,补丁采用统一的diff格式。)但是apply选项不能正常使用:它要求补丁和文件夹。不知何故,它忘记了要求文件将补丁应用到其中!!所以TortoiseSVN不能正常工作。是否有一个基于Windows GUI的实用程序,该实用程序将获取补丁程序和文件并正确地应用它?
So I tried hitting Open. It has two options: merge and apply unified diff. (The patch is in unified diff format, luckily.) But the apply option just plain doesn't work: It asks for the patch and a folder. Somehow it forgot to ask for the file to apply the patch to! So TortoiseSVN just plain doesn't work. Is there a Windows GUI-based utility that will take a patch and a file and apply it properly?
编辑:查看到目前为止的答复,看来Tortoise会仅当它是已版本化的文件时才对。这里不是这样。我需要能够将补丁应用到不是来自SVN存储库的文件。我刚刚尝试使用Tortoise,因为我碰巧知道SVN使用差异,并且必须知道如何创建和应用差异。
Looking at the replies so far, it seems that Tortoise will only do it right if it's a file that's already versioned. That's not the case here. I need to be able to apply a patch to a file that did not come out of an SVN repository. I just tried using Tortoise, because I happen to know that SVN uses diffs and has to know how to both create them and apply them.
推荐答案
应用补丁
- 找到并打开现有的SVN存储库目录
- 创建一个名为 merges的新目录(如果尚不存在)
- 复制文件继续进行下一步之前,要将.patch文件
- ADD和COMMIT应用于svn存储库
- 右键单击合并,然后选择应用补丁...
- 双击列表中的文件
- 带有差异的修补文件显示在右窗格中
- 单击该窗格并单击 Save 或使用 File-> Save As ...
- Find and open an existing SVN repo directory
- Create a new directory named "merges", if it does not exist already
- Copy the file onto which you want to apply the .patch file
- ADD and COMMIT to the svn repository before you continue to the next step
- Right click on merges and choose Apply patch...
- Double click the file from list
- The patched file with diff is displayed on the right pane
- Click on that pane and hit Save or export with File->Save As...
如果您是从TortoiseMerge打开的,则为备用屏幕。在下面的屏幕中,目录指的是上面步骤2中提到的合并目录:
Alternative screeny if you Open from TortoiseMerge. In the screeny below, directory refers to the "merges" directory mentioned at step 2 above:
WinMerge GUI的屏幕截图:
Screenshot of WinMerge GUI:
这篇关于如何在Windows上应用差异补丁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!