/[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

Annotation of /trunk/svndump-move.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (hide annotations)
Fri Aug 3 17:57:25 2007 UTC (16 years, 8 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 dpavlin 47 #!/usr/bin/perl
2     use strict;
3     use warnings;
4     use SVN::Dump;
5 dpavlin 48 use Shell qw/svnadmin cp find svn rm/;
6 dpavlin 47 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 dpavlin 48 }
40    
41     if ( -e $to ) {
42     #die "$to allready exists! remove it to re-create repository\n";
43     rm('-Rf',$to);
44     }
45 dpavlin 47
46 dpavlin 48 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 dpavlin 47
50 dpavlin 48 my $dump = SVN::Dump->new( { fh => $fh_in } );
51 dpavlin 47
52 dpavlin 48 warn "## $from -> $to\n";
53 dpavlin 47
54 dpavlin 48 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 dpavlin 47 }
60 dpavlin 48
61     my $path = $rec->get_header('Node-path');
62     warn "##> $path\n" if $path;
63    
64     print $fh_out $rec->as_string();
65 dpavlin 47 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26