7 echo "Usage: $COMMAND keywords -- files or directories"
12 [[ -z "$@" ]] && usage
24 keywords="$keywords $1" ; shift ;;
26 dirs="$dirs $1" ; shift ;;
34 if [ "$mode" == keywords -o -z "$dirs" -o -z "$keywords" ] ; then
38 function run_keyword_on_file () {
42 if [ ! -f $file ] ; then
43 echo "NOT FOUND - skipped"
46 current_keywords=$(svn propget svn:keywords $file)
47 has_keyword=$(echo $current_keywords | grep $keyword)
48 if [ -z "$has_keyword" ] ; then
50 svn propset svn:keywords "$current_keywords $keyword" $file
56 # figures what files need to have the svn:keywords set, and adds it when missing
57 function run_keywords () {
62 echo "xxxxxxxxxxxxxxxxxxxx Fixing keywords props in $(pwd)"
63 echo -n "xxxxxxxxxx Gathering files under subversion "
64 svnfiles=$(svn list -R | grep -v '/$')
66 # handle this, as otherwise grep hangs on stdin
67 if [ -z "$svnfiles" ] ; then
68 echo "xxxxx Nothing applicable in $dir - skipping"
72 echo $(ls -1 $svnfiles | wc -l) files found
74 for keyword in $keywords ; do
76 files=$(grep -l '$'"$keyword" $svnfiles)
77 if [ -z "$files" ] ; then
78 echo "xxxxx No file found with \$$keyword"
81 nbfiles=$(ls -1 $files | wc -l)
82 echo "xxxxx Found" $nbfiles "with \$$keyword"
84 for file in $files ; do
85 run_keyword_on_file $keyword $file
89 for keyword in $keywords ; do
90 grep '$'"$keyword" $dir > /dev/null && run_keyword_on_file $keyword $dir
96 # removes expansion of the specified keywords for diff
97 # useful when comparing with another codebase
98 function run_normalize_on_files () {
99 for keyword in $keywords ; do
100 echo "Deflating \$$keyword on $# files"
101 for file in "$@" ; do
102 sed -e 's,$'"$keyword"'.*\$,\$'"$keyword"'$,' $file > $file.new
108 function run_normalize () {
111 if [ -d $dir ] ; then
113 echo "xxxxxxxxxxxxxxxxxxxx Normalizing keywords $keywords in $(pwd) "
114 echo -n "xxxxxxxxxx Gathering actual files under subversion "
115 svnfiles=$(svn list -R)
118 for scan in $svnfiles; do
119 if [ -d $scan ] ; then continue
120 elif [ -L $scan ] ; then continue
121 else files="$files $scan"
124 echo $(ls -1 $files |wc -l) files found
125 run_normalize_on_files $files
128 run_normalize_on_files $dir
141 echo Unsupported command $0 ;;