3 # Copyright (c) 2014 The FreeBSD Foundation
6 # This software were developed by Glen Barber
7 # under sponsorship from the FreeBSD Foundation.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
40 echo -n "$(basename ${0}) [-rNNNNNN]"
41 echo " [-l /path/for/output] /path/to/branch"
42 echo " -r: The oldest commit to include in the search"
48 while getopts "l:r:" arg ; do
51 # Disallow '-rNNNNNN' argument for oldest
52 # revision # from becoming the log file
54 where="${OPTARG##-r*}"
55 [ -z "${where}" ] && usage
56 if [ -e "${where}" ]; then
57 echo "Log file already exists:"
64 c=$(echo -n ${rev} | tr -d '0-9' | wc -c)
65 if [ ${c} -ne 0 ]; then
66 echo "Revision number must be numeric."
69 # Since the last specified revision is
70 # specified, mangle the variable to
71 # make svn syntax happy.
79 shift $(( ${OPTIND} - 1 ))
81 # This assumes a local working copy, which svn search
82 # allows exactly one repository path (although the root
83 # can still be the path).
84 [ "$#" -ne 1 ] && usage
86 # If no log file, write to stdout.
87 [ -z "${where}" ] && where=/dev/stdout
91 for s in /usr/bin /usr/local/bin; do
92 if [ -x ${s}/svn ]; then
96 if [ -x ${s}/svnlite ]; then
102 if [ -z "${svn}" ]; then
103 echo "svn(1) binary not found."
106 # Is more than one path specified? (This should never
107 # be triggered, because the argument count is checked
108 # above, but better safe than sorry.)
109 if [ $# -gt 1 ]; then
110 echo "Cannot specify more than one working path."
113 # Does the directory exist?
114 if [ ! -d "${1}" ]; then
115 echo "Specified path (${1}) is not a directory."
118 # Is it a subversion repository checkout?
119 ${svn} info ${1} >/dev/null 2>&1
120 if [ "$?" -ne 0 ]; then
121 echo "Cannot determine svn repository information for ${1}"
125 # All tests passed. Let's see what can possibly go wrong
126 # from here. The search string specified should match this
127 # in PCRE speak: ':[\t ]*'
128 ${svn} log ${rev} --search 'Relnotes:*[A-Za-z0-9]*' ${1} > ${where}