-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwindforward-svn.pl
executable file
·80 lines (60 loc) · 1.34 KB
/
windforward-svn.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
78
#!/usr/bin/perl -w
use strict;
my $gitdir;
my $MSGFILE = "commit-message.txt";
while ($ARGV[0] =~ /^\-/) {
my $opt = shift @ARGV;
if ($opt eq '-g' || $opt eq '--gitdir') {
$gitdir = shift @ARGV;
}
elsif ($opt eq '-h' || $opt eq '--help') {
print usage();
exit 0;
}
}
die unless $gitdir;
my $f = shift @ARGV;
my $logf = shift @ARGV;
die unless $f;
#my $cmd = "svn log $f";
#print STDERR "CMD: $cmd\n";
open(F, $logf) || die $logf;
my $log = join("",<F>);
close(F);
my @commits = split(/------*/,$log);
@commits = reverse @commits;
foreach my $commit (@commits) {
my @lines = split(/\n/, $commit);
shift @lines;
my $hline = shift @lines;
#print "r: $hline\n";
my ($rev, $user, $date, $lineinfo) = split(/ \| /, $hline);
if (!$rev) {
next;
}
open(F, ">$gitdir/$MSGFILE") || die;
print F $commit;
close(F);
runcmd("svn update -r $rev $f");
runcmd("(cp $f $gitdir && cd $gitdir && git commit -F $MSGFILE $f)");
}
exit 0;
sub runcmd {
my @c = @_;
print STDERR "CMD: @c\n";
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
}