line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VCS::Lite::Store; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
13417
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
271
|
|
4
|
8
|
|
|
8
|
|
120
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
339
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
44
|
use Carp; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
648
|
|
11
|
8
|
|
|
8
|
|
46
|
use File::Spec::Functions qw(:ALL); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
3314
|
|
12
|
8
|
|
|
8
|
|
53
|
use Time::Piece; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
80
|
|
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
|
379
|
my ($self, $path) = @_; |
26
|
|
|
|
|
|
|
|
27
|
248
|
|
|
|
|
628
|
my $store_file = $self->store_path($path); |
28
|
248
|
100
|
|
|
|
10776
|
return unless -e $store_file; |
29
|
181
|
50
|
|
|
|
907
|
my $obj = $self->load($store_file) or die "Failed to retrieve $path"; |
30
|
181
|
|
|
|
|
24837
|
$obj->{store} = $self; |
31
|
181
|
|
|
|
|
840
|
$obj; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub retrieve_or_create { |
35
|
121
|
|
|
121
|
1
|
219
|
my ($self, $proto) = @_; |
36
|
|
|
|
|
|
|
|
37
|
121
|
|
|
|
|
539
|
my $path = $proto->path; |
38
|
|
|
|
|
|
|
|
39
|
121
|
100
|
|
|
|
361
|
$self->retrieve($path) || $self->create($proto); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub create { |
43
|
41
|
|
|
41
|
1
|
81
|
my ($self, $proto) = @_; |
44
|
|
|
|
|
|
|
|
45
|
41
|
|
|
|
|
130
|
my $path = $proto->path; |
46
|
|
|
|
|
|
|
|
47
|
41
|
|
|
|
|
123
|
my ($store_dir, $store_file) = $self->store_path($path); |
48
|
|
|
|
|
|
|
|
49
|
41
|
100
|
|
|
|
1419
|
if (!-d $store_dir) { |
50
|
15
|
50
|
|
|
|
1301
|
mkdir $store_dir or croak "Failed to make repository dir $store_dir"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
41
|
50
|
|
|
|
663
|
my $creator = $self->can('user') ? $self->user : $proto->user or croak "Username not specified"; |
|
|
50
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
41
|
|
|
|
|
173
|
@{$proto}{qw/store creator created/} = ($self,$creator,localtime->datetime); |
|
41
|
|
|
|
|
5530
|
|
56
|
41
|
|
|
|
|
174
|
my $class = ref $proto; |
57
|
41
|
|
|
|
|
252
|
$proto->_mumble("Creating $class $path"); |
58
|
41
|
|
|
|
|
255
|
$proto->save($store_file); |
59
|
41
|
|
|
|
|
12472
|
$proto; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub store_path { |
63
|
420
|
|
|
420
|
1
|
773
|
my ($self,$path,$ext) = @_; |
64
|
|
|
|
|
|
|
|
65
|
420
|
|
|
|
|
1180
|
my ($vol,$dir,$fil) = splitpath(rel2abs($path)); |
66
|
420
|
100
|
66
|
|
|
29829
|
if ($fil && -d $path) { # Because of the way splitpath works on Unix |
67
|
161
|
|
|
|
|
762
|
$dir = catdir($dir,$fil); |
68
|
161
|
|
|
|
|
373
|
$fil = ''; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
420
|
50
|
|
|
|
924
|
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
|
|
|
|
|
1881
|
$dir = catdir($dir,$hidden_repos_dir); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
420
|
|
|
|
|
1903
|
($dir, catpath($vol, $dir, $self->repos_name($fil,$ext))); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |