1 |
dpavlin |
1 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
# svn-indexer.pl |
4 |
|
|
# |
5 |
|
|
# 12/04/06 22:19:20 CET Dobrica Pavlinusic <dpavlin@rot13.org> |
6 |
|
|
|
7 |
|
|
use strict; |
8 |
|
|
|
9 |
|
|
use lib 'lib'; |
10 |
|
|
|
11 |
|
|
use SVN::Log; |
12 |
|
|
use Data::Dump qw/dump/; |
13 |
|
|
|
14 |
|
|
use Jifty; |
15 |
|
|
|
16 |
|
|
BEGIN { Jifty->new }; |
17 |
|
|
|
18 |
|
|
my ($start_rev,$end_rev) = (1, 'HEAD'); |
19 |
|
|
|
20 |
|
|
my $system_user = SVNBrowser::CurrentUser->superuser; |
21 |
|
|
|
22 |
|
|
SVN::Log::retrieve({ |
23 |
|
|
repository => "svn://svn.pliva.hr/strix", |
24 |
|
|
start => $start_rev, |
25 |
|
|
end => $end_rev, |
26 |
|
|
callback => sub { |
27 |
|
|
my ($paths,$revision,$author,$date,$message) = @_; |
28 |
|
|
|
29 |
|
|
$author ||= 'anonymous'; |
30 |
|
|
|
31 |
|
|
my $r = SVNBrowser::Model::Revision->new(current_user => $system_user); |
32 |
|
|
my $id = $r->load_or_create( |
33 |
|
|
revision => $revision, |
34 |
|
|
author => $author, |
35 |
|
|
commit_date => $date, |
36 |
|
|
message => $message, |
37 |
|
|
); |
38 |
|
|
print "$revision -> $id $date $author\n"; |
39 |
|
|
foreach my $path (keys %$paths) { |
40 |
|
|
my $action = $paths->{$path}->{action} || die "no action in ", dump($path); |
41 |
|
|
|
42 |
|
|
my $branch = '/'; |
43 |
|
|
($branch,$path) = ($1,$2) if ($path =~ m!^(/[^/]+)(/.+)$!); |
44 |
|
|
|
45 |
|
|
my $a = SVNBrowser::Model::Action->new(current_user => $system_user); |
46 |
|
|
$a->load_or_create( |
47 |
|
|
revision => $revision, |
48 |
|
|
type => $action, |
49 |
|
|
branch => $branch, |
50 |
|
|
rel_path => $path, |
51 |
|
|
); |
52 |
|
|
print " $action | $branch | $path\n"; |
53 |
|
|
} |
54 |
|
|
} |
55 |
|
|
}); |
56 |
|
|
|
57 |
|
|
|