TortoiseSVN : Good 'patch file' viewer? - tortoisesvn

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

Related

How do I open a (Mercurial) patch file in a human-readable format (preferably with kdiff3)?

The Mercurial command
hg diff > mypatchfile
compiles a "patch" file representing the differences between the working directory and the last commit. Opening this file as plain text results in a presentation of the changes that is quite difficult to read. I want to open this file in a diff tool for a clearer presentation of the differences.
I know that the diff tool kompare can do exactly this, using the command
kompare mypatchfile
But while its presentation is certainly more readable than the plain text format, I find it lacking.
I much prefer kdiff3. Can this tool open patch files? The command
kdiff3 mypatchfile
doesn't work. Instead, the patch file is just opened in plain-text format in the left panel, while the right panel is empty. But it seems that kdiff3 should be able to open patch files, because I can just write
hg extdiff -p kdiff3
and get exactly the presentation I want. However, I don't see how I can get similar results with a previously exported patch file. Any suggestions?
(I would also appreciate recommendations for other diff tools that can open and display patch files in a readable format.)
You can't do it easy (but can try to do it with some tricks for some patches)
hg extdiff -p kdiff3 does NOT visualize custom patch, but (read carefully Extdiff extension wiki) only show in dual-window mode difference between two revisions (see difference in terms) - Working Dir and parent in simplest case (and sources for diffing are full files from relevant revisions)
I think you are just tying to visualize diff output, right ? There's a tool xxdiff that might be useful with few caveats. extdiff is an external diff, that is instead of using Mercurial diff, another program is used to do the diff of two revisions. You can even use linux diff command as an extdiff for Mercurial.

Auto-highlight parts of the text which has been changed

Is it possible in VIM to highlight parts of some text the user has added/changed in a file?
Following situation demonstrates this:
user has opened a file
user has made some changes and then :w
all differences between 1 and 2 should be highlighted
user has made some changes and then :w
all differences between 1 and 4 should be highlighted
and so on.
I am looking for a most compact solution - should it be an option or a simple vim script.
You can keep a backup of the original file, then :vsplit file.bakļ¼Œ execute :diffthis in both buffer.
The VIM plugin vim-gitgutter will indicate lines that have been added / removed / changed if the file you are editing is part of a Git repository. This might meet your needs.
For such difference reporting, it's best to use a revision control system. The numbers from your question then map cleanly to revision numbers, and there are indeed plugins that can show those differences (also across multiple revisions, and in the form of log messages, etc.)
The vcscommand.vim - CVS/SVN/SVK/git/hg/bzr integration plugin supports all widely-used systems, and offers this in the form of a vimdiff or a unified diff in a scratch buffer. There are also plugins (vim-signify - Advanced plugin for showing VCS diffs in the SignColumn, or GitGutter for Git) that visualize this neatly in the sign column.
If you don't / can't use a revision control system, there are plugins that show the differences to the saved version (but not across saves, as this information is not available).
If you want a lightweight, Vim-only revision control system solution that can do this, have a look at my writebackup plugin and writebackupVersionControl plugin plugins, which offer vimdiffs / unified diffs, too, without requiring an underlying revision control system.
Vim tracks and maintains an undo history which records all changes made to a file. You could use a plugin like 'sjl/gundo.vim' which gives you the ability to view diffs of subsequent changes to a file (very handy).
If you keep the file under vcs, like git, you can also see diffs. For git you should use 'tpope/vim-fugitive' and then you can view diffs in several different ways, most common being :Gdiff

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

A visual patch tool for Linux

I've got a file and a patch for it. I'd like to visually apply the patch, t.i. see how the changes proposed by the patch look in context, make some corrections, and save the resulting file.
What tool can do that?
Neither of the visual diff tools (i.e. meld, diffuse, diffmerge) do what I want: they don't work with patches, they merely merge whole files.
I really like Kompare. It is just a (very nice) graphical interface for diff.
http://www.caffeinated.me.uk/kompare/
sudo apt-get install kompare
Creating and applying patches
Kompare is able to create a patch file
which lists only the differences
between two compared text files A and
B. Further, Kompare can apply a patch
file which was created this way to an
original file A and, in this manner,
recompute the contents of the
corresponding file B. This is a
comfortable utility for passing a
corrected version of a file to a
friend who already has an older
version of the same file, because only
the (relatively small) patch file has
to be delivered and the receiver can
generate the corrected file by
applying the patch to the original
file.
The patches created and applied by
Kompare are compatible to patch files
generated or applied by the command
line interface diff utility, because
Kompare is in fact merely a graphical
front end to diff and the patches are
created and applied by patch, which
gets called by Kompare.
See use vimdiff with a diff file.
gvim original.file +'vert diffpa the.patch'
This will open GVim and split the window, with the original on the left and the patch applied on the right. You can then add, remove, or change hunks, and save the changes. (Well, if you want to create a new.patch you'll have to run diff again, but that's not difficult.)
You may use the emacs ediff mode.
It lets you see and validate each chunk interactively.
For what it's worth, I have this handy script in my ~/bin directory:
#!/bin/bash
if [ "$1" == "--text" ] ; then shift; fi
if diff --brief $1 $2 ; then
exit 0
else
emacs -fn 8x13bold --eval '(ediff-files "'$1'" "'$2'")'
fi
Another option: if you use Eclipse, you can generate and apply patches visually.
The idea with visual diff tools is that you can:
make a backup copy of the patched file (or a new pristine checkout of the whole tree)
apply the patch
use the visual diff tool to review the changes in context
make any desired change to the patched file within the visual diff tool.
Some tools, such as meld or diffuse will automatically diff against the previous committed version of the files.
The key insight is that you CAN apply the patch, they discard everything you don't like as long as you have a backup copy, or if you are working on a clean checkout.
If you feel more comfortable with reading and modifying unified diffs, and just want to have more context for the diff, emacs has a fairly unique feature, which is next-error-follow-mode while viewing a diff file (diff major mode). That shows the context of a diff line in the target file.
On platforms where Kompare (a fairly nice piece of software if KDE is your cup of tea), I agree that Eclipse is a great option.
I have consistently been a reluctant Eclipse user AND I am consistently impressed by how well the tools work (once the platform finally starts up).
On Fedora, I've got just about every front end installed for each of the main version control engines (SVN - also serving my Windows machines, Mercurial, git, etc.);
Meld is quite nice (no patch interface though).
Submerge works well also.
But since Eclipse does know how to apply patches and Working Copy project created itself once I figured out to create the project in the folder containing my working copy, it may become my favorite SVN front end.
I normally use GitExtensions (.NET and Mono) which also supports applying patches interactively. I hope you are already familiar with git.
Edit: Everything mentioned below this line doesn't seem to be available directly in KDiff3. And as I mentioned before: I haven't tried it yet.
GitExtension normally uses KDiff3 as diff tool, which is able to view patches.
http://kdiff3.sourceforge.net/doc/kpart.html
Using it for patches it has only a two window view, (edit) and doesn't support merging :( but it also supports 3 way diff on complete folders etc.
Actually I never tryed it with patches.
Does xxdiff do what you are looking for?
I'd use meld.
Create two copies of the files, one without and another with the patch. Use meld to compare them, and you can see exactly what the patch is changing and make changes as necessary.
Seriously, why is this so hard?

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