line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVN::Dump::Record; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
41176
|
use strict; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
417
|
|
4
|
12
|
|
|
12
|
|
227
|
use warnings; |
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
467
|
|
5
|
|
|
|
|
|
|
|
6
|
12
|
|
|
12
|
|
569
|
use SVN::Dump::Headers; |
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
239
|
|
7
|
12
|
|
|
12
|
|
637
|
use SVN::Dump::Property; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
300
|
|
8
|
12
|
|
|
12
|
|
541
|
use SVN::Dump::Text; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
1223
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $NL = "\012"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
731
|
|
|
731
|
1
|
3060
|
my ($class, @args) = @_; |
14
|
731
|
|
|
|
|
3212
|
return bless {}, $class |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
for my $attr (qw( headers_block property_block text_block included_record )) { |
18
|
12
|
|
|
12
|
|
75
|
no strict 'refs'; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
15172
|
|
19
|
1243
|
|
|
1243
|
|
4458
|
*{"set_$attr"} = sub { $_[0]->{$attr} = $_[1]; }; |
20
|
5308
|
|
|
5308
|
|
28019
|
*{"get_$attr"} = sub { $_[0]->{$attr} }; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub type { |
24
|
1346
|
|
|
1346
|
1
|
3559
|
my ($self) = @_; |
25
|
1346
|
100
|
|
|
|
9224
|
return $self->{headers_block} ? $self->{headers_block}->type() : ''; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
847
|
|
|
847
|
1
|
3064
|
sub has_text { return defined $_[0]->get_text_block(); } |
29
|
847
|
|
|
847
|
1
|
2237
|
sub has_prop { return defined $_[0]->get_property_block(); } |
30
|
|
|
|
|
|
|
sub has_prop_only { |
31
|
2
|
|
66
|
2
|
1
|
6
|
return defined $_[0]->get_property_block() |
32
|
|
|
|
|
|
|
&& !defined $_[0]->get_text_block(); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
sub has_prop_or_text { |
35
|
446
|
|
100
|
446
|
1
|
948
|
return defined $_[0]->get_property_block() |
36
|
|
|
|
|
|
|
|| defined $_[0]->get_text_block(); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# length methods |
40
|
|
|
|
|
|
|
sub property_length { |
41
|
36
|
|
|
36
|
1
|
46
|
my ($self) = @_; |
42
|
36
|
|
|
|
|
65
|
my $prop = $self->get_property_block(); |
43
|
36
|
100
|
|
|
|
125
|
return defined $prop ? length( $prop->as_string() ) : 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub text_length { |
47
|
38
|
|
|
38
|
1
|
593
|
my ($self) = @_; |
48
|
38
|
|
|
|
|
71
|
my $text = $self->get_text(); |
49
|
38
|
100
|
|
|
|
127
|
return defined $text ? length($text) : 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub as_string { |
53
|
844
|
|
|
844
|
1
|
4871
|
my ($self) = @_; |
54
|
844
|
|
|
|
|
3761
|
my $headers_block = $self->get_headers_block(); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# the headers block |
57
|
844
|
|
|
|
|
2587
|
my $string = $headers_block->as_string(); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# the properties |
60
|
844
|
100
|
|
|
|
3166
|
$string .= $self->get_property_block()->as_string() |
61
|
|
|
|
|
|
|
if $self->has_prop(); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# the text |
64
|
844
|
100
|
|
|
|
6128
|
$string .= $self->get_text_block()->as_string() |
65
|
|
|
|
|
|
|
if $self->has_text(); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# is there an included record? |
68
|
844
|
100
|
|
|
|
2080
|
if( my $included = $self->get_included_record() ) { |
69
|
1
|
|
|
|
|
6
|
$string .= $included->as_string() . $NL; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# add a record separator if needed |
73
|
844
|
|
|
|
|
9763
|
my $type = $self->type(); |
74
|
844
|
100
|
|
|
|
3666
|
return $string if $type =~ /\A(?:format|uuid)\z/; |
75
|
|
|
|
|
|
|
|
76
|
750
|
100
|
|
|
|
1990
|
$string .= $type eq 'revision' ? $NL |
|
|
100
|
|
|
|
|
|
77
|
|
|
|
|
|
|
: $self->has_prop_or_text() ? $NL x 2 |
78
|
|
|
|
|
|
|
: $NL ; |
79
|
|
|
|
|
|
|
|
80
|
750
|
|
|
|
|
6632
|
return $string; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub update_headers { |
84
|
35
|
|
|
35
|
1
|
43
|
my ($self) = @_; |
85
|
35
|
|
|
|
|
81
|
my $proplen = $self->property_length(); |
86
|
35
|
|
|
|
|
107
|
my $textlen = $self->text_length(); |
87
|
|
|
|
|
|
|
|
88
|
35
|
100
|
|
|
|
80
|
$self->set_header( 'Text-content-length' => $textlen ) |
89
|
|
|
|
|
|
|
if defined $self->get_text_block(); |
90
|
35
|
100
|
|
|
|
129
|
$self->set_header( 'Prop-content-length', $proplen ) |
91
|
|
|
|
|
|
|
if $proplen; |
92
|
35
|
|
|
|
|
104
|
$self->set_header( 'Content-length' => $proplen + $textlen ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# access methods to the inner blocks |
96
|
|
|
|
|
|
|
sub set_header { |
97
|
109
|
|
|
109
|
1
|
235
|
my ($self, $h, $v) = @_; |
98
|
109
|
|
66
|
|
|
182
|
my $headers = $self->get_headers_block() |
99
|
|
|
|
|
|
|
|| $self->set_headers_block( SVN::Dump::Headers->new() ); |
100
|
109
|
|
|
|
|
325
|
$headers->set( $h, $v ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub get_header { |
104
|
176
|
|
|
176
|
1
|
1690
|
my ($self, $h) = @_; |
105
|
176
|
|
|
|
|
5251
|
return $self->get_headers_block()->get($h); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub set_property { |
109
|
6
|
|
|
6
|
1
|
15
|
my ( $self, $k, $v ) = @_; |
110
|
6
|
|
66
|
|
|
12
|
my $prop = $self->get_property_block() |
111
|
|
|
|
|
|
|
|| $self->set_property_block( SVN::Dump::Property->new() ); |
112
|
6
|
|
|
|
|
19
|
$prop->set( $k, $v ); |
113
|
6
|
|
|
|
|
13
|
$self->update_headers(); |
114
|
6
|
|
|
|
|
13
|
return $v; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub get_property { |
118
|
3
|
|
|
3
|
1
|
1380
|
my ($self, $k) = @_; |
119
|
3
|
|
|
|
|
8
|
return $self->get_property_block()->get($k); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub delete_property { |
123
|
3
|
|
|
3
|
1
|
982
|
my ( $self, @keys ) = @_; |
124
|
3
|
|
33
|
|
|
6
|
my $prop = $self->get_property_block() |
125
|
|
|
|
|
|
|
|| $self->set_property_block( SVN::Dump::Property->new() ); |
126
|
3
|
|
|
|
|
11
|
my @result = $prop->delete(@keys); |
127
|
3
|
|
|
|
|
8
|
$self->update_headers(); |
128
|
3
|
100
|
|
|
|
15
|
return wantarray ? @result : pop @result; # behave like delete() |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub set_text { |
132
|
26
|
|
|
26
|
1
|
110
|
my ($self, $t) = @_; |
133
|
26
|
|
66
|
|
|
60
|
my $text_block = $self->get_text_block() |
134
|
|
|
|
|
|
|
|| $self->set_text_block( SVN::Dump::Text->new() ); |
135
|
|
|
|
|
|
|
|
136
|
26
|
|
|
|
|
97
|
$text_block->set( $t ); |
137
|
26
|
|
|
|
|
67
|
$self->update_headers(); |
138
|
26
|
|
|
|
|
52
|
return $t; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub get_text { |
142
|
206
|
|
|
206
|
1
|
1198
|
my ($self) = @_; |
143
|
206
|
|
|
|
|
372
|
my $text_block = $self->get_text_block(); |
144
|
206
|
100
|
|
|
|
654
|
return defined $text_block ? $text_block->get() : undef; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__END__ |