/[simile]/svn/index.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /svn/index.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (hide annotations)
Sun Oct 5 18:45:10 2008 UTC (15 years, 5 months ago) by dpavlin
Original Path: svn/svn2js.cgi
File size: 1691 byte(s)
experimental svn broser

based on http://stud05.technikum-wien.at/~tw05n126/exhibit/log/log.html
1 dpavlin 14 #!/usr/bin/perl -w
2    
3     # svn2js.pl
4     #
5     # 10/05/08 16:15:38 CEST Dobrica Pavlinusic <dpavlin@rot13.org>
6    
7     use strict;
8     use XML::Simple;
9     use Data::Dump qw/dump/;
10     use JSON;
11    
12     my $debug = 0;
13    
14     my $max_items = 500;
15    
16     my $repository = 'file:///home/dpavlin/.svk/strix4/';
17     my $svnweb = 'http://localhost/svnweb/svk/index.cgi/strix4/revision?rev=';
18    
19     my $json = {
20     properties => {
21     revision => {
22     valueType => "number",
23     },
24     'google-code-svn-link' => {
25     valueType => "url"
26     }
27     },
28     items => [],
29     };
30    
31     my $log;
32     {
33     open( my $log_fh, '-|', "svn log --xml --stop-on-copy -v $repository" ) || die "can't read svn log: $!";
34     local $/ = undef;
35     $log = <$log_fh>;
36     close( $log_fh );
37     }
38    
39     my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]);
40    
41     warn dump( $xml ) if $debug;
42    
43     foreach my $e (@{$xml->{'logentry'}}) {
44    
45     foreach my $p (@{$e->{'paths'}->{'path'}}) {
46     my $label = $e->{'revision'} . ' - ' . $p->{'content'};
47     my $item = {
48     type => 'Item',
49     id => $label,
50     label => $label,
51     uri => $svnweb . $e->{'revision'},
52     path => delete( $p->{'content'} ),
53     };
54    
55     $item->{$_} = $p->{$_} foreach keys %$p;
56     $item->{$_} = $e->{$_} foreach grep { ! /^(paths)$/ } keys %$e;
57    
58     $item->{'path'} =~ s!^/[^/]+/[^/]+/!/!;
59    
60     warn dump( $item ) if $debug;
61    
62     push @{ $json->{items} }, $item;
63    
64     $max_items--;
65     # we skip all other items in commits with more than 10 files as they are too chatty
66     last if $#{ $e->{'paths'}->{'path'} } > 10;
67     # last; # FIXME record just single item for each commit!
68     # we also break out when $max_items is reached to keep browser (somewhat) alive
69     last if ! $max_items;
70     }
71    
72     last if ! $max_items;
73     }
74    
75     print qq|Content-type: application/json\n\r\n\r|, encode_json( $json );
76    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26