| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Arch Perl library, Copyright (C) 2004 Mikhael Goikhman |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
4
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
5
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
6
|
|
|
|
|
|
|
# (at your option) any later version. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
9
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
14
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
|
15
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
16
|
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
46
|
use 5.005; |
|
|
3
|
|
|
|
|
10
|
|
|
|
3
|
|
|
|
|
111
|
|
|
18
|
3
|
|
|
3
|
|
14
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
114
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Arch::Storage; |
|
21
|
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
|
1787
|
use Arch::Name; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
223
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new ($%) { |
|
25
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
26
|
0
|
|
|
|
|
|
my %init = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $self = { $class->_default_fields }; |
|
29
|
0
|
|
|
|
|
|
bless $self, $class; |
|
30
|
0
|
|
|
|
|
|
$self->init(%init); |
|
31
|
|
|
|
|
|
|
|
|
32
|
3
|
|
|
3
|
|
17
|
no strict 'refs'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
236
|
|
|
33
|
0
|
|
|
|
|
|
${"${class}::global_instance"} = $self; |
|
|
0
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return $self; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub instance ($) { |
|
38
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
39
|
|
|
|
|
|
|
|
|
40
|
3
|
|
|
3
|
|
14
|
no strict 'refs'; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
3321
|
|
|
41
|
0
|
|
0
|
|
|
|
return ${"${class}::global_instance"} || $class->new; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub init ($%) { |
|
45
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
46
|
0
|
|
|
|
|
|
my %init = @_; |
|
47
|
0
|
|
|
|
|
|
while (my ($name, $value) = each %init) { |
|
48
|
0
|
0
|
|
|
|
|
die ref($self) . "::init: Option $name is unknown.\n" |
|
49
|
|
|
|
|
|
|
unless exists $self->{$name}; |
|
50
|
0
|
|
|
|
|
|
$self->{$name} = $value; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
0
|
|
|
|
|
|
return $self; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _default_fields ($) { |
|
56
|
0
|
|
|
0
|
|
|
my $this = shift; |
|
57
|
|
|
|
|
|
|
return ( |
|
58
|
0
|
|
|
|
|
|
name => Arch::Name->new, |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub working_name ($;$) { |
|
63
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
64
|
0
|
0
|
|
|
|
|
if (@_) { |
|
65
|
0
|
|
|
|
|
|
$self->{name} = Arch::Name->new(shift); |
|
66
|
0
|
|
|
|
|
|
$self->fixup_name_alias; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
0
|
|
|
|
|
|
return $self->{name}; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub working_names ($;$@) { |
|
72
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
73
|
0
|
0
|
|
|
|
|
if (@_) { |
|
74
|
0
|
0
|
|
|
|
|
$self->{name} = Arch::Name->new(ref($_[0])? $_[0]: [ @_ ]); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
|
|
|
|
|
return $self->{name}->get; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub fixup_name_alias ($) { |
|
80
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
81
|
0
|
|
|
|
|
|
$self->{name_alias} = 0; |
|
82
|
0
|
|
|
|
|
|
$self->{version_alias} = undef; |
|
83
|
0
|
|
|
|
|
|
$self->{revision_alias} = undef; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $name = $self->{name}; |
|
86
|
0
|
|
|
|
|
|
my ($version, $revision) = ($name->get)[3, 4]; |
|
87
|
0
|
|
|
|
|
|
foreach ( |
|
88
|
|
|
|
|
|
|
[ qw(version versions branch), $version ], |
|
89
|
|
|
|
|
|
|
[ qw(revision revisions version), $revision ] |
|
90
|
|
|
|
|
|
|
) { |
|
91
|
0
|
|
|
|
|
|
my ($element, $method, $parent, $alias) = @$_; |
|
92
|
0
|
0
|
0
|
|
|
|
if (defined $alias && $alias =~ /^FIRST|LATEST$/) { |
|
93
|
0
|
|
|
|
|
|
$name->$element(undef); |
|
94
|
0
|
|
|
|
|
|
my $values = $self->$method($name); |
|
95
|
0
|
0
|
|
|
|
|
die "There is no any $element in this $parent, so $name--$alias alias is invalid\n" |
|
96
|
|
|
|
|
|
|
unless @$values; |
|
97
|
0
|
0
|
|
|
|
|
my $value = $values->[$alias eq "FIRST"? 0: -1]; |
|
98
|
0
|
|
|
|
|
|
$value =~ s/^.*--//; |
|
99
|
0
|
|
|
|
|
|
$name->$element($value); |
|
100
|
0
|
0
|
|
|
|
|
$name->revision($revision) unless $element eq 'revision'; |
|
101
|
0
|
|
|
|
|
|
$self->{name_alias} = 1; |
|
102
|
0
|
|
|
|
|
|
$self->{"${element}_alias"} = $alias; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _name_operand ($$;$) { |
|
108
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
109
|
0
|
|
|
|
|
|
my $arg = shift; |
|
110
|
0
|
|
|
|
|
|
my $elem = shift; |
|
111
|
0
|
|
|
|
|
|
my $func = (caller(1))[3]; |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
my $name = $arg? Arch::Name->new($arg): $self->{name}; |
|
114
|
0
|
0
|
|
|
|
|
die "$func: no working name and no argument given\n" unless $name; |
|
115
|
0
|
0
|
|
|
|
|
if ($elem) { |
|
116
|
0
|
|
|
|
|
|
my $enclosing = $name->cast($elem); |
|
117
|
0
|
0
|
|
|
|
|
die "$func: operand '$name' is not $elem\n" unless $enclosing; |
|
118
|
0
|
|
|
|
|
|
$name = $enclosing; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
0
|
|
|
|
|
|
return $name; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub is_archive_managed ($;$) { |
|
124
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
125
|
0
|
|
|
|
|
|
my $archive = $self->_name_operand(shift, 'archive'); |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
unless ($self->{archives_presence}) { |
|
128
|
0
|
|
|
|
|
|
my $archives_hash = {}; |
|
129
|
0
|
|
|
|
|
|
$archives_hash->{$_} = 1 foreach @{$self->archives}; |
|
|
0
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
$self->{archives_presence} = $archives_hash; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
0
|
|
|
|
|
|
return $self->{archives_presence}->{$archive}; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub expanded_revisions ($) { |
|
136
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
my $all_revisions = []; |
|
139
|
0
|
|
|
|
|
|
my $archives = $self->archives; |
|
140
|
0
|
|
|
|
|
|
foreach my $archive (@$archives) { |
|
141
|
0
|
|
|
|
|
|
my $category_infos = $self->expanded_archive_info($archive, 1); |
|
142
|
0
|
|
|
|
|
|
foreach my $category_info (@$category_infos) { |
|
143
|
0
|
|
|
|
|
|
my ($category, $branch_infos) = @$category_info; |
|
144
|
0
|
|
|
|
|
|
foreach my $branch_info (@$branch_infos) { |
|
145
|
0
|
|
|
|
|
|
my ($branch, $version_infos) = @$branch_info; |
|
146
|
0
|
|
|
|
|
|
foreach my $version_info (@$version_infos) { |
|
147
|
0
|
|
|
|
|
|
my ($version, @revisions) = @$version_info; |
|
148
|
0
|
|
|
|
|
|
foreach my $revision (@revisions) { |
|
149
|
0
|
|
|
|
|
|
my $name = Arch::Name->new([ |
|
150
|
|
|
|
|
|
|
$archive, $category, $branch, $version, $revision, |
|
151
|
|
|
|
|
|
|
]); |
|
152
|
0
|
0
|
|
|
|
|
die $name->error . |
|
153
|
|
|
|
|
|
|
"\n\t($archive, $category, $branch, $version, $revision)\n" |
|
154
|
|
|
|
|
|
|
if $name->error; |
|
155
|
0
|
|
|
|
|
|
push @$all_revisions, $name; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
return $all_revisions; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
__END__ |