执行 svn remove 和 svn rename 后获取适用的补丁

发布于 2024-12-02 08:17:22 字数 577 浏览 1 评论 0原文

  1. 我使用svn remove删除了一些文本文件。但 svn diff 显示为删除文件中的所有内容。应用该差异的补丁只会修改内容,不会删除文件。

  2. 我使用 svn rename 重命名了包含二进制文件的目录。普通 svn diff 中的补丁文件不会执行任何操作。

当使用 svn cp 或 svn mv 时,如何使 svn diff 生成补丁将应用的文件?

subversion diff 包括新文件

上述链接中的两种方法仅对文件进行修改。应用补丁后它们不会被删除/重命名。是否可以获得上述更改的工作补丁?

  1. I have deleted some textual files using svn remove. But svn 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.

  2. I renamed a directory which contains binary files using svn rename. A patch file from a normal svn 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 技术交流群。

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

发布评论

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

评论(3

薄荷→糖丶微凉 2024-12-09 08:17:22

patch 手册页:

-E 或 --remove-empty-files
删除补丁后空的输出文件
已应用。通常这个选项是不必要的,因为
补丁可以检查标头上的时间戳以阻止 -
我的问题是修补后文件是否应该存在。然而,
如果输入不是上下文差异或者补丁是否一致
到 POSIX,补丁不会删除空的补丁文件
除非给出这个选项。当补丁删除一个文件时,它
还尝试删除任何空的祖先目录。

From the patchman page:

-E or --remove-empty-files
Remove output files that are empty after the patches have
been applied. Normally this option is unnecessary, since
patch can examine the time stamps on the header to deter‐
mine whether a file should exist after patching. However,
if the input is not a context diff or if patch is conform‐
ing to POSIX, patch does not remove empty patched files
unless this option is given. When patch removes a file, it
also attempts to remove any empty ancestor directories.

血之狂魔 2024-12-09 08:17:22

试试这个:

patch -p0 -E < 1.patch && svn rm `svn st -q | grep ^! | cut -c 9-`

Try this:

patch -p0 -E < 1.patch && svn rm `svn st -q | grep ^! | cut -c 9-`
佞臣 2024-12-09 08:17:22

我认为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.

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