9 echo "Usage: $COMMAND keywords -- files or directories"
14 [[ -z "$@" ]] && usage
26 keywords="$keywords $1" ; shift ;;
28 dirs="$dirs $1" ; shift ;;
36 if [ "$mode" == keywords -o -z "$dirs" -o -z "$keywords" ] ; then
40 function run_keyword_on_file () {
44 if [ ! -f $file ] ; then
45 echo "NOT FOUND - skipped"
48 current_keywords=$(svn propget svn:keywords $file)
49 has_keyword=$(echo $current_keywords | grep $keyword)
50 if [ -z "$has_keyword" ] ; then
52 svn propset svn:keywords "$current_keywords $keyword" $file
58 # figures what files need to have the svn:keywords set, and adds it when missing
59 function run_keywords () {
64 echo "xxxxxxxxxxxxxxxxxxxx Fixing keywords props in $(pwd)"
65 echo -n "xxxxxxxxxx Gathering files under subversion "
66 svnfiles=$(svn list -R | grep -v '/$')
68 # handle this, as otherwise grep hangs on stdin
69 if [ -z "$svnfiles" ] ; then
70 echo "xxxxx Nothing applicable in $dir - skipping"
74 echo $(ls -1 $svnfiles | wc -l) files found
76 for keyword in $keywords ; do
78 files=$(grep -l '$'"$keyword" $svnfiles)
79 if [ -z "$files" ] ; then
80 echo "xxxxx No file found with \$$keyword"
83 nbfiles=$(ls -1 $files | wc -l)
84 echo "xxxxx Found" $nbfiles "with \$$keyword"
86 for file in $files ; do
87 run_keyword_on_file $keyword $file
91 for keyword in $keywords ; do
92 grep '$'"$keyword" $dir > /dev/null && run_keyword_on_file $keyword $dir
98 # removes expansion of the specified keywords for diff
99 # useful when comparing with another codebase
100 function run_normalize_on_files () {
101 for keyword in $keywords ; do
102 echo "Deflating \$$keyword on $# files"
103 for file in "$@" ; do
104 sed -e 's,$'"$keyword"'.*\$,\$'"$keyword"'$,' $file > $file.new
110 function run_normalize () {
113 if [ -d $dir ] ; then
115 echo "xxxxxxxxxxxxxxxxxxxx Normalizing keywords $keywords in $(pwd) "
116 echo -n "xxxxxxxxxx Gathering actual files under subversion "
117 svnfiles=$(svn list -R)
120 for scan in $svnfiles; do
121 if [ -d $scan ] ; then continue
122 elif [ -L $scan ] ; then continue
123 else files="$files $scan"
126 echo $(ls -1 $files |wc -l) files found
127 run_normalize_on_files $files
130 run_normalize_on_files $dir
143 echo Unsupported command $0 ;;