-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert-to-relative
executable file
·48 lines (39 loc) · 1.09 KB
/
convert-to-relative
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env perl
#==============================================================================
# convert-to-relative
# File ID: 55d642ae-20dc-11e4-ad57-c80aa9e67bbd
#
# Convert repos.dat to a data set where every graph starts at zero.
#
# Author: Øyvind A. Holm <[email protected]>
# License: GNU General Public License version 2 or later.
#==============================================================================
use strict;
use warnings;
my $progname = "convert-to-relative";
my $VERSION = "0.2.0";
exit(main());
sub main {
my $Retval = 0;
my %init = ();
for my $f (qw{ bazaar cvs git mercurial subversion }) {
$init{$f} = `sqlite3 repos.sqlite "
SELECT $f FROM repos ORDER BY date LIMIT 1;"`;
}
while (<>) {
if (/^(20.*?)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)/) {
printf("%s %u %u %u %u %u\n",
$1,
$2 - $init{bazaar},
$3 - $init{cvs},
$4 - $init{git},
$5 - $init{mercurial},
$6 - $init{subversion},
);
} else {
print;
}
}
return $Retval;
} # main()
# vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :