Skip Menu |
 

This queue is for tickets about the SVN-Dump CPAN distribution.

Report information
The Basics
Id: 56276
Status: resolved
Priority: 0/
Queue: SVN-Dump

People
Owner: Nobody in particular
Requestors: RCAPUTO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.04
Fixed in: 0.05



Subject: patches vs. 0.04
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1270361418-26542-162"
Content-Length: 0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 189
Download (untitled) / with headers
text/plain 189b
Attached are patches that help when content lengths are specified, but they are 0. As of 0.04, they cause as_string() to generate blocks that SVN::Dump isn't able to successfully re-parse.
Subject: for-book.txt
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"; name="for-book.txt"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="for-book.txt"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: ascii
Content-Length: 8071
Download for-book.txt
text/plain 7.8k
commit 67d3b78550e36582b50b7b419c9dae531d1ee24a Author: Rocco Caputo <rcaputo@cpan.org> Date: Sun Apr 4 01:59:13 2010 -0400 Be lenient about blank lines before headers. diff --git a/lib/SVN/Dump/Reader.pm b/lib/SVN/Dump/Reader.pm index bba02c8..d5a676d 100644 --- a/lib/SVN/Dump/Reader.pm +++ b/lib/SVN/Dump/Reader.pm @@ -35,6 +35,7 @@ sub read_record { # first get the headers my $headers = $fh->read_header_block(); + return unless $headers; $record->set_headers_block( $headers ); # get the property block @@ -83,13 +84,28 @@ sub read_record { sub read_header_block { my ($fh) = @_; + my $in_headers = 0; + local $/ = $NL; my $headers = SVN::Dump::Headers->new(); while(1) { my $line = <$fh>; - confess _eof() if !defined $line; + + # EOF is unexpected if we're in headers. Fine if we're not. + unless (defined $line) { + confess _eof() if $in_headers; + last; + } + chop $line; - last if $line eq ''; # stop on empty line + + # Empty line ends headers. Discarded if before headers. + if ($line eq '') { + next unless $in_headers; + last; + } + + $in_headers = 1; my ($key, $value) = split /: /, $line, 2; $headers->{$key} = $value; diff --git a/t/dump/fail/h_empty.svn b/t/dump/fail/h_empty.svn index 917557c..85529c7 100644 --- a/t/dump/fail/h_empty.svn +++ b/t/dump/fail/h_empty.svn @@ -1,2 +1,2 @@ read_header_block -^Unexpected EOF line \d+ +^Empty line found instead of a header block line \d+ commit 5487c4b4ed40a2757771c8a5a51616e01cb7f7f5 Author: Rocco Caputo <rcaputo@cpan.org> Date: Sun Apr 4 01:57:54 2010 -0400 Don't create text or property blocks if they don't exist in a dump. diff --git a/lib/SVN/Dump/Reader.pm b/lib/SVN/Dump/Reader.pm index f631b34..bba02c8 100644 --- a/lib/SVN/Dump/Reader.pm +++ b/lib/SVN/Dump/Reader.pm @@ -39,12 +39,18 @@ sub read_record { # get the property block $record->set_property_block( $fh->read_property_block() ) - if exists $headers->{'Prop-content-length'}; + if ( + exists $headers->{'Prop-content-length'} and + $headers->{'Prop-content-length'} + ); # get the text block $record->set_text_block( $fh->read_text_block( $headers->{'Text-content-length'} ) ) - if exists $headers->{'Text-content-length'}; + if ( + exists $headers->{'Text-content-length'} and + $headers->{'Text-content-length'} + ); # some safety checks confess "Inconsistent record size" commit 98dacab052a4dca52679dc92a2c25a29a317592d Author: Rocco Caputo <rcaputo@cpan.org> Date: Sat Apr 3 23:00:23 2010 -0400 Add vim directives so I don't mess up style. Confess rather than croak. diff --git a/lib/SVN/Dump.pm b/lib/SVN/Dump.pm index c8ace9d..dd50f02 100644 --- a/lib/SVN/Dump.pm +++ b/lib/SVN/Dump.pm @@ -1,8 +1,9 @@ package SVN::Dump; +# vim: ts=4 sw=4 expandtab use strict; use warnings; -use Carp; +use Carp qw(croak); use SVN::Dump::Reader; diff --git a/lib/SVN/Dump/Headers.pm b/lib/SVN/Dump/Headers.pm index c45745d..bc0832c 100644 --- a/lib/SVN/Dump/Headers.pm +++ b/lib/SVN/Dump/Headers.pm @@ -1,8 +1,9 @@ package SVN::Dump::Headers; +# vim: ts=4 sw=4 expandtab use strict; use warnings; -use Carp; +use Carp qw(croak confess); use Scalar::Util qw( reftype ); my $NL = "\012"; @@ -68,7 +69,7 @@ sub type { : exists $self->{'Revision-number'} ? 'revision' : exists $self->{'UUID'} ? 'uuid' : exists $self->{'SVN-fs-dump-format-version'} ? 'format' - : croak 'Unable to determine the record type'; + : confess 'Unable to determine the record type'; return $type; } diff --git a/lib/SVN/Dump/Property.pm b/lib/SVN/Dump/Property.pm index 54b2460..0bd3d94 100644 --- a/lib/SVN/Dump/Property.pm +++ b/lib/SVN/Dump/Property.pm @@ -1,4 +1,5 @@ package SVN::Dump::Property; +# vim: ts=4 sw=4 expandtab use strict; use warnings; diff --git a/lib/SVN/Dump/Reader.pm b/lib/SVN/Dump/Reader.pm index 052437f..f631b34 100644 --- a/lib/SVN/Dump/Reader.pm +++ b/lib/SVN/Dump/Reader.pm @@ -1,9 +1,10 @@ package SVN::Dump::Reader; +# vim: ts=4 sw=4 expandtab use strict; use warnings; use IO::Handle; -use Carp; +use Carp qw(croak confess); our @ISA = qw( IO::Handle ); @@ -46,7 +47,7 @@ sub read_record { if exists $headers->{'Text-content-length'}; # some safety checks - croak "Inconsistent record size" + confess "Inconsistent record size" if ( $headers->{'Prop-content-length'} || 0 ) + ( $headers->{'Text-content-length'} || 0 ) != ( $headers->{'Content-length'} || 0 ); @@ -80,7 +81,7 @@ sub read_header_block { my $headers = SVN::Dump::Headers->new(); while(1) { my $line = <$fh>; - croak _eof() if !defined $line; + confess _eof() if !defined $line; chop $line; last if $line eq ''; # stop on empty line @@ -88,7 +89,7 @@ sub read_header_block { $headers->{$key} = $value; } - croak "Empty line found instead of a header block line $." + confess "Empty line found instead of a header block line $." if ! keys %$headers; return $headers; @@ -102,7 +103,7 @@ sub read_property_block { my @buffer; while(1) { my $line = <$fh>; - croak _eof() if !defined $line; + confess _eof() if !defined $line; chop $line; # read a key/value pair @@ -112,7 +113,7 @@ sub read_property_block { chop $key; # remove the last $NL $line = <$fh>; - croak _eof() if !defined $line; + confess _eof() if !defined $line; chop $line; if( $line =~ /\AV (\d+)\z/ ) { @@ -125,7 +126,7 @@ sub read_property_block { # FIXME what happens if we see duplicate keys? } else { - croak "Corrupted property"; # FIXME better error message + confess "Corrupted property"; # FIXME better error message } } # or a deleted key (only with fs-format-version >= 3) @@ -143,7 +144,7 @@ sub read_property_block { } # inconsistent data else { - croak "Corrupted property"; # FIXME better error message + confess "Corrupted property"; # FIXME better error message } } @@ -158,7 +159,7 @@ sub read_text_block { my $text = ''; while( length($text) <= $size ) { my $line = <$fh>; - croak _eof() if ! defined $line; + confess _eof() if ! defined $line; $text .= $line; } diff --git a/lib/SVN/Dump/Record.pm b/lib/SVN/Dump/Record.pm index e8a2905..ecaf8ce 100644 --- a/lib/SVN/Dump/Record.pm +++ b/lib/SVN/Dump/Record.pm @@ -1,4 +1,5 @@ package SVN::Dump::Record; +# vim: ts=4 sw=4 expandtab use strict; use warnings; diff --git a/lib/SVN/Dump/Text.pm b/lib/SVN/Dump/Text.pm index 030f1b1..c6d2435 100644 --- a/lib/SVN/Dump/Text.pm +++ b/lib/SVN/Dump/Text.pm @@ -1,4 +1,5 @@ package SVN::Dump::Text; +# vim: ts=4 sw=4 expandtab use strict; use warnings; commit cd4a14a1575f7f131609ea4aad55c9ae9e4ddfd6 Author: Rocco Caputo <rcaputo@cpan.org> Date: Sat Apr 3 22:21:11 2010 -0400 Subversion dump format docs have moved. diff --git a/README b/README index d93231c..d7bd2ea 100644 --- a/README +++ b/README @@ -4,9 +4,8 @@ SVN::Dump This module lets you manage SVN dumps with Perl. The reference document for Subversion dumpfiles is at: -http://svn.collab.net/viewvc/svn/trunk/notes/fs_dumprestore.txt?revision=HEAD +http://svn.apache.org/repos/asf/subversion/trunk/notes/dump-load-format.txt PLEASE NOTE THAT THIS CODE IS OF IN ALPHA QUALITY. I DO NOT MASTER YET ALL THE CONCEPTS BEHIND THE SUBVERSION FILESYSTEM, BUT WILL EVENTUALLY LEARN. THE INTERFACE IS SUBJECT TO CHANGE IN THE FUTURE. -
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-7681-1298125648-408.56276-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 498
Download (untitled) / with headers
text/plain 498b
On Sun Apr 04 02:10:18 2010, RCAPUTO wrote: Show quoted text
> Attached are patches that help when content lengths are specified, but > they are 0. As of 0.04, they cause as_string() to generate blocks that > SVN::Dump isn't able to successfully re-parse.
I think those patches are the ones in your github clone (later cloned by avar), which I have either cherry-picked or reproduced in some way. I'll mark it resolved, but please check if the recently published version 0.05 does work for you. Thanks. -- BooK


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.