X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-svnimport.perl;h=4d5371ca901cb7579e454443958e8ca360763dbe;hb=42b5c78845feb44f1d36eecad4c72336d5c2a9c5;hp=0dd9fab9fea81243cc4c0e80ec93fe0489b368cd;hpb=0a26233859572f84a2c6e8648565af7e7514caac;p=git.git diff --git a/git-svnimport.perl b/git-svnimport.perl index 0dd9fab9..4d5371ca 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -13,6 +13,7 @@ use strict; use warnings; use Getopt::Std; +use File::Copy; use File::Spec; use File::Temp qw(tempfile); use File::Path qw(mkpath); @@ -30,7 +31,7 @@ $SIG{'PIPE'}="IGNORE"; $ENV{'TZ'}="UTC"; our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T, - $opt_b,$opt_r,$opt_I,$opt_s,$opt_l,$opt_d,$opt_D); + $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D); sub usage() { print STDERR <rel2abs($opt_A) if $opt_A; + +our %users = (); +our $users_file = undef; +sub read_users($) { + $users_file = File::Spec->rel2abs(@_); + die "Cannot open $users_file\n" unless -f $users_file; + open(my $authors,$users_file); + while(<$authors>) { + chomp; + next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/; + (my $user,my $name,my $email) = ($1,$2,$3); + $users{$user} = [$name,$email]; + } + close($authors); +} + select(STDERR); $|=1; select(STDOUT); @@ -289,6 +309,14 @@ EOM -d $git_dir or die "Could not create git subdir ($git_dir).\n"; +my $default_authors = "$git_dir/svn-authors"; +if ($opt_A) { + read_users($opt_A); + copy($opt_A,$default_authors) or die "Copy failed: $!"; +} else { + read_users($default_authors) if -f $default_authors; +} + open BRANCHES,">>", "$git_dir/svn2git"; sub node_kind($$$) { @@ -485,6 +513,10 @@ sub commit { if (not defined $author) { $author_name = $author_email = "unknown"; + } elsif (defined $users_file) { + die "User $author is not listed in $users_file\n" + unless exists $users{$author}; + ($author_name,$author_email) = @{$users{$author}}; } elsif ($author =~ /^(.*?)\s+<(.*)>$/) { ($author_name, $author_email) = ($1, $2); } else { @@ -584,9 +616,7 @@ sub commit { } if(($action->[0] eq "A") || ($action->[0] eq "R")) { my $node_kind = node_kind($branch,$path,$revision); - if($action->[1]) { - copy_path($revision,$branch,$path,$action->[1],$action->[2],$node_kind,\@new,\@parents); - } elsif ($node_kind eq $SVN::Node::file) { + if ($node_kind eq $SVN::Node::file) { my $f = get_file($revision,$branch,$path); if ($f) { push(@new,$f) if $f; @@ -595,8 +625,15 @@ sub commit { print STDERR "$revision: $branch: could not fetch '$opath'\n"; } } elsif ($node_kind eq $SVN::Node::dir) { - get_ignore(\@new, \@old, $revision, - $branch,$path); + if($action->[1]) { + copy_path($revision, $branch, + $path, $action->[1], + $action->[2], $node_kind, + \@new, \@parents); + } else { + get_ignore(\@new, \@old, $revision, + $branch, $path); + } } } elsif ($action->[0] eq "D") { push(@old,$path); @@ -819,7 +856,7 @@ sub commit_all { $opt_l = $svn->{'maxrev'} if not defined $opt_l or $opt_l > $svn->{'maxrev'}; -if ($svn->{'maxrev'} < $current_rev) { +if ($opt_l < $current_rev) { print "Up to date: no new revisions to fetch!\n" if $opt_v; unlink("$git_dir/SVN2GIT_HEAD"); exit;