执行 svn remove 和 svn rename 后获取适用的补丁
我使用
svn remove
删除了一些文本文件。但 svn diff 显示为删除文件中的所有内容。应用该差异的补丁只会修改内容,不会删除文件。我使用 svn rename 重命名了包含二进制文件的目录。普通
svn diff
中的补丁文件不会执行任何操作。
当使用 svn cp 或 svn mv 时,如何使 svn diff 生成补丁将应用的文件?
上述链接中的两种方法仅对文件进行修改。应用补丁后它们不会被删除/重命名。是否可以获得上述更改的工作补丁?
I have deleted some textual files using
svn remove
. Butsvn diff
shows as removal of all content in the file. Applying a patch of that diff only modifies the content, does not remove the file.I renamed a directory which contains binary files using
svn rename
. A patch file from a normalsvn diff
does nothing.
How to make svn diff produce file that patch would apply, when svn cp or svn mv was used?
subversion diff including new files
Both the methods in above links does only modifications to the files. They do not get removed/renamed after applying a patch. Is it possible to get a working patch for the above changes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从
patch
手册页:From the
patch
man page:试试这个:
Try this:
我认为OP的第二个问题是由SVN错误引起的,该错误已在SVN 1.7中修复。您更改目录结构(移动、重命名、删除)并提交它,但使用 svn diff 时,补丁似乎“不执行任何操作”。
我在删除目录时遇到了这个问题,并且症状是相同的,所以我假设我们遇到了相同的“根错误”。对我来说,更新到 svn 1.7 解决了这个问题,因为 svn 1.7 生成差异(补丁)的方式不同。
某些版本的 svn diff 根本不将移动/重命名/删除的文件放入 diff 中!
请参阅:http://svn.haxx.se/dev/archive-2004 -03/0333.shtml。这份来自 SVN DEV 列表的存档电子邮件显示,开发人员自己在 1.0.1 发布之前(十多年前)就发现了这个问题。如果你关注这个线程,他们似乎下定决心要修复它,但即使是 1.6 也将一些东西排除在 diff 之外。我必须更新到1.7。
基本上,如果 svn < 1.7 检测到一个目录被
svn delete
删除,它不会递归和处理子目录,它只会停在那里,不会在 diff 中的该树下放置任何内容。这不是我们想要的,我们希望显式删除所有子项,以便补丁可以如其他答案中所述,通过 -E 删除空文件和目录。如果该文件不在补丁中,则补丁无法执行任何操作。使用 svn 1.7,我做了一个与之前相同的 diff,但已删除目录下的每个文件都明确在补丁中,因为所有行都被删除(清空),然后
patch
/quilt 成功删除文件和文件夹。我假设您的情况需要在移动或重命名时发生类似的情况。
陷阱:
升级到 1.7 将使您的工作副本毫无用处。
确保在更新之前提交更改。然后您必须再次签出所有内容。编辑:SVN 1.7 客户端可能能够修复您的工作目录,但如果不能,您可能需要再次签出。请注意,这样您就不会失去工作。I think the OP's second issue is caused by an SVN bug that was fixed in SVN 1.7. You change a directory structure (move, rename, delete) and commit it, but when using
svn diff
, the patch seems to "do nothing".I had this problem when deleting directories and the symptoms are the same so I'm assuming we are experiencing the same "root bug". For me, updating to svn 1.7 solved it, because svn 1.7 generates diffs (patches) differently.
Some versions of
svn diff
don't put the moved/renamed/deleted files in the diff at all!See: http://svn.haxx.se/dev/archive-2004-03/0333.shtml. This archived email from the SVN DEV list shows the devs themselves identified this problem, sometime before 1.0.1 was released, over a decade ago. If you follow the thread, they seemed quite determined to fix it then, but even 1.6 was also leaving stuff out of the diff. I had to update to 1.7.
Basically, if svn < 1.7 detected that a directory was
svn delete
'd, it would not recurse and process the children, it would just stop there and not put anything under that tree in the diff. This is not what we want, we want explicit removes for ALL of the children, so that patch can, as mentioned in other answer, remove empty files and directories via -E. Patch can't do anything if the file isn't in the patch.Using svn 1.7 I did an identical diff as I did before but every file under a deleted directory was explicitly in the patch as having all lines removed (emptying), and then
patch
/quilt
successfully removed the files and folders. I'm assuming something similar needs to happen in your case with moving or renaming.GOTCHAS:
Upgrading to 1.7 will leave your working copies useless.
Make sure you commit your changes before updating. Then you have to checkout everything again.Edit: The SVN 1.7 client might be able to repair your working directories but if it can't you might need to checkout again. Just be aware so you don't lose work.