#!/usr/bin/perl -w use File::Copy; use strict; my $log = 'git-svn-gen.log'; my %types = ( 'http' => 'http://svn.xfce.org/svn', 'https' => 'https://svn.xfce.org/svn', 'ssh' => 'svn+ssh://svn.xfce.org/var/svn', ); my %repos = (); sub usage { print "Usage: $0 repo [ module ]+\n"; } do { usage(); exit(1); } if(!defined($ARGV[0])); my $repo = shift(@ARGV); do { usage(); exit(1); } if(!defined($ARGV[0])); $repos{$repo} = []; foreach my $m (@ARGV) { push(@{$repos{$repo}}, $m); } my $svn_authors = $ENV{'HOME'}.'/svn-authors'; open(LOG, '>>'.$log) or die("Unable to open log: $!"); foreach my $t (keys(%types)) { if(! -d $t) { mkdir($t) or exit(1); } chdir($t) or exit(1); foreach my $r (keys(%repos)) { if(! -d $r) { mkdir($r) or exit(1); } chdir($r) or exit(1); foreach my $m (@{$repos{$r}}) { print LOG "START: $t:$r:$m\n"; if(! -d $m.'.git-svn') { mkdir($m.'.git-svn') or next; } chdir($m.'.git-svn') or next; (0 == system(qq(git-svn init -s --prefix=origin/ --rewrite-root=$types{$t}/$r file:///var/svn/$r/$m))) and (0 == system(qq(git-svn fetch --repack 50000 -A "$svn_authors"))) and (0 == system(qq(git-config svn-remote.svn.url $types{$t}/$r))) and (0 == system(qq(git-repack -a -d))) and copy($svn_authors, '.git/svn/svn-authors') and (0 == system(qq(git-config svn.authorsfile .git/svn/svn-authors))) and print LOG "DONE: $t:$r:$m\n" and do { # make sure we've defaulted to the right branch my $master = `cat .git/refs/heads/master`; my $trunk = `cat .git/refs/remotes/origin/trunk`; if($master ne $trunk) { # find another branch to switch to, fix the master ref, and switch back my $other = `git-branch -a | head -n 2 | tail -n 1`; system(qq(git-checkout $other)); open(MR, '>.git/refs/heads/master') and print MR $trunk and close(MR); system(qq(git-checkout master)); } }; chdir('..'); } chdir('..'); } chdir('..'); } close(LOG);