How to create patch file between two revisions in TortoiseSVN? - tortoisesvn

I'm using TortoiseSVN 1.7 and want to create patch file between two revisions.
I've searched, but these threads How do I create a patch from diff between revisions using TortoiseSVN? Creating a patch between two revisions do not work for me, as Show changes as unified diff generates very simple file (not a patch file). Something like
Index: myfile.txt
===================================================================
I read in Viewing Differences that
If you want to see the changes made to all files in a particular
revision in one view, you can use Unified-Diff output (GNU patch
format). This shows only the differences with a few lines of context.
It is harder to read than a visual file compare, but will show all the
changes together. From the Revision Log dialog select the revision of
interest, then select Show Differences as Unified-Diff from the
context menu.
I want to create a single patch file (or many patch files according to modified files) that contains useful diff information (like the menu context TortoiseSVN -> Create patch ...)

If you use the "Show changes as unified diff" command, then TortoiseSVN shows all changes of the selected revision in a single file.
Now simply use the "File / Save as" command to save the changes to a ".patch" or ".diff" file and there you have your patch file.

Related

Getting an SVN version of a certain file

I would like to present in my GUI the SVN version of a certain file added to the project without hard-coding it each time I change something in the file and re-upload it to the SVN.
Is there a way to do that?
You need to use Subversion keywords, expressed as subversion properties on the file using the svn:keywords property. You'd set svn:keywords to Revision or Id to solve your problem. (Note that this solution updates data in the file, which is exposed when viewing or editing the file. It may or may not be shown an any particular GUI which is not a file editor.)
For more information on svn:keywords check out Special Keywords
For TortoiseSVN, right-button the file, pick TortoiseSVN, Properties, new, Keywords, and check the ones you want applied to the file.
Then, in the file, insert (in comments) the special strings $Revision$, $Id$, $Author$, etc. and Subversion will convert those into the actual data when the file is committed. Then, upon checkout, the data will appear and will be updated on the next commit.
If
your GUI can communicate with repository (i.e data is Working Copy or
you know filename-URL relation)
and
Production system has SVN-client
you can for any file-type get file-revision dynamically
svn ls -v URL (first column) or svn info URL ("Last Changed Rev" string)

How to temporarily apply (or archive) PATCH/DIFF changes from Tortoise SVN?

I've been using Tortoise SVN + Visual SVN for about a year since left the corporate world to do my own startup. There's one feature in Tortoise SVN that I've never figured out:
How can I bundle up a bunch of changes into a PATCH or DIFF file and either: A) share them with my co-founder; or B) archive them into a standalone change that I can either "apply" or "revert" on my dev box?
At my previous employer, we used an internal tool that let us build so-called DPK files that contained a set of local changes. You could add changed files to the DPK and then share it with colleagues. They could either review the changes in a Diff tool or apply all the changes from the DPK to test your change on their box. After the review was complete, you could then check in these changes. You could also have multiple DPK's applied at the same time (provided you didn't have overlapping changes).
I want to achieve the same thing with Tortoise SVN + Visual SVN in the VS2010 IDE.
My real-world scenario is that I have some extensive change pending but uncompleted on my box. I want to ZIP up these changes and store them in a DIFF file, revert the changes, move on to something else, work on that, and in a few days reapply my changes from the archived DIFF file.
Reluctantly answering my own question. This feature is available with Tortoise SVN. Basically, you make a PATCH file, distribute it or archive it, and then you apply the PATCH. The only trick is to make sure you're in the right location in the WC (Working Copy) when you do the "apply". When you apply, you'll get a popup menu to the left with a list of all files in the changelist. You can apply the patches one by one or in bulk. Seems to work great. I should have drilled into the docs more before posting this question.
Here's the text for picking the location:
"Patch files are applied to your
working copy. This should be done from
the same folder level as was used to
create the patch. If you are not sure
what this is, just look at the first
line of the patch file. For example,
if the first file being worked on was
doc/source/english/chapter1.xml and
the first line in the patch file is
Index: english/chapter1.xml then you
need to apply the patch to the
doc/source/ folder. However, provided
you are in the correct working copy,
if you pick the wrong folder level,
TortoiseSVN will notice and suggest
the correct level."
Be sure to pick the location carefully. If Tortoise SVN can't find it because you selected the wrong node in the VS file explorer, it will try to find a matching location and that might be wrong. In my tests, the Patch feature actually tried to map to a branch (!!) when I specified the wrong location.
Here's the relevant link:
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-patch.html

TortoiseSVN : Good 'patch file' viewer?

The default patch file viewer is messy (ie. no side by side diff view etc). I tried setting the path of beyondCompare exe in "Settings->Unified Diff Viewer->custom", but beyond compare also behaves same as default diff tool.
Is there a way to atleast allow side by side diff in patch files ? If so, what is the method ?
My aim is to allow emailing of changes so that they can be reviewed before I commit them :)
Mishal
I've never found any, but the solution that I usually use is to simply apply the patch file to a pristine checkout of the tree, and then do a "regular" diff (my preferred tool is diffuse) to review the changes in context.
The problem with "raw" patch files is that they only provide a few lines of context before and after the change, which often isn't enough.
If you don't like the patch, simply revert the changes and don't commit!
Beyond Compare 4 allows you to view patch files created by SVN. The top window in Beyond Compare is a tree structure, allowing you to navigate folders and files by name. Revision numbers are present in the left and right diff windows.
Create the patch
svn diff -r 5922:6116 > CodeReview.patch
Open the patch in Beyond Compare 4
SVN 1.7 I think was released since this answer was posted, and I landed here because I wanted to show my newly created patch file with syntax coloring, a la view unified diff in TortoiseSvn.
It turns out that Notepad++ automatically syntax colors my file correctly if I give it the filetype of "patch"!
Patches have been around a long time but SVN is now supporting them more fully.
See for example the documentation;
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-patch.html
For how to create a patch file, see this nice document that describes various methods including mine, WinMerge;
http://docs.moodle.org/dev/How_to_create_a_patch#Creating_a_patch_using_WinMerge
If you have access to a Mac OS X machine, PatchViewer sounds like it might do what you're looking for:
http://appledeveloper.com.au/products/patchviewer/
(Disclaimer: I am the author of PatchViewer.)
You can view a diff file (a patch generated by diff tool) using Kompare from KDE environment. I used it before on Linux, but today I found how to install it on Windows. Here is an installation instruction from a blog "Kompare - the only valuable diff for M$Windows":
Go to gnuwin32 diffutils, download and install.
Download kdewin installer and launch it.
After installing kde4win - start kompare and in "Diff" section show him where your diff.exe (from gnuwin32 diffutils) is located.
Restart Kompare and it's ready to use!
You can also add an association with .diff file format and now you can view any diff files. For me it works great.
I like to use KDiff3, it's packed with functions, very user friendly and available for all popular platforms. It can also integrate with TortoiseSVN.
GitExtensions, my favorite Git GUI, also has an option to "View patch file":

In Perforce command line, how to diff a file reopened for add?

Suppose you open a file for branch to another place (without submitting), and then reopen it for add and make some edits. I would like to diff this edited version against its branch source in a script.
p4 diff2 is no good because one of the versions is in the client.
p4 diff is no good because it can only diff against the "corresponding" version of the file in the depot, which a branched unsubmitted file doesn't have yet.
Is there a way, or is the only option to just grab the two files and diff them using a third-party tool?
Sadly, you're on the money here, you'd need to use a third party diff tool to do this because, as you rightly pointed out, until you've submitted the initial integration to the depot, it doesn't have a copy against which to diff. If you go down this route you'd obviously not be able to access files directly in the depot though, you'd need to have both files on the client PC and specify their paths explicity.
ninesided is correct that you need to have both files on the client PC.
But there are shortcuts:
If you're using P4V, choose "Diff Against..." from the context or Tools menu. For 1st Path, choose the old location and select "Latest Revision'. For 2nd path, choose the new location and select "Workspace revision on local disk".
The work of selecting the paths can be made easier if you can get both files to appear in the same pane and Ctrl-click to multi-select. e.g. use the Workspace tree pane or open the source file for edit temporarily in order to get it listed in the Pending files pane.
P4V accomplishes this by running 'p4 print -o' on the depot file to create a temporary file on the client PC, then passing that temporary file to the diff application. If you need a textual diff, you can either configure P4V to run a textual diffing application, or run p4 print -o and diff yourself.

Tortoise svn adding <<<< to files!

My problem is that whenever I update a folder via tortoise svn I get the files that were edited and now different from revision 1 to revision 2, SVN adds a "<<<<<<" to places that were affected.
Can anyone please provide some sort of solution?
These markers indicate where there have been conflicting changes between what you have changed and what somebody else has changed. The SVN Book has a section on merging which shows you what to expect. The book talks about the command line commands but the workflow for TortoiseSVN is similar.
See in particular the section titled "Merging conflicts by hand".
This lines are inserted by the default tortoise merge program.
If you change the default program to see the file differences you will not see this ugly <<<<<mine anymore. Use for example Winmerge
To use winmerge for file changes do the following:
Right click on a versioned folder and select Tortoise SVN->Settings
In External Programs->Diff Viewer section you can set the program you want to see file diffs. Select winmerger or you prefered.

Resources