std.c: Improve some comments
[sunny256-utils.git] / svnstat
blob49f93b69b21275bd0620d52189db850dda98a0fd
1 #!/usr/bin/env perl
3 #=======================================================================
4 # svnstat
5 # File ID: 348a6fb6-f744-11dd-87e5-000475e441b9
6 # Generates a gnuplot curve of weekly Subversion commits. Extremely
7 # primitive at the moment.
9 # Character set: UTF-8
10 # ©opyleft 2004– Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later, see end of
12 # file for legal stuff.
13 #=======================================================================
15 use strict;
16 use warnings;
17 use Getopt::Long;
19 $| = 1;
21 our $Debug = 0;
23 our %Opt = (
25 'debug' => 0,
26 'force' => 0,
27 'help' => 0,
28 'verbose' => 0,
29 'version' => 0,
33 our $progname = $0;
34 $progname =~ s/^.*\/(.*?)$/$1/;
35 our $VERSION = "0.00";
37 Getopt::Long::Configure("bundling");
38 GetOptions(
40 "debug" => \$Opt{'debug'},
41 "force|f" => \$Opt{'force'},
42 "help|h" => \$Opt{'help'},
43 "verbose|v+" => \$Opt{'verbose'},
44 "version" => \$Opt{'version'},
46 ) || die("$progname: Option error. Use -h for help.\n");
48 $Opt{'debug'} && ($Debug = 1);
49 $Opt{'help'} && usage(0);
50 if ($Opt{'version'}) {
51 print_version();
52 exit(0);
55 my $dat_file = "svnstat.dat";
56 my $tmp_file = "svnstat.tmp";
57 my $ep_file = "svnstat.ep.tmp";
58 my $week_file = "svnstat.week.dat";
59 my $count_file = "svnstat.count.dat";
60 my $time_file = "svnstat.time.dat";
61 my $create_log = 1;
63 my $args = "";
65 if (scalar(@ARGV)) {
66 $args = join(" ", @ARGV);
69 if (-e $dat_file) {
70 if ($Opt{'force'}) {
71 print("$dat_file exists, but --force was specified.\n");
72 } else {
73 print("$dat_file exists, skipping svn log.\n");
74 $create_log = 0;
78 if ($create_log) {
79 print("Running svn log...\n");
80 system("svn log --xml $args >$dat_file");
83 system("LC_ALL=C LC_CTYPE=C grep '<date>' $dat_file | cut -c7-25,33 | sort >$tmp_file");
84 system("deep $tmp_file >$ep_file");
85 system("ep_day -w 1 $ep_file | ep >$week_file");
86 system("stpl -k -t \"Commits per week\" $week_file");
87 system("inc_epstat $tmp_file >$count_file");
88 system("stpl -k -t \"Incrementally number of revisions\" $count_file");
89 system("ep-pause -s $ep_file >$time_file");
90 system("stpl -k -t \"Number of seconds between commits\" $time_file");
92 # unlink($tmp_file);
93 # unlink($week_file);
95 sub print_version {
96 # Print program version {{{
97 print("$progname v$VERSION\n");
98 # }}}
99 } # print_version()
101 sub usage {
102 # Send the help message to stdout {{{
103 my $Retval = shift;
105 if ($Opt{'verbose'}) {
106 print("\n");
107 print_version();
109 print(<<END);
111 Usage: $progname [options] [file_or_url [...]]
113 Options:
115 -f, --force
116 Force execution of “svn log”.
117 -h, --help
118 Show this help.
119 -v, --verbose
120 Increase level of verbosity. Can be repeated.
121 --version
122 Print version information.
123 --debug
124 Print debugging messages.
127 exit($Retval);
128 # }}}
129 } # usage()
131 sub msg {
132 # Print a status message to stderr based on verbosity level {{{
133 my ($verbose_level, $Txt) = @_;
135 if ($Opt{'verbose'} >= $verbose_level) {
136 print(STDERR "$progname: $Txt\n");
138 # }}}
139 } # msg()
141 sub D {
142 # Print a debugging message {{{
143 $Debug || return;
144 my @call_info = caller;
145 chomp(my $Txt = shift);
146 my $File = $call_info[1];
147 $File =~ s#\\#/#g;
148 $File =~ s#^.*/(.*?)$#$1#;
149 print(STDERR "$File:$call_info[2] $$ $Txt\n");
150 return("");
151 # }}}
152 } # D()
154 __END__
156 # Plain Old Documentation (POD) {{{
158 =pod
160 =head1 NAME
162 svnstat
164 =head1 SYNOPSIS
166 svnstat [options] [file_or_url [...]]
168 =head1 DESCRIPTION
170 Generate statistics for Subversion commits.
172 =head1 OPTIONS
174 =over 4
176 =item B<-f>, B<--force>
178 Force “svn log” to run even if F<svnstat.dat> exists.
180 =item B<-h>, B<--help>
182 Print a brief help summary.
184 =item B<-v>, B<--verbose>
186 Increase level of verbosity. Can be repeated.
188 =item B<--version>
190 Print version information.
192 =item B<--debug>
194 Print debugging messages.
196 =back
198 =head1 AUTHOR
200 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
202 =head1 COPYRIGHT
204 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
205 This is free software; see the file F<COPYING> for legalese stuff.
207 =head1 LICENCE
209 This program is free software: you can redistribute it and/or modify it
210 under the terms of the GNU General Public License as published by the
211 Free Software Foundation, either version 2 of the License, or (at your
212 option) any later version.
214 This program is distributed in the hope that it will be useful, but
215 WITHOUT ANY WARRANTY; without even the implied warranty of
216 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
217 See the GNU General Public License for more details.
219 You should have received a copy of the GNU General Public License along
220 with this program.
221 If not, see L<http://www.gnu.org/licenses/>.
223 =head1 SEE ALSO
225 =cut
227 # }}}
229 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :