#!/usr/bin/perl -w use strict; use warnings; use SVN::Client; use Data::Dumper; my $gitreposdir = '.'; my $svnrepo = 'http://svn.foswiki.org'; my $ctx = SVN::Client->new(); my %extensions = (); my %branches = ( pharvey => { WikiDrawPlugin => 'branches/scratch/pharvey/WikiDrawPlugin' }, ItaloValcy => { ImageGalleryPlugin => 'branches/scratch/ItaloValcy/ImageGalleryPlugin_5x10' }, # 'foswikidotorg' => { # _path => 'branches/foswiki.org', # }, 'Release01x00' => { _path => 'branches/Release01x00', }, 'Release01x01' => { _path => 'branches/Release01x01', }, 'trunk' => { _path => 'trunk' } ); while ( my ( $branch, $data ) = each %branches ) { if ( $data->{_path} ) { my @branchextensions; print "Listing $svnrepo/$data->{_path}\n"; @branchextensions = keys %{ $ctx->ls( $svnrepo . '/' . $data->{_path}, 'HEAD', 0 ) }; foreach my $ext (@branchextensions) { if ($ext ne 't2fos.sh') { $data->{$ext} = $data->{_path} . '/' . $ext; $extensions{$ext} = 1; } } } else { foreach my $ext ( keys %{$data} ) { $extensions{$ext} = 1; } } } foreach my $ext ( sort( keys %extensions ) ) { if ( $branches{trunk}->{$ext} ) { do_commands( "git svn init $svnrepo -T $branches{trunk}->{$ext} $gitreposdir/$ext" ); while ( my ( $branch, $data ) = each %branches ) { if ( $branch ne 'trunk' and $data->{$ext} ) { do_commands(<<"HERE"); cd $gitreposdir/$ext git config --add svn-remote.$branch.url http://svn.foswiki.org/$data->{$ext} git config --add svn-remote.$branch.fetch :refs/remotes/$branch HERE } } } else { print STDERR "ERROR: Couldn't find $ext in svn trunk\n"; } } sub do_commands { my ($commands) = @_; #print $commands . "\n"; system($commands); return; }