line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VCS::Which::Plugin::CVS; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2009-05-16 16:58:14 |
4
|
|
|
|
|
|
|
# Create by: ivan |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1213
|
use Moo; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
13
|
|
10
|
2
|
|
|
2
|
|
624
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
38
|
|
11
|
2
|
|
|
2
|
|
19
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
68
|
|
12
|
2
|
|
|
2
|
|
12
|
use version; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
13
|
2
|
|
|
2
|
|
156
|
use Carp; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
120
|
|
14
|
2
|
|
|
2
|
|
12
|
use Data::Dumper qw/Dumper/; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
103
|
|
15
|
2
|
|
|
2
|
|
14
|
use English qw/ -no_match_vars /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
16
|
2
|
|
|
2
|
|
750
|
use Path::Tiny; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
116
|
|
17
|
2
|
|
|
2
|
|
15
|
use File::chdir; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
186
|
|
18
|
2
|
|
|
2
|
|
14
|
use Contextual::Return; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
extends 'VCS::Which::Plugin'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = version->new('0.6.9'); |
23
|
|
|
|
|
|
|
our $name = 'CVS'; |
24
|
|
|
|
|
|
|
our $exe = 'cvs'; |
25
|
|
|
|
|
|
|
our $meta = 'CVS'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub installed { |
28
|
6
|
|
|
6
|
1
|
10
|
my ($self) = @_; |
29
|
|
|
|
|
|
|
|
30
|
6
|
100
|
|
|
|
25
|
return $self->_installed if defined $self->_installed; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
8
|
for my $path (split /[:;]/, $ENV{PATH}) { |
33
|
9
|
50
|
|
|
|
149
|
next if !-x "$path/$exe"; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
return $self->_installed( 1 ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
11
|
return $self->_installed( 0 ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub used { |
42
|
21
|
|
|
21
|
1
|
43
|
my ( $self, $dir ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
21
|
50
|
|
|
|
538
|
if (-f $dir) { |
45
|
0
|
|
|
|
|
0
|
$dir = path($dir)->parent; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
21
|
100
|
|
|
|
300
|
croak "$dir is not a directory!" if !-d $dir; |
49
|
|
|
|
|
|
|
|
50
|
20
|
|
|
|
|
290
|
return -d "$dir/$meta"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub uptodate { |
54
|
0
|
|
|
0
|
1
|
|
my ( $self, $dir ) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
0
|
|
|
|
$dir ||= $self->_base; |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
croak "'$dir' is not a directory!" if !-e $dir; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
chdir $dir; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return !grep {!/Up-to-date/} grep { /Status:/ } `$exe status 2>/dev/null`; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub pull { |
66
|
0
|
|
|
0
|
1
|
|
my ( $self, $dir ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
0
|
|
|
|
$dir ||= $self->_base; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
croak "'$dir' is not a directory!" if !-e $dir; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
local $CWD = $dir; |
73
|
0
|
|
|
|
|
|
return !system "$exe update > /dev/null 2> /dev/null"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub cat { |
77
|
0
|
|
|
0
|
1
|
|
my ($self, $file, $revision) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
0
|
|
|
|
if ( $revision && $revision =~ /^-\d+$/xms ) { |
|
|
0
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my @versions = reverse `$exe log -q $file` =~ /^ revision \s+ (\d+[.]\d+)/gxms; |
81
|
0
|
|
|
|
|
|
$revision = $versions[$revision]; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
elsif ( !defined $revision ) { |
84
|
0
|
|
|
|
|
|
$revision = ''; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
0
|
|
|
|
$revision &&= "-r $revision"; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return `$exe update -p $revision $file`; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub log { |
93
|
0
|
|
|
0
|
1
|
|
my ($self, $file, @args) = @_; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my $args = join ' ', @args; |
96
|
0
|
0
|
|
|
|
|
my $dir = -d $file ? path($file) : path($file)->parent; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
local $CWD = $dir; |
99
|
|
|
|
|
|
|
return |
100
|
0
|
|
|
0
|
|
|
SCALAR { scalar `$exe log $args` } |
101
|
|
|
|
|
|
|
ARRAYREF { |
102
|
0
|
|
|
0
|
|
|
my $logs = `$exe $args log 2> /dev/null`; |
103
|
0
|
|
|
|
|
|
my @logs; |
104
|
0
|
|
|
|
|
|
for my $file ( split /^={77}$/xms, $logs ) { |
105
|
0
|
|
|
|
|
|
my ($details, @log) = split /^-{28}$/xms, $file; |
106
|
0
|
|
|
|
|
|
push @logs, @log; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return \@logs; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
HASHREF { |
112
|
0
|
|
|
0
|
|
|
my $logs = `$exe $args log 2> /dev/null`; |
113
|
0
|
|
|
|
|
|
my %log_by_date; |
114
|
0
|
|
|
|
|
|
for my $file ( split /^={77}$/xms, $logs ) { |
115
|
0
|
|
|
|
|
|
my ($details, @log) = split /^-{28}$/xms, $file; |
116
|
0
|
|
|
|
|
|
for my $log (@log) { |
117
|
0
|
|
|
|
|
|
my (undef, $rev_line, $data_line, $description) = split /\r?\n/xms, $log, 4; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
chomp $description; |
120
|
0
|
|
|
|
|
|
my ($rev) = $rev_line =~ /^revision \s+ ([\d.]+)$/xms; |
121
|
0
|
|
|
|
|
|
my ($date, $author) = $data_line =~ /^date: \s* ([^;]+); \s* author: \s* ([^;]+)/xms; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
push @{ $log_by_date{$date} }, { |
|
0
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
rev => $rev, |
125
|
|
|
|
|
|
|
description => $description, |
126
|
|
|
|
|
|
|
Date => $date, |
127
|
|
|
|
|
|
|
Author => $author, |
128
|
|
|
|
|
|
|
}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my %log; |
133
|
0
|
|
|
|
|
|
my $i = 1; |
134
|
0
|
|
|
|
|
|
for my $date ( sort keys %log_by_date ) { |
135
|
0
|
|
|
|
|
|
$log{$i++} = $log_by_date{$date}[0]; |
136
|
|
|
|
|
|
|
} |
137
|
0
|
|
|
|
|
|
return \%log; |
138
|
|
|
|
|
|
|
} |
139
|
0
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
__END__ |