Print last 10/20/... svn log messages with diffs
I am using SVN for a project. with svn log -l 10
, I can get the last 10 commits to this folder, with the revision id, log message, etc.. Is there any SVN command that lets me print out on the command line all t开发者_如何学Gohe diffs for each of those changesets? I'd like to do some grepping/etc. with the last X diffs?
In SVN v1.7, there are the
--diff : produce diff output
--diff-cmd ARG : use ARG as diff command
options that you can use with svn log
For older version (which is probably your case), you will have to do some scripting to supply revision to svn diff
and get the output
For older svn, you can use function:
svn-log-diff()
{
for c in `svn log "$@" | grep '^r' | cut -f1 -d ' ' | sed s/r/-c/`; do
svn diff --force $c || break
done
}
Assuming you are using Linux, use the following script. save it like svn-diffs.sh. Then run
sh svn-diffs.sh 10
This adds the diffed contents to files under a newly created diffs/ dir. That way, you can grep through without worrying about latency later on. This worked in my tests. You may grep through the files under diffs/ dir separately to have a colored output.
#!/bin/bash
# Author - Kasun Gajasinghe
HEAD="HEAD"
limit=${1}
[[ -z "$1" ]] && limit=10
revisions=$(svn log -l $limit | grep -r "r[0-9][0-9]*\w" -o | grep -r "[0-9][0-9]*" -o)
mkdir diffs
echo $revisions > diffs/revisions.log
for revision in ${revisions}
do
# svn diff -r $revision:${HEAD} } | grep -ri "SEARCHME" || exit 1
diff=$(svn diff -r $revision:${HEAD})
echo "$diff" > diffs/diffs-$revision-$HEAD.log
echo "=======================" >> diffs/diffs-$revision-$HEAD.log
HEAD=$revision
done
grep -ri "searchme" diffs/
精彩评论