--- trunk/svndump-move.pl 2007/08/03 17:52:21 47 +++ trunk/svndump-move.pl 2007/08/03 18:13:55 49 @@ -2,7 +2,7 @@ use strict; use warnings; use SVN::Dump; -use Shell qw/svnadmin cp find svn/; +use Shell qw/svnadmin cp find svn rm/; use Cwd qw/abs_path/; my $base = shift @ARGV; @@ -27,7 +27,6 @@ warn "created: $path ", -s $path, "bytes\n"; } - die "please copy repository on which to perfrom operation to $from\n" if ( ! -e $from ); warn "collect all paths from repository $from\n"; @@ -36,25 +35,45 @@ if ( ! -e $tl ) { cp( $fl, $tl ); die "created $tl\nplease edit it to reflect new layout\n"; -} elsif ( ! -e $to ) { - svnadmin('create', $to); - open(my $fh_in, '-|', "svnadmin dump $from") || die "can't dump $from: $!"; - open(my $fh_out, '|-', "svnadmin load $to") || die "can't load $to: $!"; - - my $dump = SVN::Dump->new( { fh => $fh_in } ); - - warn "## $from -> $to\n"; - - while ( my $rec = $dump->next_record() ) { - my $type = $rec->type(); - if ( $type eq 'revision' && $rec->get_header( 'Revision-number' ) != 0 ) { - my $to = 'dpavlin@rot13.org'; - $rec->set_property( 'svn:author' => $to ); - } - warn "##> ", $rec->get_header('Node-path'), "\n"; +} + +my $map; - print $fh_out $rec->as_string(); +open(my $fhf, '<', $fl ) || die "can't open $fl: $!"; +open(my $fht, '<', $tl ) || die "can't open $tl: $!"; +while( my $lf = <$fhf> ) { + chomp($lf); + my $lt = <$fht> || die "list shorter, probably corrupt: $tl\n"; + chomp($lt); + $map->{$lf} = $lt; +} + +if ( -e $to ) { + #die "$to allready exists! remove it to re-create repository\n"; + rm('-Rf',$to); +} + +svnadmin('create', $to); +open(my $fh_in, '-|', "svnadmin dump $from") || die "can't dump $from: $!"; +open(my $fh_out, '|-', "svnadmin load $to") || die "can't load $to: $!"; + +my $dump = SVN::Dump->new( { fh => $fh_in } ); + +warn "## $from -> $to\n"; + +while ( my $rec = $dump->next_record() ) { + my $type = $rec->type(); + if ( $type eq 'revision' && $rec->get_header( 'Revision-number' ) != 0 ) { + my $to = 'dpavlin@rot13.org'; + $rec->set_property( 'svn:author' => $to ); + } + + my $path = $rec->get_header('Node-path'); + if ( $path && defined( $map->{$path} ) ) { + my $to = $map->{$path}; + warn "##> $path -> $to\n"; + $rec->set_header('Node-path', $to); } -} else { - die "$to allready exists! remove it to re-create repository\n"; + + print $fh_out $rec->as_string(); }