Ticket #1998: svnkeywords.sh

File svnkeywords.sh, 1.4 KB (added by mloskot, 8 years ago)

The script purpose is to reset svn:keywords property for files identified as using keywords.

Line 
1#!/bin/sh
2#
3# Author: Mateusz Loskot, mateusz@loskot
4# Revision: $Revision$
5# Date: $Date$
6#
7# The script purpose is to reset svn:keywords property for files
8# identified as using keywords.
9#
10# Set to 1 to print detailed listing of touched files and set keywords
11VERBOSE=0
12
13if test ! $# = 1; then
14    echo "Usage: `basename $0` <source path>"
15    exit 1
16fi
17
18SVNSRCPATH=${1}
19if test ! -d ${SVNSRCPATH}; then
20    echo "*** Given source location is not valid directory '${SVNSRCPATH}'"
21    exit 1
22fi
23
24SVN=`which svn`
25FIND=`which find`
26GREP=`which grep`
27
28if test ! -x ${SVN}; then
29    echo "Can not find Subversion program"
30    exit 1
31fi
32
33if test ! -x ${FIND}; then
34    echo "Can not locate find program"
35    exit 1
36fi
37
38if test ! -x ${GREP}; then
39    echo "Can not locate grep program"
40    exit 1
41fi
42
43echo "Entering '${SVNSRCPATH}'"
44echo "Setting svn:keywords property\c"
45
46${FIND} ${SVNSRCPATH} \( -path '*/.svn' \) -prune -o -type f -print | while read file ; do
47
48    plist=""
49    for p in Author Date Id Rev ; do
50        if ${GREP} -q '\$'${p}'' "${file}" ; then
51            plist="${p} $plist"
52        fi
53    done
54
55    if [ "$plist" != "" ] ; then 
56        ${SVN} propset svn:keywords "${plist%% }" ${file} > /dev/null 2>&1
57        if test ${VERBOSE} = 1; then
58            echo "${SVN} propset svn:keywords "${plist%% }" ${file} "
59        else
60            echo ".\c"
61        fi
62    fi
63done
64
65echo "done."