在远程Linux机器上应用SVN补丁总是失败

发布于 2024-09-24 03:21:50 字数 1047 浏览 3 评论 0原文

我典型的工作流程是这样的:

  1. 检查从 trunk 到我的 Windows 工作机器的代码
  2. 做一些修复(但不提交 SVN)并使用 Tortoise SVN 的“创建补丁”创建这些修改的补丁。
  3. 通过 SSH 登录远程 Linux 服务器,并上传补丁。 Linux 服务器还签出了 trunk HEAD。
  4. 在 Linux 服务器上应用补丁,如下所示:
[work@remoteLinuxBox:~/work] patch -p0 -i ~/work/fix.patch
(Stripping trailing CRs from patch.)
patching file src/java/main/myApp/view/action/test/launch/GetPeekAction.java
Hunk #1 FAILED at 385.
1 out of 1 hunk FAILED -- saving rejects to file src/java/main/myApp/view/action/test/launch/GetPeekAction.java.rej
(Stripping trailing CRs from patch.)
patching file src/java/main/myApp/view/action/test/GetAllCustomerAction.java
Hunk #1 FAILED at 76.
1 out of 1 hunk FAILED -- saving rejects to file src/java/main/myApp/view/action/test/GetAllCustomerAction.java.rej
(Stripping trailing CRs from patch.)

但我总是遇到这样的错误。我以为是windows和linux上的行尾不同造成的,于是我用dos2unix转换了补丁,类似(Stripping Trailing CRs from patch)的警告消失了,但打补丁仍然失败。

有一种奇怪的行为,如果对文件的修改仅发生在现有行上,则应用补丁将起作用。但如果添加了新行,补丁就会失败。

有人知道如何解决这个问题吗?非常感谢

My typical work process is like:

  1. Check out the codes from trunk on to my windows work machine
  2. Do some fixes (but no commit the SVN) and create a patch of these modifications using Tortoise SVN's "Create Patch".
  3. SSH log into a remote Linux server, and upload the patch. The linux server also has the trunk HEAD checked out.
  4. Apply the patch on the Linux Server like:
[work@remoteLinuxBox:~/work] patch -p0 -i ~/work/fix.patch
(Stripping trailing CRs from patch.)
patching file src/java/main/myApp/view/action/test/launch/GetPeekAction.java
Hunk #1 FAILED at 385.
1 out of 1 hunk FAILED -- saving rejects to file src/java/main/myApp/view/action/test/launch/GetPeekAction.java.rej
(Stripping trailing CRs from patch.)
patching file src/java/main/myApp/view/action/test/GetAllCustomerAction.java
Hunk #1 FAILED at 76.
1 out of 1 hunk FAILED -- saving rejects to file src/java/main/myApp/view/action/test/GetAllCustomerAction.java.rej
(Stripping trailing CRs from patch.)

But I always got errors like these. I thought it was caused by the reason that the end of the line is different on windows and Linux, so I converted the patch using dos2unix, the warning like (Stripping trailing CRs from patch) disappeared, but the patching still failed.

There is one strange behavior that if the modification for a file only happens on a existing line, applying patch will work. But if there are new lines added, the patch gets failed.

Anyone has clue on how to resolve this? Thanks very much

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

美人如玉 2024-10-01 03:21:50

使用 cygwin svn diff 来避免头痛,将确保每个块的标题只有 LF 作为行结尾而不是 CR+LF。
Linux patch 命令不能很好地处理具有 CR+LF 行结尾的大块标头。
对我来说,TortoiseSVN/create patch 已损坏,因为它创建的补丁不是跨平台的。

Use cygwin svn diff to avoid the headache, will make sure that the header of each hunk has only LF as a line ending instead of CR+LF.
The Linux patch command does not play well with hunk headers having CR+LF line endings.
To me TortoiseSVN/create patch is broken because the patches it creates are not cross-platform.

︶葆Ⅱㄣ 2024-10-01 03:21:50

我遇到了类似的问题,我认为不仅补丁文件的行分隔符很重要,而且工作副本的行分隔符也很重要。

我的工作副本有 Windows 行结尾 (CR+LF),但在我将受影响的文件(在工作副本中)转换为 Unix 行结尾后,补丁起作用了!问题是,现在我的文件比较工具显示工作副本文件在每一行中都与存储库不同 - 因为行结尾不同。我想,如果 Windows 可以处理的话,我最终会将整个存储库转换为 Unix 行结尾。

希望有帮助。

I had a similar problem, and I figured that not only the line delimiters of the patch-file are important, but of your working copy as well.

My working copy had Windows Line Endings (CR+LF), but after I converted the affected files (in the working copy) to Unix Line Endings, the patch worked! The problem is, that now my file comparison tool shows that the working copy files are different from the repository in every single line - because of different line endings. I think, I will end up converting the whole repository to Unix line endings, if Windows can deal with them.

Hope it helps.

浮云落日 2024-10-01 03:21:50

您可以尝试在修补命令中添加“-l --binary”,如下所示:

    patch -p0 -l --binary < patch.diff

You can try to add "-l --binary" to the patching command, like this:

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