简体   繁体   中英

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. I'm on Win 7, if it matters.

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. 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.

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. Here's the download link if you don't have it already: 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 .

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. http://sourceforge.net/projects/gnuwin32/

This will give you a diff util that can create patch files. 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). Documentation on that here: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-diff.html . You can also use the external diff with svn. Documentation on that here: 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.

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. I generated a list of revisions by searching for the defect id in the Message field in Tortoise. I then went to each relevant revision in Tortoise, right clicked on them and did a "Show Changes as Unified Diff". This basically created the diff that Jubob was talking about. On each diff I did a Save As and saved each revision as revision1.patch, revision2.patch, etc.

I started to apply each patch file one at a time using Tortoise, but that got tedious. 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. So I had to change from, say, c:/versionA/ to 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...". "export" keeps the folder structure, "Save..." saves all files into the same folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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