line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVN::Dump::Record; |
2
|
|
|
|
|
|
|
$SVN::Dump::Record::VERSION = '0.08'; |
3
|
11
|
|
|
11
|
|
59149
|
use strict; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
276
|
|
4
|
11
|
|
|
11
|
|
45
|
use warnings; |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
227
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
412
|
use SVN::Dump::Headers; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
247
|
|
7
|
11
|
|
|
11
|
|
396
|
use SVN::Dump::Property; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
176
|
|
8
|
11
|
|
|
11
|
|
383
|
use SVN::Dump::Text; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
866
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $NL = "\012"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
746
|
|
|
746
|
1
|
2297
|
my ($class, @args) = @_; |
14
|
746
|
|
|
|
|
1472
|
return bless {}, $class |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
for my $attr (qw( headers_block property_block text_block included_record )) { |
18
|
11
|
|
|
11
|
|
60
|
no strict 'refs'; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
9829
|
|
19
|
1268
|
|
|
1268
|
|
2394
|
*{"set_$attr"} = sub { $_[0]->{$attr} = $_[1]; }; |
20
|
5384
|
|
|
5384
|
|
10031
|
*{"get_$attr"} = sub { $_[0]->{$attr} }; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub type { |
24
|
1374
|
|
|
1374
|
1
|
2100
|
my ($self) = @_; |
25
|
1374
|
100
|
|
|
|
2941
|
return $self->{headers_block} ? $self->{headers_block}->type() : ''; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
861
|
|
|
861
|
1
|
1208
|
sub has_text { return defined $_[0]->get_text_block(); } |
29
|
861
|
|
|
861
|
1
|
1632
|
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
|
453
|
|
100
|
453
|
1
|
618
|
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
|
48
|
my ($self) = @_; |
42
|
36
|
|
|
|
|
54
|
my $prop = $self->get_property_block(); |
43
|
36
|
100
|
|
|
|
82
|
return defined $prop ? length( $prop->as_string() ) : 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub text_length { |
47
|
38
|
|
|
38
|
1
|
484
|
my ($self) = @_; |
48
|
38
|
|
|
|
|
60
|
my $text = $self->get_text(); |
49
|
38
|
100
|
|
|
|
76
|
return defined $text ? length($text) : 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub as_string { |
53
|
858
|
|
|
858
|
1
|
2329
|
my ($self) = @_; |
54
|
858
|
|
|
|
|
1134
|
my $headers_block = $self->get_headers_block(); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# the headers block |
57
|
858
|
|
|
|
|
1460
|
my $string = $headers_block->as_string(); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# the properties |
60
|
858
|
100
|
|
|
|
1362
|
$string .= $self->get_property_block()->as_string() |
61
|
|
|
|
|
|
|
if $self->has_prop(); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# the text |
64
|
858
|
100
|
|
|
|
1415
|
$string .= $self->get_text_block()->as_string() |
65
|
|
|
|
|
|
|
if $self->has_text(); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# is there an included record? |
68
|
858
|
100
|
|
|
|
1246
|
if( my $included = $self->get_included_record() ) { |
69
|
1
|
|
|
|
|
11
|
$string .= $included->as_string() . $NL; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# add a record separator if needed |
73
|
858
|
|
|
|
|
1146
|
my $type = $self->type(); |
74
|
858
|
100
|
|
|
|
2299
|
return $string if $type =~ /\A(?:format|uuid)\z/; |
75
|
|
|
|
|
|
|
|
76
|
762
|
100
|
|
|
|
1354
|
$string .= $type eq 'revision' ? $NL |
|
|
100
|
|
|
|
|
|
77
|
|
|
|
|
|
|
: $self->has_prop_or_text() ? $NL x 2 |
78
|
|
|
|
|
|
|
: $NL ; |
79
|
|
|
|
|
|
|
|
80
|
762
|
|
|
|
|
3261
|
return $string; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub update_headers { |
84
|
35
|
|
|
35
|
1
|
50
|
my ($self) = @_; |
85
|
35
|
|
|
|
|
51
|
my $proplen = $self->property_length(); |
86
|
35
|
|
|
|
|
58
|
my $textlen = $self->text_length(); |
87
|
|
|
|
|
|
|
|
88
|
35
|
100
|
|
|
|
58
|
$self->set_header( 'Text-content-length' => $textlen ) |
89
|
|
|
|
|
|
|
if defined $self->get_text_block(); |
90
|
35
|
100
|
|
|
|
89
|
$self->set_header( 'Prop-content-length', $proplen ) |
91
|
|
|
|
|
|
|
if $proplen; |
92
|
35
|
|
|
|
|
63
|
$self->set_header( 'Content-length' => $proplen + $textlen ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# access methods to the inner blocks |
96
|
|
|
|
|
|
|
sub set_header { |
97
|
109
|
|
|
109
|
1
|
166
|
my ($self, $h, $v) = @_; |
98
|
109
|
|
66
|
|
|
153
|
my $headers = $self->get_headers_block() |
99
|
|
|
|
|
|
|
|| $self->set_headers_block( SVN::Dump::Headers->new() ); |
100
|
109
|
|
|
|
|
199
|
$headers->set( $h, $v ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub get_header { |
104
|
176
|
|
|
176
|
1
|
1400
|
my ($self, $h) = @_; |
105
|
176
|
|
|
|
|
239
|
return $self->get_headers_block()->get($h); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub set_property { |
109
|
6
|
|
|
6
|
1
|
13
|
my ( $self, $k, $v ) = @_; |
110
|
6
|
|
66
|
|
|
9
|
my $prop = $self->get_property_block() |
111
|
|
|
|
|
|
|
|| $self->set_property_block( SVN::Dump::Property->new() ); |
112
|
6
|
|
|
|
|
16
|
$prop->set( $k, $v ); |
113
|
6
|
|
|
|
|
10
|
$self->update_headers(); |
114
|
6
|
|
|
|
|
11
|
return $v; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub get_property { |
118
|
3
|
|
|
3
|
1
|
1248
|
my ($self, $k) = @_; |
119
|
3
|
|
|
|
|
6
|
return $self->get_property_block()->get($k); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub delete_property { |
123
|
3
|
|
|
3
|
1
|
920
|
my ( $self, @keys ) = @_; |
124
|
3
|
|
33
|
|
|
7
|
my $prop = $self->get_property_block() |
125
|
|
|
|
|
|
|
|| $self->set_property_block( SVN::Dump::Property->new() ); |
126
|
3
|
|
|
|
|
10
|
my @result = $prop->delete(@keys); |
127
|
3
|
|
|
|
|
7
|
$self->update_headers(); |
128
|
3
|
100
|
|
|
|
12
|
return wantarray ? @result : pop @result; # behave like delete() |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub set_text { |
132
|
26
|
|
|
26
|
1
|
73
|
my ($self, $t) = @_; |
133
|
26
|
|
66
|
|
|
41
|
my $text_block = $self->get_text_block() |
134
|
|
|
|
|
|
|
|| $self->set_text_block( SVN::Dump::Text->new() ); |
135
|
|
|
|
|
|
|
|
136
|
26
|
|
|
|
|
63
|
$text_block->set( $t ); |
137
|
26
|
|
|
|
|
50
|
$self->update_headers(); |
138
|
26
|
|
|
|
|
39
|
return $t; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub get_text { |
142
|
206
|
|
|
206
|
1
|
939
|
my ($self) = @_; |
143
|
206
|
|
|
|
|
268
|
my $text_block = $self->get_text_block(); |
144
|
206
|
100
|
|
|
|
407
|
return defined $text_block ? $text_block->get() : undef; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__END__ |