| 1 | package SVN::Dump; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use SVN::Dump::Reader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub new { | ||||||||||||||||||||||||||||
| 12 | 32 | ▶ | my ( $class, $args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 32 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # FIXME - croak() if incompatible options | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # we have a reader | ||||||||||||||||||||||||||||
| 18 | 32 | ▶ | if ( exists $args->{fh} || exists $args->{file} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $args->{"fh"} or exists $args->{"file"}
MC/DC100%2/2
exists $args->{"fh"} or exists $args->{"file"}
exists $args->{"fh"}
exists $args->{"file"}
Truth table100%3/3
A or B
A= exists $args->{"fh"}B= exists $args->{"file"}
| |||||||||||||||||||||||||||||
| 19 | 29 | my ( $fh, $file ) = delete @{$args}{qw( fh file )}; | |||||||||||||||||||||||||||
| 20 | 29 | ▶ | if ( !$fh ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 25 | ▶ | open $fh, $file or croak "Can't open $file: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 28 | $self->{reader} = SVN::Dump::Reader->new( $fh, $args ); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | # we don't have a reader | ||||||||||||||||||||||||||||
| 26 | else { | ||||||||||||||||||||||||||||
| 27 | 3 | ▶ | if( exists $args->{version} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 2 | $self->{format} = SVN::Dump::Record->new(); | |||||||||||||||||||||||||||
| 29 | $self->{format}->set_header( | ||||||||||||||||||||||||||||
| 30 | 2 | 'SVN-fs-dump-format-version' => $args->{version} ); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 3 | ▶ | if( exists $args->{uuid} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 2 | $self->{uuid} = SVN::Dump::Record->new(); | |||||||||||||||||||||||||||
| 34 | 2 | $self->{uuid}->set_header( 'UUID' => $args->{uuid} ); | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 31 | return $self; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub next_record { | ||||||||||||||||||||||||||||
| 42 | 527 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
next_record: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 527 | my $record; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | RECORD: { | ||||||||||||||||||||||||||||
| 46 | 527 | $record = $self->{reader}->read_record(); | |||||||||||||||||||||||||||
| 47 | 527 | ▶ | return unless $record; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # keep the first records in the dump itself | ||||||||||||||||||||||||||||
| 50 | 500 | my $type = $record->type(); | |||||||||||||||||||||||||||
| 51 | 500 | ▶ | if ( $type =~ /\A(?:format|uuid)\z/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 56 | $self->{$type} = $record; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 500 | return $record; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub version { | ||||||||||||||||||||||||||||
| 60 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
version: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | return $self->{format} | ||||||||||||||||||||||||||||
| 62 | 4 | ▶ | ? $self->{format}->get_header('SVN-fs-dump-format-version') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | : ''; | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 5 | *format = \&version; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | sub uuid { | ||||||||||||||||||||||||||||
| 68 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
uuid: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 4 | ▶ | return $self->{uuid} ? $self->{uuid}->get_header('UUID') : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub as_string { | ||||||||||||||||||||||||||||
| 73 | 1 | ▶ | return join '', map { $_[0]->{$_}->as_string() } qw( format uuid ); | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 5 | 1; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||