When I do svn commit and let my svn editor pick it up I'd LOVE for the svn editor to show the diff of the files that have changed instead of just the list of files. Really helps jog the memory when writing detailed commit messages. Any ideas on how to accomplish?
Write a script
It would take some work, but you could write a script to front end as your SVN_EDITOR.
When svn
invokes your SVN_EDITOR, it passes the name of an svn-generated temporary comment file containing the summary list of affected files to be committed.
http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.advanced.externaleditors
The value of any of these options or variables is the beginning of a command line to be executed by the shell. Subversion appends to that command line a space and the pathname of a temporary file to be edited. So, to be used with Subversion, the configured or specified editor needs to support an invocation in which its last command-line parameter is a file to be edited, and it should be able to save the file in place and return a zero exit code to indicate success.
Conceivably, you could write a shell script that takes a filename parameter that:
- opens the file indicated by the last arg (the svn temporary comment file)
- parses it for the files to be committed
- runs
svn diff
on each modified (non-binary) file and appends the diff output back to the end of the svn temporary comment file - invokes your real editor on the modified svn temporary comment file
Make sure your script returns the return code returned by your real editor or 0 to indicate success. Then set your SVN_EDITOR env var to point to your script.
Perhaps someone has already written such a script, but I couldn't find one (especially since you didn't indicate an OS). There's also a good chance that this script could generate an extremely large file.
Alternative - write a macro
I think a better alternative would be to use a programmable editor and program a macro that read a filename(s) from some selected line(s) and then run SVN diff on the file(s) - putting the results in a buffer or appending it to current buffer . You could then selectively highlight files from the svn temporary comment file and run SVN diff on just the key files you need. Sounds like a job for elisp!
Sorry I don't have an ready-made code for you. If you do either of these, it would be interesting to see come back and post your script/macro back here as an answer.
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.