This page shows how to recursively do a
svn log
on all files and creating a filtered log file.
-
In order to find new files I use svn log. In this
case, I needed to recursively do it on all files
somewhere in the middle of the svn tree.
-
Only the revision and file name are the only
information, that I needed. I also wanted them to
be written into a log file. One line per entry, to
facilitate farther script processing.
In my case filtering results was easy as all
unwanted entries were marked with revision
r2.
Sometimes it easier to run a script, to process
and manipulate text, from within vim / gvim.
So I marked the area in vim and run:
:'a,'b !grep -v " r2 "
To extract based only on date:
:'a,'b !grep -v "Sun, 23 Sep 2012"
-
The script was recently improved. On large SVN data
base, looking on all files, may take very long
time to finish. So it would be nice to be able to
restrict the search.
This script shows a way to handle input parameters to a bash
script.
-
The script is simple as shown:
- #!/bin/bash
- date > ~/restricted/my_svn_log.txt
- #save the input arguments array
- arr=("$@")
- arg=${#arr[*]}
- if [ "$arg" -eq "0" ] ; then
- #if no argument just run on all files (may take long time to finish)
- for f in `find -L . -type f | grep -v "\.svn" | grep -v "\.swp"`; do printf '%s ' $f >> ~/restricted/my_svn_log.txt; svn log $f | grep "^r[0-9]" | head -1 >> ~/restricted/my_svn_log.txt; done
- else
- #arr of suffixes to search in SVN
- #invocation examples:
- #~/bin/svn_file.unx
- for suf in "${arr[@]}" ; do
- #use printf instead of echo in order not to have \n at print end
- echo "working on *."${suf}
- for f in `find -L . -name "*.${suf}"`; do printf '%s ' $f >> ~/restricted/my_svn_log.txt; svn log $f | grep "^r[0-9]" | head -1 >> ~/restricted/my_svn_log.txt; done
- done
- fi
- #later filtered on the resulting file
- #'a,'b !grep -v " r2 "
-
If the script is to be run multiple times concurrently, say on different
directories, then the following change is a nice option, which makes
use of the $$ to add
the process ID to file name:
Replace line 3 with:
fn="/home/krengelp/restricted/my_svn_log_"$$".txt"
echo $fn
eval "date > "$fn
Replace every other
"~/restricted/my_svn_log.txt" with $fn.
|