line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VCS::Lite::Store; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
51395
|
use strict; |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
322
|
|
4
|
10
|
|
|
10
|
|
40
|
use warnings; |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
353
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
9
|
|
|
|
|
|
|
|
10
|
10
|
|
|
10
|
|
45
|
use Carp; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
636
|
|
11
|
10
|
|
|
10
|
|
55
|
use File::Spec::Functions qw(:ALL); |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
1941
|
|
12
|
10
|
|
|
10
|
|
51
|
use Time::Piece; |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
76
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $hidden_repos_dir = '.VCSLite'; |
15
|
|
|
|
|
|
|
$hidden_repos_dir = '_VCSLITE' if $^O =~ /vms/i; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
0
|
|
|
0
|
1
|
0
|
my ($pkg, %par) = @_; |
21
|
0
|
|
|
|
|
0
|
bless \%par,$pkg; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub retrieve { |
25
|
248
|
|
|
248
|
1
|
338
|
my ($self, $path) = @_; |
26
|
|
|
|
|
|
|
|
27
|
248
|
|
|
|
|
498
|
my $store_file = $self->store_path($path); |
28
|
248
|
100
|
|
|
|
6096
|
return unless -e $store_file; |
29
|
181
|
50
|
|
|
|
563
|
my $obj = $self->load($store_file) or die "Failed to retrieve $path"; |
30
|
181
|
|
|
|
|
15439
|
$obj->{store} = $self; |
31
|
181
|
|
|
|
|
574
|
$obj; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub retrieve_or_create { |
35
|
121
|
|
|
121
|
1
|
180
|
my ($self, $proto) = @_; |
36
|
|
|
|
|
|
|
|
37
|
121
|
|
|
|
|
346
|
my $path = $proto->path; |
38
|
|
|
|
|
|
|
|
39
|
121
|
100
|
|
|
|
276
|
$self->retrieve($path) || $self->create($proto); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub create { |
43
|
41
|
|
|
41
|
1
|
66
|
my ($self, $proto) = @_; |
44
|
|
|
|
|
|
|
|
45
|
41
|
|
|
|
|
114
|
my $path = $proto->path; |
46
|
|
|
|
|
|
|
|
47
|
41
|
|
|
|
|
94
|
my ($store_dir, $store_file) = $self->store_path($path); |
48
|
|
|
|
|
|
|
|
49
|
41
|
100
|
|
|
|
819
|
if (!-d $store_dir) { |
50
|
15
|
50
|
|
|
|
921
|
mkdir $store_dir or croak "Failed to make repository dir $store_dir"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
41
|
50
|
|
|
|
436
|
my $creator = $self->can('user') ? $self->user : $proto->user or croak "Username not specified"; |
|
|
50
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
41
|
|
|
|
|
144
|
@{$proto}{qw/store creator created/} = ($self,$creator,localtime->datetime); |
|
41
|
|
|
|
|
4564
|
|
56
|
41
|
|
|
|
|
152
|
my $class = ref $proto; |
57
|
41
|
|
|
|
|
2140
|
$proto->_mumble("Creating $class $path"); |
58
|
41
|
|
|
|
|
144
|
$proto->save($store_file); |
59
|
41
|
|
|
|
|
7121
|
$proto; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub store_path { |
63
|
420
|
|
|
420
|
1
|
460
|
my ($self,$path,$ext) = @_; |
64
|
|
|
|
|
|
|
|
65
|
420
|
|
|
|
|
955
|
my ($vol,$dir,$fil) = splitpath(rel2abs($path)); |
66
|
420
|
100
|
66
|
|
|
16777
|
if ($fil && -d $path) { # Because of the way splitpath works on Unix |
67
|
161
|
|
|
|
|
668
|
$dir = catdir($dir,$fil); |
68
|
161
|
|
|
|
|
247
|
$fil = ''; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
420
|
50
|
|
|
|
787
|
if (ref $self) { |
72
|
0
|
|
|
|
|
0
|
my ($hvol,$hdir) = splitpath($self->{home}); |
73
|
0
|
0
|
|
|
|
0
|
croak "Wrong volume in attempt to access store for $path" |
74
|
|
|
|
|
|
|
if $hvol ne $vol; |
75
|
0
|
|
|
|
|
0
|
my @dir = splitdir($dir); |
76
|
0
|
|
|
|
|
0
|
for (splitdir($hdir)) { |
77
|
0
|
|
|
|
|
0
|
my $dd = shift @dir; |
78
|
0
|
0
|
|
|
|
0
|
croak "Outside directory tree: $path" if $dd ne $_; |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
0
|
($vol,my $rdir) = splitpath($self->{root}); |
81
|
0
|
|
|
|
|
0
|
$dir = catdir($rdir,@dir); |
82
|
|
|
|
|
|
|
} else { |
83
|
420
|
|
|
|
|
1528
|
$dir = catdir($dir,$hidden_repos_dir); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
420
|
|
|
|
|
1269
|
($dir, catpath($vol, $dir, $self->repos_name($fil,$ext))); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |