Create SVN patch after commit

SvnTortoisesvn

Svn 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:

  1. Check out each branch
  2. Mark the two files that should be compared
  3. Compare via WinMerge
  4. 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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfluentView Question on Stackoverflow
Solution 1 - SvnStefanView Answer on Stackoverflow
Solution 2 - SvnJakub CView Answer on Stackoverflow
Solution 3 - SvnTobiasView Answer on Stackoverflow
Solution 4 - SvnDan AtkinsonView Answer on Stackoverflow