4 # summarize and re-format subversion's log output to plain text
6 # Written by Rocco Rutte <pdmef@cs.tu-berlin.de>
7 # for internal use with mutt-ng <http://mutt-ng.berlios.de/>.
12 # -t print only today's messages
13 # -s YYYY-MM-DD print only messages since (and including) date
14 # -i string use string for indentation
15 # -m number break lines at the latest at number columns
18 # Note: lines matching ``^([^:]+):?$'' will be ignored if the first
19 # submatch in brackets is a known author; i.e. the logs
29 # will be interpreted as only 'added l33t c0d3' if 'Foo Bar' is known as
30 # an author. This does not count when grouping messages for authors,
31 # those lines are just skipped. This is hard-coded, see below.
37 # hard-coded configuration: this maps user to full names
39 "ak1" => "Andreas Krennmair",
40 "nion" => "Nico Golde",
41 "pdmef" => "Rocco Rutte",
42 "dkg1" => "Daniel K. Gebhart"
47 "filesM" => "Modified",
67 # nicely print log lines in itemized style with eye-candy indentation and
68 # somewhat smart line-breaking
71 my @lines = split (/\n/, $text);
73 print "$indent$indent-";
74 my @words = split (/\ /, $l);
75 my $c = length ($indent);
77 if (length ($w) + $c > $linemax) {
78 print "\n$indent$indent $w";
79 $c = length ($indent);
83 $c += length ($w) + 1;
91 This is: svnlog2changelog.pl
92 written by Rocco Rutte <pdmef\@cs.tu-berlin.de>
93 for use with mutt-ng <http://mutt-ng.berlios.de/>
97 svn log | svnlog2changelog.pl -h
99 Print Subversion's log for today:
100 svn log | svnlog2changelog.pl -t [-i string]
102 Print Subversion's log since (and including) YYYY-MM-DD
103 svn log | svnlog2changelog.pl -s YYYY-MM-DD [-i string]
110 for my $k (keys %commiters) {
111 if ($commiters{$k} eq $name) {
118 # get and process options
119 getopts ("tm:s:hi:", \%options);
120 if (defined $options{'t'}) {
121 $today = strftime ("%Y-%m-%d", localtime (time ()));
123 if (defined $options{'m'} and $options{'m'} =~ /^[0-9]{2,}$/) {
124 $linemax = $options{'m'};
126 if (defined $options{'s'} and $options{'s'} =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) {
127 $since = $options{'s'};
129 if (defined $options{'h'}) {
133 if (defined $options{'i'}) {
134 $indent = $options{'i'};
140 if ($_ =~ /^r([0-9]+)/) {
145 my @items = split (/\ \|\ /, $_);
146 my @dateinfo = split (/\ /, $items[2]);
147 $curentry = $dateinfo[0];
148 ${$changes{$curentry}}{'author'} = $items[1];
149 $curauthor = $items[1];
150 # _keep_ latest rev. number for day
151 if (not defined ${$changes{$curentry}}{'rev'}) {
152 ${$changes{$curentry}}{'rev'} = substr ($items[0], 1);
154 # _keep_ latest commit time for day
155 if (not defined ${$changes{$curentry}}{'time'}) {
156 ${$changes{$curentry}}{'time'} = "$dateinfo[1] $dateinfo[2]";
163 if (length ($_) == 0 or $_ =~ /^[-]+$/ or
164 $_ =~ /^([^:]+):?$/ and &isknown ($1) or
165 $_ eq "Changed paths:") {
168 if ($_ =~ /([A-Z]) \/((trunk|branches|tags).*)$/) {
171 ${${$changes{$curentry}}{"files$what"}}{$target} = 1;
173 # try to be smart and remove itemizations people make
175 $clean =~ s/^[- \t*]*//;
176 if (length ($clean) > 0) {
177 # _pre_pend space for continued log and newline for
178 # new log lines for new revisions
179 # if (defined ${${$changes{$curentry}}{'log'}}{$curauthor} and
180 # length (${${$changes{$curentry}}{'log'}}{$curauthor}) > 0) {
181 # if ($lastrev eq $currev) {
182 # ${${$changes{$curentry}}{'log'}}{$curauthor} .= " ";
184 # ${${$changes{$curentry}}{'log'}}{$curauthor} .= "\n";
187 # ${${$changes{$curentry}}{'log'}}{$curauthor} .= "$clean";
188 ${${$changes{$curentry}}{'log'}}{$curauthor} .= "$clean\n";
198 for my $k (sort { $b cmp $a } (keys (%changes))) {
200 if (not defined %{${$changes{$k}}{'log'}} or
201 (length ($since) > 0 && length ($today) == 0 && ($k lt $since)) or
202 (length ($today) > 0 && ($k ne $today))) {
205 # print first line with date, time and latest revision for current day
206 print "$first$k ${$changes{$k}}{'time'} ";
209 print "Latest Revision: ${$changes{$k}}{'rev'}\n\n";
210 # per author: print his name and an itemized list of his log msgs.
211 # with smart line-breaking and indentation
212 for my $a (keys %{${$changes{$k}}{'log'}}) {
213 print "$first2$indent";
214 if (defined $commiters{$a}) {
215 print $commiters{$a};
220 &niceline (${${$changes{$k}}{'log'}}{$a});
223 for my $a (keys %fmap) {
224 if (defined %{${$changes{$k}}{$a}}) {
225 print "$first$indent$fmap{$a} Files:\n";
226 my $fixme = join (", ", keys %{${$changes{$k}}{$a}});