@matheusbsbs / matheus-bagliano / commits / d3cac2c95a
Fork 0

Save username -> Full Name <email@addr.es> map file

When the user specifies a username -> Full Name <email@addr.es> map file with the -A option, save a copy of that file as $git_dir/svn-authors. When running git-svnimport with an existing GIT directory, use $git_dir/svn-authors (if it exists) unless a file was explicitly specified with -A. Signed-off-by: Karl Hasselström <kha@treskal.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Karl Hasselström committed Feb 28, 2006 at 00:08 UTC d3cac2c95a1600c9269c821153cbad681b66a8d2
2 files changed +25 -5
Documentation/git-svnimport.txt
+5
@@ -82,6 +82,11 @@ When importing incrementally, you might need to edit the .git/svn2git file.
82 "username". If encountering a commit made by a user not in the
83 list, abort.
84
85 + For convenience, this data is saved to $GIT_DIR/svn-authors
86 + each time the -A option is provided, and read from that same
87 + file each time git-svnimport is run with an existing GIT
88 + repository without -A.
89 +
90 -m::
91 Attempt to detect merges based on the commit message. This option
92 will enable default regexes that try to capture the name source
git-svnimport.perl
+20 -5
@@ -13,6 +13,7 @@
13 use strict;
14 use warnings;
15 use Getopt::Std;
16 +use File::Copy;
17 use File::Spec;
18 use File::Temp qw(tempfile);
19 use File::Path qw(mkpath);
@@ -68,10 +69,16 @@ if ($opt_M) {
69 push (@mergerx, qr/$opt_M/);
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 +
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);
82 while(<$authors>) {
83 chomp;
84 next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
@@ -302,6 +309,14 @@ EOM
309 -d $git_dir
310 or die "Could not create git subdir ($git_dir).\n";
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 +
320 open BRANCHES,">>", "$git_dir/svn2git";
321
322 sub node_kind($$$) {
@@ -498,8 +513,8 @@ sub commit {
513
514 if (not defined $author) {
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"
518 unless exists $users{$author};
519 ($author_name,$author_email) = @{$users{$author}};
520 } elsif ($author =~ /^(.*?)\s+<(.*)>$/) {