line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VCS::Which::Plugin; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2009-05-16 17:50:07 |
4
|
|
|
|
|
|
|
# Create by: ivan |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2853
|
use Moo; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
10
|
2
|
|
|
2
|
|
698
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
11
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
12
|
2
|
|
|
2
|
|
11
|
use version; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
15
|
|
13
|
2
|
|
|
2
|
|
156
|
use Carp; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
132
|
|
14
|
2
|
|
|
2
|
|
11
|
use Data::Dumper qw/Dumper/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
105
|
|
15
|
2
|
|
|
2
|
|
13
|
use English qw/ -no_match_vars /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
16
|
2
|
|
|
2
|
|
1937
|
use File::chdir; |
|
2
|
|
|
|
|
6715
|
|
|
2
|
|
|
|
|
277
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = version->new('0.6.9'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has [qw/_installed _base/] => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub name { |
25
|
55
|
|
|
55
|
1
|
90
|
my ($self) = @_; |
26
|
55
|
50
|
|
|
|
110
|
my $package = ref $self ? ref $self : $self; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
16
|
no strict qw/refs/; ## no critic |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
159
|
|
29
|
55
|
|
|
|
|
65
|
return ${"$package\::name"}; |
|
55
|
|
|
|
|
278
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub exe { |
33
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
34
|
0
|
0
|
|
|
|
|
my $package = ref $self ? ref $self : $self; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
|
13
|
no strict qw/refs/; ## no critic |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1220
|
|
37
|
0
|
|
|
|
|
|
return ${"$package\::exe"}; |
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub installed { |
41
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return die $self->name . ' does not currently implement installed!'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub used { |
47
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return die $self->name . ' does not currently implement used!'; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub uptodate { |
53
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return die $self->name . ' does not currently implement uptodate!'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub exec { |
59
|
0
|
|
|
0
|
1
|
|
my ($self, $dir, @args) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
die $self->name . " not installed\n" if !$self->installed(); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
local $CWD = $dir; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
if ($CWD ne $dir) { |
66
|
0
|
|
|
|
|
|
for my $arg (@args) { |
67
|
0
|
0
|
|
|
|
|
$arg = $CWD if $arg eq $dir; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $cmd = $self->exe; |
72
|
0
|
|
|
|
|
|
my $run = join ' ', $cmd, @args; |
73
|
0
|
0
|
|
|
|
|
return defined wantarray ? `$run` : CORE::exec($run); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub cat { |
77
|
0
|
|
|
0
|
1
|
|
my ($self, $file, $revision) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $exe = $self->exe; |
80
|
0
|
0
|
|
|
|
|
my $rev = $revision ? "-r$revision " : ''; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return `$exe cat $rev$file`; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub pull { |
86
|
0
|
|
|
0
|
1
|
|
die '"pull" not implemented for this Version Controll System!'; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub push { |
90
|
0
|
|
|
0
|
1
|
|
die '"push" not implemented for this Version Controll System!'; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub versions { |
94
|
0
|
|
|
0
|
1
|
|
my ($self, $file, $oldest, $newest, $max) = @_; |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
my %logs = %{ $self->log($file, $max ? "--limit $max" : '') }; |
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my @versions; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
for my $log (sort {$a <=> $b} keys %logs) { |
|
0
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
CORE::push @versions, $logs{$log}{rev};# if $oldest && $logs{$log}{rev} <= $oldest; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return @versions; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub add { |
107
|
0
|
|
|
0
|
1
|
|
my ($self, $file, $revision) = @_; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $exe = $self->exe; |
110
|
0
|
0
|
|
|
|
|
my $rev = $revision ? "-r$revision " : ''; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
return `$exe add $rev$file`; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |