我将其编写为cygwin bash脚本来解决此问题。
但是,它要求搜索词当前位于文件系统文件中。对于与文件系统grep匹配的所有文件,然后对该文件的所有svn差异执行grep。并不完美,但对于大多数用法而言应该足够好。希望这可以帮助。
/ usr / local / bin / svngrep
#!/bin/bash
# Usage: svngrep $regex @grep_args
regex="$@"
pattern=`echo $regex | perl -p -e 's/--?\S+//g; s/^\\s+//;'` # strip --args
if [[ ! $regex ]]; then
echo "Usage: svngrep \$regex @grep_args"
else
for file in `grep -irl --no-messages --exclude=\*.tmp --exclude=\.svn $regex ./`; do
revs="`svnrevisions $file`";
for rev in $revs; do
diff=`svn diff $file -r$[rev-1]:$rev \
--diff-cmd /usr/bin/diff -x "-Ew -U5 --strip-trailing-cr" 2> /dev/null`
context=`echo "$diff" \
| grep -i --color=none -U5 "^\(+\|-\).*$pattern" \
| grep -i --color=always -U5 $pattern \
| grep -v '^+++\|^---\|^===\|^Index: ' \
`
if [[ $context ]]; then
info=`echo "$diff" | grep '^+++\|^---'`
log=`svn log $file -r$rev`
#author=`svn info -r$rev | awk '/Last Changed Author:/ { print $4 }'`;
echo "========================================================================"
echo "========================================================================"
echo "$log"
echo "$info"
echo "$context"
echo
fi;
done;
done;
fi
/ usr / local / bin / svn修订版
#!/bin/sh
# Usage: svnrevisions $file
# Output: list of fully numeric svn revisions (without the r), one per line
file="$@"
svn log "$file" 2> /dev/null | awk '/^r[[:digit:]]+ \|/ { sub(/^r/,"",$1); print $1 }'
--search
参数svn log
。请在stackoverflow.com/a/17473516/761095上