/[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 48 - (show annotations)
Fri Aug 3 17:57:25 2007 UTC (15 years, 4 months ago) by dpavlin
File MIME type: text/plain
File size: 1650 byte(s)
simplify and configure to allow re-runs (comment out die line if you don't want that behaviour)

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
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 }
40
41 if ( -e $to ) {
42 #die "$to allready exists! remove it to re-create repository\n";
43 rm('-Rf',$to);
44 }
45
46 svnadmin('create', $to);
47 open(my $fh_in, '-|', "svnadmin dump $from") || die "can't dump $from: $!";
48 open(my $fh_out, '|-', "svnadmin load $to") || die "can't load $to: $!";
49
50 my $dump = SVN::Dump->new( { fh => $fh_in } );
51
52 warn "## $from -> $to\n";
53
54 while ( my $rec = $dump->next_record() ) {
55 my $type = $rec->type();
56 if ( $type eq 'revision' && $rec->get_header( 'Revision-number' ) != 0 ) {
57 my $to = 'dpavlin@rot13.org';
58 $rec->set_property( 'svn:author' => $to );
59 }
60
61 my $path = $rec->get_header('Node-path');
62 warn "##> $path\n" if $path;
63
64 print $fh_out $rec->as_string();
65 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26