简体   繁体   English

想要在一组修订版本之间制作一个SVN补丁文件

[英]Want to make an svn patch file between a set of revisions

I'd like to create a patch file for a set of revisions either via the svn command line or using Tortoise. 我想通过svn命令行或使用Tortoise为一组修订创建补丁文件。 I'm on Win 7, if it matters. 如果有问题,我将使用Win 7。

I don't need to do a diff. 我不需要做比较。 I can do that. 我可以的 I have two different versions of some software. 我有一些软件的两个不同版本。 A bug was fixed in version A, that involved a fair number of files. 版本A中修复了一个错误,该错误涉及大量文件。 I'd like to port that over to version B. I'm not seeing an easy way to do this other than on a file-by-file basis. 我想将其移植到版本B。除了逐个文件之外,我没有看到一种简便的方法。

I can click on the files, and do a save revision to, but it doesn't really preserve the folder structure, like doing a patch file would. 我可以单击文件,然后对文件进行保存修订,但是它并没有像保存补丁文件那样真正保留文件夹结构。

Thanks, Eric 谢谢,埃里克

I would personally go for the command line svn diff. 我个人将使用命令行svn diff。 Here's the download link if you don't have it already: http://subversion.apache.org/packages.html#windows . 如果您还没有下载链接,请点击这里: http : //subversion.apache.org/packages.html#windows

Here's the documentation for svn diff: http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.diff.html . 这是svn diff的文档: http : //svnbook.red-bean.com/en/1.7/svn.ref.svn.c.diff.html

Given your description above it may be as simple as: 根据上面的描述,它可能很简单:

svn diff --new="url of A" --old="url of B" > mypatch.patch

You can try it with tortoise, but first you need the Windows ports of the unix toolset from GnuWin. 您可以尝试使用乌龟,但首先需要GnuWin的UNIX工具集的Windows端口。 http://sourceforge.net/projects/gnuwin32/ http://sourceforge.net/projects/gnuwin32/

This will give you a diff util that can create patch files. 这将为您提供一个可以创建补丁文件的diff util。 TortoiseSVN allows you to set an external diff program, but I'm not sure how well that goes as I have only ever used tortoise as a convenience (any heavy lifting and I'm back to the CLI). TortoiseSVN允许您设置一个外部diff程序,但是我不确定这样做的效果如何,因为我以前只是为了方便起见使用过陆龟(任何繁重的工作,我都回到了CLI上)。 Documentation on that here: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-diff.html . 此处的文档: http : //tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-diff.html You can also use the external diff with svn. 您也可以将外部差异与svn一起使用。 Documentation on that here: http://svnbook.red-bean.com/en/1.7/svn.advanced.externaldifftools.html . 此处的文档: http : //svnbook.red-bean.com/en/1.7/svn.advanced.externaldifftools.html

Erik's suggestion probably would work. 埃里克的建议可能会奏效。 I was able to get what I needed done using Jubob's suggestion. 使用Jubob的建议,我能够完成所需的工作。

I had 13 changesets, some of which undid part or all of previous changesets to multiple files that I wanted to port from version A to version B of my code. 我有13个变更集,其中有些变更集不完整或以前的变更集全部集中到多个文件,这些文件我想从代码的版本A移植到版本B。 I generated a list of revisions by searching for the defect id in the Message field in Tortoise. 我通过在Tortoise的“消息”字段中搜索缺陷ID来生成修订列表。 I then went to each relevant revision in Tortoise, right clicked on them and did a "Show Changes as Unified Diff". 然后,我转到Tortoise中的每个相关修订版,右键单击它们,然后执行“将更改显示为统一差异”。 This basically created the diff that Jubob was talking about. 这基本上产生了Jubob所谈论的差异。 On each diff I did a Save As and saved each revision as revision1.patch, revision2.patch, etc. 在每个差异上,我执行了一个另存为并将每个修订版本另存为version1.patch,revision2.patch等。

I started to apply each patch file one at a time using Tortoise, but that got tedious. 我开始使用Tortoise一次应用每个补丁文件,但这很麻烦。 So I wrote a batch file that ran each one successively. 因此,我编写了一个批处理文件,该文件逐个运行。 The commands in the batch file looked like: 批处理文件中的命令如下所示:

patch -p0 -i  "C:\mypatchfilelocation\revision1.patch"

Oh and one more thing. 还有件事儿。 Inside each patch file, I had to change the path to match version B's path. 在每个补丁文件中,我必须更改路径以匹配版本B的路径。 So I had to change from, say, c:/versionA/ to c:/versionB/ 所以我不得不从例如c:/ versionA /更改为c:/ versionB /

-Eric -埃里克

Open the repository browser. 打开资源库浏览器。 Browse to the older version. 浏览到旧版本。 Right-click on that tag/branch folder, select "mark for comparison". 右键单击该标记/分支文件夹,选择“比较标记”。 You will see that the repo browser shows that directory in bold now. 您将看到存储库浏览器现在以粗体显示该目录。

Then browse to the new version, right-click on that tag/branch folder, select "Show differences as unified diff" and you'll get a patch file. 然后浏览到新版本,右键单击该标记/分支文件夹,选择“将差异显示为统一的差异”,您将获得一个补丁文件。

Or you can right-click and select "Compare urls" and then in the following dialog select all the changed files, right-click and select "export selection to..." or "save list of selected files to...". 或者,您可以右键单击并选择“比较URL”,然后在以下对话框中选择所有更改的文件,右键单击并选择“将选择的文件导出到...”或“将所选文件的列表保存到...”。 "export" keeps the folder structure, "Save..." saves all files into the same folder. “导出”保留文件夹结构,“保存...”将所有文件保存到同一文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM