创建包含新目录的 SVN 补丁

发布于 2024-12-01 23:34:05 字数 2809 浏览 2 评论 0原文

首先请原谅我的文字很长,但我会尽力做到详细。

我正在为一个开源项目(DSpace)进行开发。我没有他们的 SVN 存储库的提交权限,因此我查看了源代码并一直使用 git 来管理我的版本控制。

在我的开发过程中,我向我的项目添加了几个目录和二进制文件。

是时候制作一个 SVN 补丁文件了,这样我就可以回馈社区了! Netbeans 通过 Team-> 为我完成此操作创建补丁选项。到目前为止一切顺利...

但是,当我在另一台计算机上再次检查源代码并使用补丁命令时:

# get current dir
DIR="$( cd "$( dirname "$0" )" && pwd )" 

#check out dspace release
svn co http://scm.dspace.org/svn/repo/dspace/tags/dspace-1.7.2/ -q $DIR/dspace-1.7.2/

#apply patch
cd $DIR/dspace-1.7.2
echo "Now running at "&& pwd
patch --dry-run -N -p0 < $DIR/patches/patch.diff
cd $DIR

运行脚本

当我运行此脚本时,一切顺利,直到补丁尝试修改文件位于我的新目录之一中。它表示以下内容:

can't find file to patch at input line 9214
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js
|--- dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js         Base (BASE)
|+++ dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js     Locally Modified (Based On LOCAL)
--------------------------
File to patch:

在停止之前,它能够修补原始 dspace 版本中已有的一堆文件,因此我认为它与 patch 命令的 -pXXX 参数无关(尽管如此,我已经尝试了 -p10)...我认为只有当我尝试修补我创建的目录之一内的文件时才会发生这种情况。 我的猜测是 patch 命令不会创建新目录,因此它找不到正确的路径。

这让我发疯,请问有人知道如何解决我的问题吗?

提前致谢!

编辑:

我已将 --verbose 选项添加到 patch 命令中。结果如下:

--------------------------
Patching file dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/autocompleter/styles.css using Plan A...
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
can't find file to patch at input line 9214
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js
|--- dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js     Base (BASE)
|+++ dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js     Locally Modified (Based On LOCAL)
--------------------------
File to patch: 

在我退出补丁过程后,如果我得到

cd dspace-1.7.2/dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI

-bash: cd: dspace-1.7.2/dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI: No such file or directory

这是我在开发过程中添加的文件夹之一,这证明补丁没有创建这些新文件夹。

First of all excuse the long text, but I am trying to be as detailed as I can.

I am developing for an open-source project (DSpace). I don't have commit privileges to their SVN repo, so I checked out the source and have been using git to manage my versioning.

During my development, i've added several directories and binary files to my project.

The time has come to make an SVN patch file so I can give something back to the community! Netbeans does this for me through the Team-> Create patch option. So far so good...

However, when I check out the source again on another machine and use the patch command:

# get current dir
DIR="$( cd "$( dirname "$0" )" && pwd )" 

#check out dspace release
svn co http://scm.dspace.org/svn/repo/dspace/tags/dspace-1.7.2/ -q $DIR/dspace-1.7.2/

#apply patch
cd $DIR/dspace-1.7.2
echo "Now running at "&& pwd
patch --dry-run -N -p0 < $DIR/patches/patch.diff
cd $DIR

Running Script

When i run this script, all goes well until the patch attempts to modify a file inside one of my new directories. It says the following:

can't find file to patch at input line 9214
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js
|--- dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js         Base (BASE)
|+++ dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js     Locally Modified (Based On LOCAL)
--------------------------
File to patch:

Before it stops, it is able to patch a bunch of files which were already in the original dspace release, so I think it is not related to the -pXXX parameter of the patch command (nevertheless i have tried up to -p10) ... I think this only happens when I attempt to patch a file inside one of my created directories. My guess is that the patch command does not create new directories, so it cannot find the correct paths.

This is driving me nuts, please does anyone have any idea how to solve my problem?

Thanks in advance!

EDIT:

I've added the --verbose option to the patch command. Here's the result:

--------------------------
Patching file dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/autocompleter/styles.css using Plan A...
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
can't find file to patch at input line 9214
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js
|--- dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js     Base (BASE)
|+++ dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI/jquery-ui.js     Locally Modified (Based On LOCAL)
--------------------------
File to patch: 

After I quit the patch process, if i make

cd dspace-1.7.2/dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI

I get:

-bash: cd: dspace-1.7.2/dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jQueryUI: No such file or directory

This is one of the folders I added during the development, which proves that patch is not creating these new folders.

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

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

发布评论

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

评论(1

第几種人 2024-12-08 23:34:05

如果生成补丁,其中必须包括添加新文件/目录,对于纯 subversion CLI,您必须将 --git 选项添加到 svn diff 命令

In case of generating patches, which have to include adding new files/directories, for pure subversion CLI you have to add --git option to svn diff command

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