line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FreePAN::SVKMirror; |
2
|
1
|
|
|
1
|
|
1452
|
use FreePAN::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
use URI; |
5
|
|
|
|
|
|
|
use SVK 0.30; |
6
|
|
|
|
|
|
|
use SVK::XD; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
field svk => -init => q{$self->svk_init}; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub svk_init { |
11
|
|
|
|
|
|
|
$self->create_repos unless (-d $self->plugin_directory); |
12
|
|
|
|
|
|
|
my $xd = SVK::XD->new(depotmap => {'' => $self->plugin_directory}); |
13
|
|
|
|
|
|
|
return SVK->new(xd=>$xd); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub register { |
17
|
|
|
|
|
|
|
my $reg = shift; |
18
|
|
|
|
|
|
|
$reg->add(command => 'mirror', |
19
|
|
|
|
|
|
|
description => 'Mirror other svn repository to freepan repository'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub create_repos { |
23
|
|
|
|
|
|
|
system("svnadmin create --fs-type fsfs ". $self->plugin_directory); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub resolve_remote { |
27
|
|
|
|
|
|
|
my @dir = split('/',URI->new(shift||return)->path); |
28
|
|
|
|
|
|
|
($dir[-1]=~/trunk|tag|branch/i)?$dir[-2]:$dir[-1]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub mirror_freepan_repos { |
32
|
|
|
|
|
|
|
my ($reponame) = @_; |
33
|
|
|
|
|
|
|
my $remote = $self->hub->config->svn_domain_name . "/$reponame"; |
34
|
|
|
|
|
|
|
$self->svk->mirror("//freepan/$reponame",$remote); |
35
|
|
|
|
|
|
|
$self->svk->sync("//freepan/$reponame"); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub mirror_remote_repos { |
39
|
|
|
|
|
|
|
my ($reponame,$remote) = @_; |
40
|
|
|
|
|
|
|
$self->svk->mirror("//mirror/$reponame",$remote); |
41
|
|
|
|
|
|
|
$self->svk->sync("//mirror/$reponame"); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub handle_mirror { |
45
|
|
|
|
|
|
|
my ($repo,$remote,$rename) = @_; |
46
|
|
|
|
|
|
|
my $module = $self->resolve_remote($remote); |
47
|
|
|
|
|
|
|
$self->mirror_freepan_repos($repo); |
48
|
|
|
|
|
|
|
$self->mirror_remote_repos($module,$remote); |
49
|
|
|
|
|
|
|
$self->svk->mkdir("//freepan/$repo/$module", |
50
|
|
|
|
|
|
|
-p => -m => "make $module directory"); |
51
|
|
|
|
|
|
|
$self->svk->smerge(-BI => '--verbatim' => "//mirror/$module","//freepan/$repo/$module"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__DATA__ |