Create SVN patch after commit
SvnTortoisesvnSvn Problem Overview
Is it possible to retrospectively create a patch? The Tortoise SVN client we are using gives us the option to create a patch instead of (or during) a commit.
I would like to work on the fix using the trunk, check it in and have the build server run all its tests and metrics to confirm that the fix is acceptable. I would then like to be able to select a few revisions (if the first attempt at fixing it only got us part way there) and create a patch file from the files that have changed.
I can then take the patch and apply it to a few other branches. Is this possible?
Svn Solutions
Solution 1 - Svn
Show Log, select the revisions, right-click, "show unified diff".
Solution 2 - Svn
if you have problem with paths, you can show diff on every file separately
Solution 3 - Svn
You can also use WinMerge on Windows if you want to compare two files from different branches:
- Check out each branch
- Mark the two files that should be compared
- Compare via WinMerge
- Then click: Tools -> Generate Patch
By this you can create a patch for already committed files from different branches.
Solution 4 - Svn
I tend to use the svn diff
command line to create patches. As such, the following examples could be used, but they rely upon you knowing the revision number - which shouldn't be too difficult to ascertain.
For the purposes of this answer, let's assume the following:
- The revision number of your commit is 1234.
- Your SVN repository is located at
https://mySvnServer/myRepository/trunk
. - You will place your patches in
C:\Path\To\Patches\
.
Create a patch of just revision 1234. Note -c 1234
.
svn diff -c 1234 https://mySvnServer/myRepository/trunk > "C:\Path\To\Patches\1234.patch"
Create a patch of all revisions between your commit and the head (latest commit). Note -r 1234:HEAD
.
svn diff -r 1234:HEAD https://mySvnServer/myRepository/trunk > "C:\Path\To\Patches\1234_head.patch"
As far as I know, there isn't a single line method of creating a patch from multiple non-consecutive revision numbers without creating a branch, merging in the desired revisions individually, and then performing a svn diff (similar to above) to create a patch.