| 1 |
#!/usr/bin/env mksh |
|---|
| 2 |
#- |
|---|
| 3 |
# Copyright (c) 2007 |
|---|
| 4 |
# Thorsten Glaser <tg@mirbsd.de> |
|---|
| 5 |
# |
|---|
| 6 |
# Provided that these terms and disclaimer and all copyright notices |
|---|
| 7 |
# are retained or reproduced in an accompanying document, permission |
|---|
| 8 |
# is granted to deal in this work without restriction, including un- |
|---|
| 9 |
# limited rights to use, publicly perform, distribute, sell, modify, |
|---|
| 10 |
# merge, give away, or sublicence. |
|---|
| 11 |
# |
|---|
| 12 |
# Advertising materials mentioning features or use of this work must |
|---|
| 13 |
# display the following acknowledgement: |
|---|
| 14 |
# This product includes material provided by Thorsten Glaser. |
|---|
| 15 |
# |
|---|
| 16 |
# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to |
|---|
| 17 |
# the utmost extent permitted by applicable law, neither express nor |
|---|
| 18 |
# implied; without malicious intent or gross negligence. In no event |
|---|
| 19 |
# may a licensor, author or contributor be held liable for indirect, |
|---|
| 20 |
# direct, other damage, loss, or other issues arising in any way out |
|---|
| 21 |
# of dealing in the work, even if advised of the possibility of such |
|---|
| 22 |
# damage or existence of a defect, except proven that it results out |
|---|
| 23 |
# of said person's immediate fault when using the work as intended. |
|---|
| 24 |
|
|---|
| 25 |
export LC_ALL=C; unset LANGUAGE |
|---|
| 26 |
|
|---|
| 27 |
topdir=$(readlink -nf "${1:-$(dirname "$0")}") |
|---|
| 28 |
topdir=${topdir%%/trunk*} |
|---|
| 29 |
topdir=${topdir%%/branch*} |
|---|
| 30 |
topdir=${topdir%%/tag*} |
|---|
| 31 |
|
|---|
| 32 |
cd "$topdir" |
|---|
| 33 |
if [[ ! -d trunk || ! -d branches || ! -d .svn ]]; then |
|---|
| 34 |
print -u2 cannot figure out top directory |
|---|
| 35 |
exit 1 |
|---|
| 36 |
fi |
|---|
| 37 |
|
|---|
| 38 |
svn log -qrHEAD:1 |& |
|---|
| 39 |
set -A allrevs -- - |
|---|
| 40 |
set -A authors _total |
|---|
| 41 |
set -A authrevs 0 |
|---|
| 42 |
while read -pr revn bar author rest; do |
|---|
| 43 |
[[ $revn = r+([0-9]) ]] || continue |
|---|
| 44 |
integer rev=${revn#r} |
|---|
| 45 |
#print -u2 revision $rev by $author |
|---|
| 46 |
allrevs[rev]=$author |
|---|
| 47 |
integer i=1 |
|---|
| 48 |
while (( i < ${#authors[*]} )); do |
|---|
| 49 |
[[ $author = ${authors[i]} ]] && break |
|---|
| 50 |
let i++ |
|---|
| 51 |
done |
|---|
| 52 |
authors[i]=$author |
|---|
| 53 |
let authrevs[i]++ |
|---|
| 54 |
let authrevs[0]++ |
|---|
| 55 |
done |
|---|
| 56 |
|
|---|
| 57 |
#print -u2 dump: |
|---|
| 58 |
#integer i=0 |
|---|
| 59 |
#while (( i < ${#authors[*]} )); do |
|---|
| 60 |
# print "| ${authors[i]} ${authrevs[i]}" |
|---|
| 61 |
# let i++ |
|---|
| 62 |
#done | sort -nrk3 | column -t >&2 |
|---|
| 63 |
|
|---|
| 64 |
# select-sort |
|---|
| 65 |
integer i=0 n=${#authors[*]} |
|---|
| 66 |
while (( i < (n - 1) )); do |
|---|
| 67 |
integer j=i+1 k=i |
|---|
| 68 |
while (( j < n )); do |
|---|
| 69 |
(( authrevs[j] < authrevs[k] )) || let k=j |
|---|
| 70 |
let j++ |
|---|
| 71 |
done |
|---|
| 72 |
if (( i != k )); then |
|---|
| 73 |
t=${authors[i]} |
|---|
| 74 |
authors[i]=${authors[k]} |
|---|
| 75 |
authors[k]=$t |
|---|
| 76 |
let j=authrevs[i] |
|---|
| 77 |
let authrevs[i]=authrevs[k] |
|---|
| 78 |
let authrevs[k]=j |
|---|
| 79 |
fi |
|---|
| 80 |
let i++ |
|---|
| 81 |
done |
|---|
| 82 |
|
|---|
| 83 |
print -u2 dump: |
|---|
| 84 |
i=0 |
|---|
| 85 |
while (( i < ${#authors[*]} )); do |
|---|
| 86 |
print "| ${authors[i]} ${authrevs[i]}" |
|---|
| 87 |
let i++ |
|---|
| 88 |
done | column -t >&2 |
|---|
| 89 |
|
|---|
| 90 |
i=0 |
|---|
| 91 |
integer orows=0 |
|---|
| 92 |
while (( i < n )); do |
|---|
| 93 |
eval set -A orows$i |
|---|
| 94 |
integer rev=1 revs=0 orow=0 |
|---|
| 95 |
me=${authors[i]} |
|---|
| 96 |
if [[ $me = _total ]]; then |
|---|
| 97 |
line=\"total\" |
|---|
| 98 |
me='*' |
|---|
| 99 |
else |
|---|
| 100 |
line=\"$me\" |
|---|
| 101 |
fi |
|---|
| 102 |
eval orows$i[orow++]=\$line |
|---|
| 103 |
while (( rev <= authrevs[0] )); do |
|---|
| 104 |
[[ ${allrevs[rev]} = $me ]] && let revs++ |
|---|
| 105 |
eval orows$i[orow++]=\$revs |
|---|
| 106 |
let rev++ |
|---|
| 107 |
done |
|---|
| 108 |
(( orows < orow )) && let orows=orow |
|---|
| 109 |
let i++ |
|---|
| 110 |
done |
|---|
| 111 |
|
|---|
| 112 |
# fucking openoffice has a 256-column limit on spreadsheets |
|---|
| 113 |
# Lotus 1-2-3 9.5 doesn't seem to be much better so reshape |
|---|
| 114 |
integer orow=0 |
|---|
| 115 |
while (( orow < orows )); do |
|---|
| 116 |
integer j=0 |
|---|
| 117 |
sp= |
|---|
| 118 |
while (( j < i )); do |
|---|
| 119 |
eval print -n -- "\$sp\${orows$j[orow]}" |
|---|
| 120 |
sp=';' |
|---|
| 121 |
let j++ |
|---|
| 122 |
done |
|---|
| 123 |
print |
|---|
| 124 |
let orow++ |
|---|
| 125 |
done |
|---|
| 126 |
exit 0 |
|---|