问题描述
场景是:
- svn cp或mv一些文件
- 修改该文件
- svn diff> mypatch
在另一台机器上(相同的工作副本,但没有更改):
On other machine (same working copy, but no changes):
- 尝试应用mypatch.
- 失败->尝试修改不存在的文件.
在这种情况下,如何使svn diff生成适用于补丁的补丁,或者干净地应用svn diff生成的补丁?我不能承诺我想保留mergeinfo(因为明显的解决方法是将文件添加为全新文件,而不连接到前一个文件).
How can I make svn diff produce patch-appliable patch, or cleanly apply patch produced by svn diff in this case? I can't commit. I would like to preserve mergeinfo (because the obvious workaround is to add the file as totally new, without connection to the previous one).
推荐答案
通过Subversion,您可以指定要使用的diff二进制文件,以及要传递给它的参数.有关svn差异,请参见手册.
With subversion, you can specify which diff binary to use, and parameters to pass to it. See the manual on svn diff.
您想从svn diff生成一个常规的补丁文件,因此您希望svn diff看起来像普通的diff.试试这个:
You'd want to produce a regular patch file from a svn diff, so you'd want the svn diff to look like a normal diff. Try this:
svn diff --diff-cmd /usr/bin/diff -x "-i -b" > mypatch
...
patch -p0 < mypatch
概念证明:
echo "newline" >> README.txt
svn diff --diff-cmd /usr/bin/diff -x "-i -b" > mypatch
cp README.txt README.txt.patched
svn revert README.txt
patch -p0 < mypatch
diff README.txt README.txt.patched
打补丁后两个文件没有区别.
No difference in the two files after patching.
这篇关于当使用svn cp或svn mv时,如何使svn diff产生该补丁将应用的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!