/[scripts]/trunk/svndump-move.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/svndump-move.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (show annotations)
Fri Aug 3 18:13:55 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 2018 byte(s)
basic mapping path-to-path

1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use SVN::Dump;
5 use Shell qw/svnadmin cp find svn rm/;
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 die "please copy repository on which to perfrom operation to $from\n" if ( ! -e $from );
31
32 warn "collect all paths from repository $from\n";
33 create_list( $from, $fl );
34
35 if ( ! -e $tl ) {
36 cp( $fl, $tl );
37 die "created $tl\nplease edit it to reflect new layout\n";
38 }
39
40 my $map;
41
42 open(my $fhf, '<', $fl ) || die "can't open $fl: $!";
43 open(my $fht, '<', $tl ) || die "can't open $tl: $!";
44 while( my $lf = <$fhf> ) {
45 chomp($lf);
46 my $lt = <$fht> || die "list shorter, probably corrupt: $tl\n";
47 chomp($lt);
48 $map->{$lf} = $lt;
49 }
50
51 if ( -e $to ) {
52 #die "$to allready exists! remove it to re-create repository\n";
53 rm('-Rf',$to);
54 }
55
56 svnadmin('create', $to);
57 open(my $fh_in, '-|', "svnadmin dump $from") || die "can't dump $from: $!";
58 open(my $fh_out, '|-', "svnadmin load $to") || die "can't load $to: $!";
59
60 my $dump = SVN::Dump->new( { fh => $fh_in } );
61
62 warn "## $from -> $to\n";
63
64 while ( my $rec = $dump->next_record() ) {
65 my $type = $rec->type();
66 if ( $type eq 'revision' && $rec->get_header( 'Revision-number' ) != 0 ) {
67 my $to = 'dpavlin@rot13.org';
68 $rec->set_property( 'svn:author' => $to );
69 }
70
71 my $path = $rec->get_header('Node-path');
72 if ( $path && defined( $map->{$path} ) ) {
73 my $to = $map->{$path};
74 warn "##> $path -> $to\n";
75 $rec->set_header('Node-path', $to);
76 }
77
78 print $fh_out $rec->as_string();
79 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26