line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# PANT::Svn - Provide support for Svn operations
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package PANT::Svn;
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1378
|
use 5.008;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
7
|
1
|
|
|
1
|
|
59
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
9
|
1
|
|
|
1
|
|
5
|
use Cwd;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
57
|
|
10
|
1
|
|
|
1
|
|
6
|
use XML::Writer;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
11
|
1
|
|
|
1
|
|
5
|
use Exporter;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
771
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export
|
16
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead.
|
17
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants.
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# This allows declaration use PANT ':all';
|
20
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
|
21
|
|
|
|
|
|
|
# will save memory.
|
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @EXPORT = qw( );
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.02';
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new {
|
32
|
1
|
|
|
1
|
1
|
5
|
my($clsname, $writer, @rest) =@_;
|
33
|
1
|
|
|
|
|
4
|
my $self = {
|
34
|
|
|
|
|
|
|
writer=>$writer,
|
35
|
|
|
|
|
|
|
@rest,
|
36
|
|
|
|
|
|
|
};
|
37
|
1
|
|
|
|
|
4
|
bless $self, $clsname;
|
38
|
1
|
|
|
|
|
5
|
return $self;
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub Run {
|
42
|
3
|
|
|
3
|
1
|
385
|
my($self, $cmd, %args) = @_;
|
43
|
3
|
|
|
|
|
9
|
my $writer = $self->{writer};
|
44
|
3
|
|
|
|
|
6
|
my $cdir = ".";
|
45
|
3
|
50
|
|
|
|
65
|
if ($args{directory}) {
|
46
|
0
|
|
|
|
|
0
|
$cdir = getcwd;
|
47
|
0
|
0
|
|
|
|
0
|
chdir($args{directory}) || Abort("Can't change to directory $args{directory}");
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
}
|
50
|
3
|
|
|
|
|
368
|
$writer->startTag('li');
|
51
|
3
|
|
|
|
|
170
|
$writer->characters("Run $cmd\n");
|
52
|
3
|
|
|
|
|
61
|
my $output;
|
53
|
|
|
|
|
|
|
my $retval;
|
54
|
3
|
50
|
|
|
|
11
|
if ($self->{dryrun}) {
|
55
|
0
|
|
|
|
|
0
|
$output = "Output of the command $cmd would be here";
|
56
|
0
|
|
|
|
|
0
|
$retval = 1;
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
else {
|
59
|
3
|
|
|
|
|
8
|
$writer->startTag('pre');
|
60
|
3
|
|
|
|
|
143
|
$cmd .= " 2>&1"; # collect stderr too
|
61
|
3
|
|
|
|
|
8
|
$self->{lines} = [];
|
62
|
3
|
50
|
|
|
|
15554
|
if (open(PIPE, "$cmd |")) {
|
63
|
3
|
|
|
|
|
15580
|
while(my $line = ) {
|
64
|
10
|
|
|
|
|
134
|
$writer->characters($line);
|
65
|
10
|
|
|
|
|
437
|
push(@ {$self->{lines} }, $line);
|
|
10
|
|
|
|
|
723
|
|
66
|
|
|
|
|
|
|
}
|
67
|
3
|
|
|
|
|
2080
|
close(PIPE);
|
68
|
3
|
|
|
|
|
47
|
$retval = $? == 0;
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
else {
|
71
|
0
|
|
|
|
|
0
|
$retval = 0;
|
72
|
|
|
|
|
|
|
}
|
73
|
3
|
|
|
|
|
35
|
$writer->endTag('pre');
|
74
|
|
|
|
|
|
|
}
|
75
|
3
|
50
|
|
|
|
1265
|
$writer->characters("$cmd failed: $!") if ($retval == 0);
|
76
|
3
|
|
|
|
|
15
|
$writer->endTag('li');
|
77
|
3
|
0
|
|
|
|
11417
|
do { chdir($cdir) || Abort("Can't change back to $cdir: $!"); } if ($args{directory});
|
|
0
|
50
|
|
|
|
0
|
|
78
|
3
|
|
|
|
|
131
|
return $retval;
|
79
|
|
|
|
|
|
|
}
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub HasUpdate {
|
82
|
3
|
|
|
3
|
1
|
10
|
my $self = shift;
|
83
|
3
|
|
|
|
|
7
|
foreach my $line (@{ $self->{lines} }) {
|
|
3
|
|
|
|
|
11
|
|
84
|
|
|
|
|
|
|
#A Added
|
85
|
|
|
|
|
|
|
#D Deleted
|
86
|
|
|
|
|
|
|
#U Updated
|
87
|
|
|
|
|
|
|
#C Conflict
|
88
|
|
|
|
|
|
|
#G Merged
|
89
|
|
|
|
|
|
|
#Restored
|
90
|
3
|
50
|
|
|
|
28
|
next if ($line =~ /^At /);
|
91
|
|
|
|
|
|
|
# treat these two as updates
|
92
|
3
|
50
|
|
|
|
12
|
return 1 if ($line =~ /^Updated to /);
|
93
|
3
|
50
|
|
|
|
10
|
return 1 if ($line =~ /^Restored /);
|
94
|
3
|
100
|
|
|
|
37
|
if ($line =~ /^[ADUM][A-Z]?\s+/) { # Its a change, one out, all out.
|
95
|
2
|
|
|
|
|
16
|
return 1;
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
}
|
98
|
1
|
|
|
|
|
17
|
return 0;
|
99
|
|
|
|
|
|
|
}
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub HasLocalMod {
|
102
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
103
|
0
|
|
|
|
|
0
|
foreach my $line (@{ $self->{lines} }) {
|
|
0
|
|
|
|
|
0
|
|
104
|
|
|
|
|
|
|
# not sure what to look for.
|
105
|
|
|
|
|
|
|
}
|
106
|
0
|
|
|
|
|
0
|
return 0;
|
107
|
|
|
|
|
|
|
}
|
108
|
|
|
|
|
|
|
sub HasConflict {
|
109
|
3
|
|
|
3
|
1
|
6
|
my $self = shift;
|
110
|
3
|
|
|
|
|
6
|
foreach my $line (@{ $self->{lines} }) {
|
|
3
|
|
|
|
|
21
|
|
111
|
10
|
100
|
|
|
|
36
|
if ($line =~ /^[C][A-Z]?\s+/) { # Its a conflict
|
112
|
1
|
|
|
|
|
7
|
return 1;
|
113
|
|
|
|
|
|
|
}
|
114
|
|
|
|
|
|
|
}
|
115
|
2
|
|
|
|
|
17
|
return 0;
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1;
|
119
|
|
|
|
|
|
|
__END__
|