-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathobo-cvs-log-and-diff.pl
executable file
·79 lines (67 loc) · 1.51 KB
/
obo-cvs-log-and-diff.pl
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/perl -w
$ENV{CVS_RSH} = 'ssh';
use strict;
my $diffcmd = 'obodiff';
while ($ARGV[0] =~ /^\-/) {
my $opt = shift @ARGV;
if ($opt eq '-d' || $opt eq '--diff') {
$diffcmd = shift @ARGV;
}
elsif ($opt eq '-h' || $opt eq '--help') {
print usage();
exit 0;
}
}
foreach my $f (@ARGV) {
my $cmd = "cvs log $f";
my @lines = split(/\n/,`$cmd`);
my @revs = ();
foreach (@lines) {
if (/^revision\s+(\S+)/) {
push(@revs,$1);
}
}
my $f1 = $f;
for (my $i=1; $i<@revs; $i++) {
my $rev = $revs[$i];
my $revp = $revs[$i-1];
my $f2 = $f.$rev;
runcmd("cvs diff -u -r $revp -r $rev $f > DIFF");
open(F,"DIFF") || die;
open(OF,">DIFF2") || die;
my $line = 0;
while(<F>) {
s/Index:\s+($f)/Index: $f1/;
s/^\-\-\-\s($f)/\-\-\- $f1/;
s/^\+\+\+\s($f)/\+\+\+ $f1/;
$line++;
print OF "$_";
}
close(OF);
close(F);
runcmd("patch -o $f2 < DIFF2");
runcmd("$diffcmd $f2 $f1 > obodiff.$f.$rev-$revp.diff");
$f1=$f2;
}
}
exit 0;
sub runcmd {
my @c = @_;
print STDERR "CMD: @c\n";
system("@c");
#system("@c") && die "@c";
}
sub scriptname {
my @p = split(/\//,$0);
pop @p;
}
sub usage {
my $sn = scriptname();
<<EOM;
$sn FILE.OBO
obodiff over history. Must be run from a cvs directory
Example:
cd cvs/go/ontology
$sn gene_ontology_edit.obo
EOM
}