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

Diff of /trunk/bin/indexer

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/svn-indexer.pl revision 26 by dpavlin, Sun Dec 10 00:01:33 2006 UTC trunk/bin/indexer revision 63 by dpavlin, Mon Sep 3 20:10:08 2007 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  # svn-indexer.pl  # SVNBrowser indexer
4  #  #
5  # 12/04/06 22:19:20 CET Dobrica Pavlinusic <dpavlin@rot13.org>  # 12/04/06 22:19:20 CET Dobrica Pavlinusic <dpavlin@rot13.org>
6    
# Line 8  use strict; Line 8  use strict;
8    
9  use lib 'lib';  use lib 'lib';
10    
   
11  use SVN::Log;  use SVN::Log;
12  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
13    
14  use Jifty;  use Jifty;
15    use SVNBrowser::Indexer;
16    
17  BEGIN { Jifty->new };  BEGIN { Jifty->new };
18    
19  my $repository = shift @ARGV || Jifty->config->app('repository');  my $repository = shift @ARGV || Jifty->config->app('repository');
20    
 my ($start_rev,$end_rev) = (1, 'HEAD');  
   
21  my $system_user = SVNBrowser::CurrentUser->superuser;  my $system_user = SVNBrowser::CurrentUser->superuser;
22    
23  my $rev_col = SVNBrowser::Model::RevisionCollection->new(current_user => $system_user);  my $rep_col = SVNBrowser::Model::RepositoryCollection->new(current_user => $system_user);
24  $rev_col->unlimit;  $rep_col->unlimit;
25  $rev_col->order_by({ column => 'revision', order => 'DES' });  while ( my $rep = $rep_col->next ) {
26  my $last_rev = $rev_col->first;          SVNBrowser::Indexer->reindex( $rep );
   
 my $branch_regex = Jifty->config->app('branch_regex');  
   
 if ($last_rev) {  
         $start_rev = $last_rev->revision;  
         warn "Index $repository rev $start_rev - $end_rev [branch regex: $branch_regex]\n";  
27  }  }
28    
 SVN::Log::retrieve({  
         repository => $repository,  
         start => $start_rev,  
         end => $end_rev,  
         callback => sub {  
                 my ($paths,$revision,$author,$date,$message) = @_;  
   
                 return if ($last_rev && $revision <= $last_rev->revision);  
   
                 $author ||= 'anonymous';  
   
                 my $r = SVNBrowser::Model::Revision->new(current_user => $system_user);  
                 my $id = $r->load_or_create(  
                         revision => $revision,  
                         author => $author,  
                         commit_date => $date,  
                         message => $message,  
                 );  
                 print "$revision -> $id $date $author\n";  
                 foreach my $path (keys %$paths) {  
                         my $action = $paths->{$path}->{action} || die "no action in ", dump($path);  
   
                         my $branch = '/';  
                         ($branch,$path) = ($1,$2) if ($path =~ m/$branch_regex/);  
   
                         my $b = SVNBrowser::Model::Branch->new(current_user => $system_user);  
                         $b->load_or_create(  
                                 path => $branch,  
                         );  
                           
                         my $rb = SVNBrowser::Model::RevisionBranch->new(current_user => $system_user);  
                         $rb->load_or_create(  
                                 revision => $r,  
                                 branch => $b,  
                         );  
   
                         my $a = SVNBrowser::Model::Action->new(current_user => $system_user);  
                         $a->load_or_create(  
                                 revision => $revision,  
                                 type => $action,  
                                 branch => $branch,  
                                 rel_path => $path,  
                         );  
   
                         print " $action | $branch | $path\n";  
                 }  
         }  
 });  
   
   

Legend:
Removed from v.26  
changed lines
  Added in v.63

  ViewVC Help
Powered by ViewVC 1.1.26