Mohamed Mansour's Personal Website
Articles
Comments on Quick way searching comments from svn using bash script
3 Replies: (add yours)
Jarrod
2Here is a modification to produce a set of patches for matching commits.
It also doesn't use a local SVN checkout, but talks directly to the server.
(Here is hoping I can actually submit readable source-code in here)#!/bin/bash
# WARNING:
# The cachefile stuff does not properly if running
# multiple searches on the same repository at the same
# time. So don't do that, OK?
#
URI="$1"
SEARCH="$2"
cachefile=/tmp/svn-search.`echo $URI | md5sum | cut -d' ' -f1`.$USER
if [ -z "$URI" ] || [ -z "$SEARCH" ] ; then
echo >&2 "Usage: $0 uri search-term"
exit 1
fi
if [ -f "$cachefile" ] ; then
if [ "`date +%s -d '1 week ago'`" -gt "`stat -c '%Z' $cachefile`" ] ; then
rm $cachefile
fi
fi
if [ -f "$cachefile" ] ; then
incachefile=$cachefile
outcachfile=/dev/null
else
incachefile=/dev/does-not-exist-so-error-$$
outcachefile=$cachefile
fi
function makepatch()
{
while read revno ; do
filename=$revno.patch
echo Creating $filename
echo "Produced from SVN at: $URI" >$filename
svn log -c $revno $URI >>$filename
svn diff -c $revno $URI >>$filename
done
}
( cat $incachefile 2>/dev/null || svn log $URI ) | tee $outcachefile | awk '{
if ( $1 == "------------------------------------------------------------------------") {
getline
REVISION = $1
}
else {
if (match($0, SEARCH)) {
print REVISION
}
}
}' SEARCH="$SEARCH" | makepatch
› Posted on July 16, 2009, 8:57 am
Jarrod
3Typo in the above: "outcachfile" should be "outcachefile"
› Posted on July 16, 2009, 9:27 am

s
1s
› Posted on April 26, 2009, 10:58 am