|
13 | 13 | use strict; |
14 | 14 | use warnings; |
15 | 15 | use Getopt::Std; |
| 16 | +use File::Copy; |
16 | 17 | use File::Spec; |
17 | 18 | use File::Temp qw(tempfile); |
18 | 19 | use File::Path qw(mkpath); |
|
68 | 69 | push (@mergerx, qr/$opt_M/); |
69 | 70 | } |
70 | 71 |
|
| 72 | +# Absolutize filename now, since we will have chdir'ed by the time we |
| 73 | +# get around to opening it. |
| 74 | +$opt_A = File::Spec->rel2abs($opt_A) if $opt_A; |
| 75 | + |
71 | 76 | our %users = (); |
72 | | -if ($opt_A) { |
73 | | - die "Cannot open $opt_A\n" unless -f $opt_A; |
74 | | - open(my $authors,$opt_A); |
| 77 | +our $users_file = undef; |
| 78 | +sub read_users($) { |
| 79 | + $users_file = File::Spec->rel2abs(@_); |
| 80 | + die "Cannot open $users_file\n" unless -f $users_file; |
| 81 | + open(my $authors,$users_file); |
75 | 82 | while(<$authors>) { |
76 | 83 | chomp; |
77 | | - next unless /^(\S+)\s+(.+?)\s+<(\S+)>$/; |
| 84 | + next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/; |
78 | 85 | (my $user,my $name,my $email) = ($1,$2,$3); |
79 | 86 | $users{$user} = [$name,$email]; |
80 | 87 | } |
@@ -302,6 +309,14 @@ ($$) |
302 | 309 | -d $git_dir |
303 | 310 | or die "Could not create git subdir ($git_dir).\n"; |
304 | 311 |
|
| 312 | +my $default_authors = "$git_dir/svn-authors"; |
| 313 | +if ($opt_A) { |
| 314 | + read_users($opt_A); |
| 315 | + copy($opt_A,$default_authors) or die "Copy failed: $!"; |
| 316 | +} else { |
| 317 | + read_users($default_authors) if -f $default_authors; |
| 318 | +} |
| 319 | + |
305 | 320 | open BRANCHES,">>", "$git_dir/svn2git"; |
306 | 321 |
|
307 | 322 | sub node_kind($$$) { |
@@ -498,8 +513,8 @@ sub commit { |
498 | 513 |
|
499 | 514 | if (not defined $author) { |
500 | 515 | $author_name = $author_email = "unknown"; |
501 | | - } elsif ($opt_A) { |
502 | | - die "User $author is not listed in $opt_A\n" |
| 516 | + } elsif (defined $users_file) { |
| 517 | + die "User $author is not listed in $users_file\n" |
503 | 518 | unless exists $users{$author}; |
504 | 519 | ($author_name,$author_email) = @{$users{$author}}; |
505 | 520 | } elsif ($author =~ /^(.*?)\s+<(.*)>$/) { |
|
0 commit comments