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>
This commit is contained in:
Karl Hasselström 2006-02-28 00:08:19 +01:00 committed by Junio C Hamano
parent 80804d0af8
commit d3cac2c95a
2 changed files with 25 additions and 5 deletions

View File

@ -82,6 +82,11 @@ When importing incrementally, you might need to edit the .git/svn2git file.
"username". If encountering a commit made by a user not in the "username". If encountering a commit made by a user not in the
list, abort. list, abort.
For convenience, this data is saved to $GIT_DIR/svn-authors
each time the -A option is provided, and read from that same
file each time git-svnimport is run with an existing GIT
repository without -A.
-m:: -m::
Attempt to detect merges based on the commit message. This option Attempt to detect merges based on the commit message. This option
will enable default regexes that try to capture the name source will enable default regexes that try to capture the name source

View File

@ -13,6 +13,7 @@
use strict; use strict;
use warnings; use warnings;
use Getopt::Std; use Getopt::Std;
use File::Copy;
use File::Spec; use File::Spec;
use File::Temp qw(tempfile); use File::Temp qw(tempfile);
use File::Path qw(mkpath); use File::Path qw(mkpath);
@ -68,10 +69,16 @@ if ($opt_M) {
push (@mergerx, qr/$opt_M/); push (@mergerx, qr/$opt_M/);
} }
# Absolutize filename now, since we will have chdir'ed by the time we
# get around to opening it.
$opt_A = File::Spec->rel2abs($opt_A) if $opt_A;
our %users = (); our %users = ();
if ($opt_A) { our $users_file = undef;
die "Cannot open $opt_A\n" unless -f $opt_A; sub read_users($) {
open(my $authors,$opt_A); $users_file = File::Spec->rel2abs(@_);
die "Cannot open $users_file\n" unless -f $users_file;
open(my $authors,$users_file);
while(<$authors>) { while(<$authors>) {
chomp; chomp;
next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/; next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
@ -302,6 +309,14 @@ EOM
-d $git_dir -d $git_dir
or die "Could not create git subdir ($git_dir).\n"; 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"; open BRANCHES,">>", "$git_dir/svn2git";
sub node_kind($$$) { sub node_kind($$$) {
@ -498,8 +513,8 @@ sub commit {
if (not defined $author) { if (not defined $author) {
$author_name = $author_email = "unknown"; $author_name = $author_email = "unknown";
} elsif ($opt_A) { } elsif (defined $users_file) {
die "User $author is not listed in $opt_A\n" die "User $author is not listed in $users_file\n"
unless exists $users{$author}; unless exists $users{$author};
($author_name,$author_email) = @{$users{$author}}; ($author_name,$author_email) = @{$users{$author}};
} elsif ($author =~ /^(.*?)\s+<(.*)>$/) { } elsif ($author =~ /^(.*?)\s+<(.*)>$/) {