/[SVNBrowser]/trunk/lib/SVNBrowser/Indexer.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/SVNBrowser/Indexer.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 63 - (show annotations)
Mon Sep 3 20:10:08 2007 UTC (16 years, 8 months ago) by dpavlin
File size: 1984 byte(s)
moved indexer into own package and use it
1 package SVNBrowser::Indexer;
2
3 # Dobrica Pavlinusic, <dpavlin@rot13.org> 09/03/07 21:54:40 CEST
4
5 use strict;
6 use warnings;
7
8 use base qw/Jifty::Object/;
9
10 use Data::Dump qw/dump/;
11
12 sub reindex {
13 my $self = shift;
14
15 my $repository = shift;
16
17 $self->log->logdie("repository is ", ref($repository)) unless $repository->isa('SVNBrowser::Model::Repository');
18
19 my ($start_rev,$end_rev) = (1, 'HEAD');
20
21 my $rev_col = SVNBrowser::Model::RevisionCollection->new;
22 $rev_col->unlimit;
23 $rev_col->order_by({ column => 'revision', order => 'DES' });
24 my $last_rev = $rev_col->first;
25
26 if ($last_rev) {
27 $start_rev = $last_rev->revision;
28 $self->log->info("Indexing ", $repository->uri, " rev $start_rev - $end_rev [branch regex: ", $repository->branch_regex, "]");
29 }
30
31 SVN::Log::retrieve({
32 repository => $repository->uri,
33 start => $start_rev,
34 end => $end_rev,
35 callback => sub {
36 my ($paths,$revision,$author,$date,$message) = @_;
37
38 return if ($last_rev && $revision <= $last_rev->revision);
39
40 $author ||= 'anonymous';
41
42 my $r = SVNBrowser::Model::Revision->new;
43 my $id = $r->load_or_create(
44 repository => $repository,
45 revision => $revision,
46 author => $author,
47 commit_date => $date,
48 message => $message,
49 );
50
51 $self->log->info("$revision -> $id $date $author");
52 foreach my $path (keys %$paths) {
53 my $action = $paths->{$path}->{action} || die "no action in ", dump($path);
54
55 my $branch = '/';
56 ($branch,$path) = ($1,$2) if ($path =~ m/$repository->branch_regex/);
57
58 my $b = SVNBrowser::Model::Branch->new;
59 $b->load_or_create(
60 path => $branch,
61 );
62
63 my $rb = SVNBrowser::Model::RevisionBranch->new;
64 $rb->load_or_create(
65 revision => $r,
66 branch => $b,
67 );
68
69 my $a = SVNBrowser::Model::Action->new;
70 $a->load_or_create(
71 revision => $revision,
72 type => $action,
73 branch => $branch,
74 rel_path => $path,
75 );
76
77 $self->log->info(" $action | $branch | $path");
78 }
79 }
80 });
81
82 }
83
84 1;

  ViewVC Help
Powered by ViewVC 1.1.26