1 |
dpavlin |
47 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use warnings; |
4 |
|
|
use SVN::Dump; |
5 |
|
|
use Shell qw/svnadmin cp find svn/; |
6 |
|
|
use Cwd qw/abs_path/; |
7 |
|
|
|
8 |
|
|
my $base = shift @ARGV; |
9 |
|
|
$base ||= 'svn/'; |
10 |
|
|
|
11 |
|
|
die "usage: $0 temp-base-directory (default: $base)\n" unless ( -e $base ); |
12 |
|
|
|
13 |
|
|
my $mode = 'move'; |
14 |
|
|
my ( $from, $to ) = ( "$base/from", "$base/to/" ); |
15 |
|
|
my ( $fl, $tl ) = ( "$base/from.lst", "$base/to.lst" ); |
16 |
|
|
|
17 |
|
|
sub create_list { |
18 |
|
|
my ( $dir, $path ) = @_; |
19 |
|
|
my $list = svn('ls', '-R', 'file://' . abs_path($from)); |
20 |
|
|
open(my $fh, '>', $path) || die "can't create $path: $!"; |
21 |
|
|
print $fh $list; |
22 |
|
|
close($fh); |
23 |
|
|
if ( ! -s $path ) { |
24 |
|
|
unlink($path); |
25 |
|
|
die "ABORT: created zero size $path\n"; |
26 |
|
|
} |
27 |
|
|
warn "created: $path ", -s $path, "bytes\n"; |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
die "please copy repository on which to perfrom operation to $from\n" if ( ! -e $from ); |
32 |
|
|
|
33 |
|
|
warn "collect all paths from repository $from\n"; |
34 |
|
|
create_list( $from, $fl ); |
35 |
|
|
|
36 |
|
|
if ( ! -e $tl ) { |
37 |
|
|
cp( $fl, $tl ); |
38 |
|
|
die "created $tl\nplease edit it to reflect new layout\n"; |
39 |
|
|
} elsif ( ! -e $to ) { |
40 |
|
|
svnadmin('create', $to); |
41 |
|
|
open(my $fh_in, '-|', "svnadmin dump $from") || die "can't dump $from: $!"; |
42 |
|
|
open(my $fh_out, '|-', "svnadmin load $to") || die "can't load $to: $!"; |
43 |
|
|
|
44 |
|
|
my $dump = SVN::Dump->new( { fh => $fh_in } ); |
45 |
|
|
|
46 |
|
|
warn "## $from -> $to\n"; |
47 |
|
|
|
48 |
|
|
while ( my $rec = $dump->next_record() ) { |
49 |
|
|
my $type = $rec->type(); |
50 |
|
|
if ( $type eq 'revision' && $rec->get_header( 'Revision-number' ) != 0 ) { |
51 |
|
|
my $to = 'dpavlin@rot13.org'; |
52 |
|
|
$rec->set_property( 'svn:author' => $to ); |
53 |
|
|
} |
54 |
|
|
warn "##> ", $rec->get_header('Node-path'), "\n"; |
55 |
|
|
|
56 |
|
|
print $fh_out $rec->as_string(); |
57 |
|
|
} |
58 |
|
|
} else { |
59 |
|
|
die "$to allready exists! remove it to re-create repository\n"; |
60 |
|
|
} |