How to view svn diff in vimdiff style in svn
Found it at:
http://blog.tplus1.com/index.php/2007/08/29/how-to-use-vimdiff-as-the-subversion-diff-tool/
This blog post takes the script directly from the SVN book external diff tools example:
diffwrap.sh
#!/bin/sh
# Configure your favorite diff program here.
DIFF="/usr/local/bin/vimdiff"
# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT=${6}
RIGHT=${7}
# Call the diff command (change the following line to make sense for
# your merge program).
$DIFF $LEFT $RIGHT
# Return an errorcode of 0 if no differences were detected, 1 if some were.
# Any other errorcode will be treated as fatal.
Note: This assumes that your vimdiff
is in /usr/local/bin
, for me, in Fedora, it was in /usr/bin
. If you can't find it run:
$ whereis vimdiff
Then in ~/.subversion/config
:
[helpers]
...
diff-cmd = /home/<username>/bin/diffwrap.sh
svn diff with vim, but with the proper filetype
When I use restructured text within a file with the .txt suffix, by default, vim won't highlight the text. So I put this at the top of my file:
.. vim: set filetype=rst :
And then vim does all the cute syntax highlighting.
Try adding a modeline to the first line of your files and then see if vim does what you want when you do a diff.
Incidentally, that's my blog you linked to! Can I get a prize?
SVN Diff Coloring into Vim
It's a vim syntax highlighting. You can turn it off inside vim with the command
:set syntax=off
Make SVN Commit also print the diff
Looks like the script here works after all.
From - http://push.cx/2007/seeing-subversion-diffs-for-commit-messages
Needed to make a few changes. I'll paste the entire script here
create a file, name it svn in this case it's put in ~/bin
#!/bin/sh
REALSVN=/usr/bin/svn
ARGS="$@"
if [ "$1" = "commit" -o "$1" = "ci" ]; then
shift # pop off $1 for diff
TEMPLATE=`mktemp -t tmp`
$REALSVN diff "$@" > "$TEMPLATE"
$REALSVN $ARGS --editor-cmd="~/bin/svn-diff-editor '$TEMPLATE'"
else
$REALSVN $ARGS
fi
and also create a file named ~/bin/svn-diff-editor
echo >> "$2"
cat "$1" >> "$2"
rm "$1"
$SVN_EDITOR "$2"
for osx i had to add the '-t tmp' to mktmp and the orig script had $VISUAL which I did not have and had $SVN_EDITOR set instead, once I changed the last line of svn-diff-editor to that it worked.
Change default SVN diffing tool
Ok, looking at the original blog post, this is what you want:
svn diff --diff-cmd wm [optional-filename]
If you want to see what is actually happening here (i.e. what sort of parameters the svn diff
passes to the nominated diff-cmd
), you can just use svn diff --diff-cmd echo
and see what it says:
[~/src/gosmore-dev]$ svn diff --diff-cmd echo
Index: gosmore.cpp
===================================================================
-u -L gosmore.cpp (revision 13753) -L gosmore.cpp (working copy) .svn/text-base/gosmore.cpp.svn-base gosmore.cpp
Some quotes were removed above, but basically you can see that svn diff
will pass
-u -L "<left-label>" -L "<right-label>" <left-file> <right-file>
to your batch file. The batch file you have is used to turn these commands into the format that WinMerge understands.
More details and examples on how this all works are provided in the svn book.
To make your batch file the default for svn diff
, you need to add the following line in the [helpers]
section in your local subversion config file (~/.subversion/config
in Linux, I'm not sure where the config file is located in Windows) (see this earlier SO question)
diff-cmd=wm.bat
svn diff -x (v1.6) does not accept my diff option --unified=40
Subversion doesn't use GNU diff to generate the diff. It has it's own implementation of diff (see the last paragraph of the section at the link). The internal diff implementation only has a few options as you can see from the output of svn help diff
:
-x [--extensions] ARG : Specify differencing options for external diff or
internal diff or blame. Default: '-u'. Options are
separated by spaces. Internal diff and blame take:
-u, --unified: Show 3 lines of unified context
-b, --ignore-space-change: Ignore changes in
amount of white space
-w, --ignore-all-space: Ignore all white space
--ignore-eol-style: Ignore changes in EOL style
-p, --show-c-function: Show C function name
You probably want to do svn diff --diff-cmd=/usr/bin/diff -x '--unified=40' my-file
so that Subversion will choose the external diff too at /usr/bin/diff
(or whatever path you want).
You can also configure Subversion to always use the external diff command through the configuration file. There is a section on using external diff and merge tools in the Subversion book.
Related Topics
Recommended Irc Server (Ircd) for a Small Site
Linux: How to Enable Execute in Place (Xip) for Ramfs/Tmpfs
What Is The Maximum Allowed Limit on The Length of a Process Name
Configure "-Prefix" Option for Cross Compiling
What Is Dma Mapping and Dma Engine in Context of Linux Kernel
Bash Will Not Auto-Complete (Tab) with Files
How to Connect to Server: Postgresql on Ubuntu in Windows Subsystem for Linux
Finding Latency Issues (Stalls) in Embedded Linux Systems
Programmatic Resource Monitoring Per Process in Linux
In a Bash Script, What Would $'\0' Evaluate to and Why
How to Idiomatically Package Dependencies for a Qt Application Using Cpack
How to Get My Cuda Specs on a Linux Machine
Getting Following Error After The Command Sudo Apt-Get Update on Ubuntu 16.04
Receiving Multicast on a Server with Multiple Interfaces (Linux)
Are Mlock()-Ed Pages Static, or Can They Be Moved in Physical Ram