@matheusbsbs / matheus-bagliano / commits / 36610b24f1
Fork 0

svnimport: Read author names and emails from a file

Read a file with lines on the form username User's Full Name <email@addres.org> and use "User's Full Name <email@addres.org>" as the GIT author and committer for Subversion commits made by "username". If encountering a commit made by a user not in the list, abort. Signed-off-by: Karl Hasselström <kha@treskal.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Karl Hasselström committed Feb 26, 2006 at 06:11 UTC 36610b24f1a1821eee95243663631c1295c202ed
2 files changed +32 -4
Documentation/git-svnimport.txt
+12 -1
@@ -13,7 +13,8 @@ SYNOPSIS
13 [ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_rev]
14 [ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
15 [ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
16 - [ -I <ignorefile_name> ] <SVN_repository_URL> [ <path> ]
16 + [ -I <ignorefile_name> ] [ -A <author_file> ]
17 + <SVN_repository_URL> [ <path> ]
18
19
20 DESCRIPTION
@@ -71,6 +72,16 @@ When importing incrementally, you might need to edit the .git/svn2git file.
72 syntaxes are similar enough that using the Subversion patterns
73 directly with "-I .gitignore" will almost always just work.)
74
75 +-A <author_file>::
76 + Read a file with lines on the form
77 +
78 + username User's Full Name <email@addres.org>
79 +
80 + and use "User's Full Name <email@addres.org>" as the GIT
81 + author and committer for Subversion commits made by
82 + "username". If encountering a commit made by a user not in the
83 + list, abort.
84 +
85 -m::
86 Attempt to detect merges based on the commit message. This option
87 will enable default regexes that try to capture the name source
git-svnimport.perl
+20 -3
@@ -30,7 +30,7 @@ $SIG{'PIPE'}="IGNORE";
30 $ENV{'TZ'}="UTC";
31
32 our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,
33 - $opt_b,$opt_r,$opt_I,$opt_s,$opt_l,$opt_d,$opt_D);
33 + $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D);
34
35 sub usage() {
36 print STDERR <<END;
@@ -38,12 +38,12 @@ Usage: ${\basename $0} # fetch/update GIT from SVN
38 [-o branch-for-HEAD] [-h] [-v] [-l max_rev]
39 [-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
40 [-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]
41 - [-m] [-M regex] [SVN_URL]
41 + [-m] [-M regex] [-A author_file] [SVN_URL]
42 END
43 exit(1);
44 }
45
46 -getopts("b:C:dDhiI:l:mM:o:rs:t:T:uv") or usage();
46 +getopts("A:b:C:dDhiI:l:mM:o:rs:t:T:uv") or usage();
47 usage if $opt_h;
48
49 my $tag_name = $opt_t || "tags";
@@ -68,6 +68,19 @@ if ($opt_M) {
68 push (@mergerx, qr/$opt_M/);
69 }
70
71 +our %users = ();
72 +if ($opt_A) {
73 + die "Cannot open $opt_A\n" unless -f $opt_A;
74 + open(my $authors,$opt_A);
75 + while(<$authors>) {
76 + chomp;
77 + next unless /^(\S+)\s+(.+?)\s+<(\S+)>$/;
78 + (my $user,my $name,my $email) = ($1,$2,$3);
79 + $users{$user} = [$name,$email];
80 + }
81 + close($authors);
82 +}
83 +
84 select(STDERR); $|=1; select(STDOUT);
85
86
@@ -485,6 +498,10 @@ sub commit {
498
499 if (not defined $author) {
500 $author_name = $author_email = "unknown";
501 + } elsif ($opt_A) {
502 + die "User $author is not listed in $opt_A\n"
503 + unless exists $users{$author};
504 + ($author_name,$author_email) = @{$users{$author}};
505 } elsif ($author =~ /^(.*?)\s+<(.*)>$/) {
506 ($author_name, $author_email) = ($1, $2);
507 } else {