{"thread":{"id":"3065","subject":"[PATCH] git-cvsimport: Add -A <author-conv-file> option","startedAt":"2006-01-12T23:38:59Z","lastAt":"2006-01-13T08:45:51Z","messageCount":6,"participants":["Andreas Ericsson","Junio C Hamano","Alexander Litvinov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"14581","messageId":"20060112233859.3438F5BED0@nox.op5.se","threadId":"3065","inReplyTo":null,"subject":"[PATCH] git-cvsimport: Add -A <author-conv-file> option","fromName":"Andreas Ericsson","fromEmail":"exon@op5.se","sentAt":"2006-01-12T23:38:59Z","receivedAt":"2006-01-12T23:38:59Z","isPatch":true,"sender":{"key":"exon@op5.se","avatar":"https://gravatar.com/avatar/b948c4f759e868f8e721e545e37afe2cf89cfa8e2ee8b70a432f0d76aee39891?d=mp&s=160"},"body":"This patch adds the option to specify an author name/email conversion\nfile in the format\n\n\texon=Andreas Ericsson <ae@op5.se>\n\tspawn=Simon Pawn <spawn@frog-pond.org>\n\nwhich will translate the ugly cvs authornames to the more informative\ngit style.\n\nThe info is saved in $GIT_DIR/cvs-authors, so that subsequent\nincremental imports will use the same author-info even if no -A\noption is specified. If an -A option *is* specified, the info in\n$GIT_DIR/cvs-authors is appended/updated appropriately.\n\nDocs updated accordingly.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n\n---\n\n Documentation/git-cvsimport.txt |   20 ++++++++++++++\n git-cvsimport.perl              |   56 +++++++++++++++++++++++++++++++++++----\n 2 files changed, 70 insertions(+), 6 deletions(-)\n\na1883e11a55c4684c0c5123c75425623a54f44cf\ndiff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt\nindex 01ca7ef..dfe86ce 100644\n--- a/Documentation/git-cvsimport.txt\n+++ b/Documentation/git-cvsimport.txt\n@@ -89,6 +89,26 @@ If you need to pass multiple options, se\n -s <subst>::\n \tSubstitute the character \"/\" in branch names with <subst>\n \n+-A <author-conv-file>::\n+\tCVS by default uses the unix username when writing its\n+\tcommit logs. Using this option and an author-conv-file\n+\tin this format\n+\n+\texon=Andreas Ericsson <ae@op5.se>\n+\tspawn=Simon Pawn <spawn@frog-pond.org>\n+\n+\tgit-cvsimport will make it appear as those authors had\n+\ttheir GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL set properly\n+\tall along.\n+\n+\tFor convenience, this data is saved to $GIT_DIR/cvs-authors\n+\teach time the -A option is provided and read from that same\n+\tfile each time git-cvsimport is run.\n+\n+\tIt is not recommended to use this feature if you intend to\n+\texport changes back to CVS again later with\n+\tgit-link[1]::git-cvsexportcommit.\n+\n OUTPUT\n ------\n If '-v' is specified, the script reports what it is doing.\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8619e7d..8d493c2 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -29,19 +29,52 @@ use IPC::Open2;\n $SIG{'PIPE'}=\"IGNORE\";\n $ENV{'TZ'}=\"UTC\";\n \n-our($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M);\n+our($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A);\n+my (%conv_author_name, %conv_author_email);\n \n sub usage() {\n \tprint STDERR <<END;\n Usage: ${\\basename $0}     # fetch/update GIT from CVS\n-       [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT]\n-       [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz]\n-       [-i] [-k] [-u] [-s subst] [-m] [-M regex] [CVS_module]\n+       [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]\n+       [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz] [-i] [-k] [-u]\n+       [-s subst] [-m] [-M regex] [CVS_module]\n END\n \texit(1);\n }\n \n-getopts(\"hivmkuo:d:p:C:z:s:M:P:\") or usage();\n+sub read_author_info($) {\n+\tmy ($file) = @_;\n+\tmy $user;\n+\topen my $f, '<', \"$file\" or die(\"Failed to open $file: $!\\n\");\n+\n+\twhile (<$f>) {\n+\t\tchomp;\n+\t\t# Expected format is this;\n+\t\t#   exon=Andreas Ericsson <ae@op5.se>\n+\t\tif (m/^([^ \\t=]*)[ \\t=]*([^<]*)(<.*$)\\s*/) {\n+\t\t\t$user = $1;\n+\t\t\t$conv_author_name{$1} = $2;\n+\t\t\t$conv_author_email{$1} = $3;\n+\t\t\t# strip trailing whitespace from author name\n+\t\t\t$conv_author_name{$1} =~ s/\\s*$//;\n+\t\t}\n+\t}\n+\tclose ($f);\n+}\n+\n+sub write_author_info($) {\n+\tmy ($file) = @_;\n+\topen my $f, '>', $file or\n+\t  die(\"Failed to open $file for writing: $!\");\n+\n+\tforeach (keys %conv_author_name) {\n+\t\tprint $f \"$_=\" . $conv_author_name{$_} .\n+\t\t  \" \" . $conv_author_email{$_} . \"\\n\";\n+\t}\n+\tclose ($f);\n+}\n+\n+getopts(\"hivmkuo:d:p:C:z:s:M:P:A:\") or usage();\n usage if $opt_h;\n \n @ARGV <= 1 or usage();\n@@ -453,7 +486,7 @@ CVS2GIT_HEAD exists.\n Make sure your working directory corresponds to HEAD and remove CVS2GIT_HEAD.\n You may need to run\n \n-    git-read-tree -m -u CVS2GIT_HEAD HEAD\n+    git read-tree -m -u CVS2GIT_HEAD HEAD\n EOM\n \t}\n \tsystem('cp', \"$git_dir/HEAD\", \"$git_dir/CVS2GIT_HEAD\");\n@@ -489,6 +522,14 @@ EOM\n -d $git_dir\n \tor die \"Could not create git subdir ($git_dir).\\n\";\n \n+# now we read (and possibly save) author-info as well\n+-f \"$git_dir/cvs-authors\" and\n+  read_author_info(\"$git_dir/cvs-authors\");\n+if ($opt_A) {\n+\tread_author_info($opt_A);\n+\twrite_author_info(\"$git_dir/cvs-authors\");\n+}\n+\n my $pid = open(CVS,\"-|\");\n die \"Cannot fork: $!\\n\" unless defined $pid;\n unless($pid) {\n@@ -702,6 +743,9 @@ while(<CVS>) {\n \t\ts/\\s+$//;\n \t\tif (/^(.*?)\\s+<(.*)>/) {\n \t\t    ($author_name, $author_email) = ($1, $2);\n+\t\t} elsif ($conv_author_name{$_}) {\n+\t\t\t$author_name = $conv_author_name{$_};\n+\t\t\t$author_email = $conv_author_email{$_};\n \t\t} else {\n \t\t    $author_name = $author_email = $_;\n \t\t}\n-- \n1.1.1-g4c34-dirty\n"},{"id":"14585","messageId":"7vvewohoy0.fsf@assigned-by-dhcp.cox.net","threadId":"3065","inReplyTo":"20060112233859.3438F5BED0@nox.op5.se","subject":"Re: [PATCH] git-cvsimport: Add -A <author-conv-file> option","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-13T01:55:03Z","receivedAt":"2006-01-13T01:55:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"ISTR there was a thread that suggested using CVSROOT/users file\nfor this purpose.\n\n\thttp://thread.gmane.org/gmane.comp.version-control.git/8167\n"},{"id":"14586","messageId":"43C70D03.4040609@op5.se","threadId":"3065","inReplyTo":"7vvewohoy0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-cvsimport: Add -A <author-conv-file> option","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-01-13T02:14:27Z","receivedAt":"2006-01-13T02:14:27Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> ISTR there was a thread that suggested using CVSROOT/users file\n> for this purpose.\n> \n> \thttp://thread.gmane.org/gmane.comp.version-control.git/8167\n> \n\nISTR?\n\nThat patch doesn't work when importing from sourceforge (among others), \nbecause no-one uses their devname@users.sourceforge.net address (and \noften just filter them out because they attract so much spam). It also \ndoes nothing for when the username isn't the leading part of the \nemail-addres, or for GIT_AUTHOR_NAME, which is the most disturbing since \nit ruffles the shortlog output. We use that shortlog to get a gisted \nchangelog for the sales and marketing people. I can recommend this. \nThey're absolutely thrilled to see things like \"Only use vararg macros \n#ifdef __GNUC__\" and \"declare **envp const throughout mplex api\". ;)\n\nAnyways, I can keep this separate if you don't want to accept it. I'll \nmost likely implement some config-reading to it too though so I don't \nhave to type the repository name and such each time I run it.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"14592","messageId":"200601130919.00928.lan@ac-sw.com","threadId":"3065","inReplyTo":"7vvewohoy0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-cvsimport: Add -A <author-conv-file> option","fromName":"Alexander Litvinov","fromEmail":"lan@ac-sw.com","sentAt":"2006-01-13T03:19:00Z","receivedAt":"2006-01-13T03:19:00Z","isPatch":true,"sender":{"key":"lan@ac-sw.com","avatar":null},"body":"On Friday 13 January 2006 07:55, Junio C Hamano wrote:\n> ISTR there was a thread that suggested using CVSROOT/users file\n> for this purpose.\n>\n> \thttp://thread.gmane.org/gmane.comp.version-control.git/8167\n\nThis should went into docs for cvsimport. Before now I knew there is a way to \nimport authors but I did not find anything in cvsimport script. This patch \nshows not only me lost this feature.\n"},{"id":"14597","messageId":"7vzmm0g45a.fsf@assigned-by-dhcp.cox.net","threadId":"3065","inReplyTo":"43C70D03.4040609@op5.se","subject":"Re: [PATCH] git-cvsimport: Add -A <author-conv-file> option","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-13T04:09:37Z","receivedAt":"2006-01-13T04:09:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Ericsson <ae@op5.se> writes:\n\n> Junio C Hamano wrote:\n>> ISTR there was a thread that suggested using CVSROOT/users file\n>> for this purpose.\n>> \thttp://thread.gmane.org/gmane.comp.version-control.git/8167\n>\n> ISTR?\n\nI seem to recall...\n\n> That patch doesn't work when importing from sourceforge...\n>\n> Anyways, I can keep this separate if you don't want to accept it.\n\nOh, I haven't formed an opinion on accept/reject yet.  I was\njust trying to see if you are aware of that (especially Pasky's\nmessage in that thread) and thought about issues like \"if in\nsome repositories CVSROOT/users is in usable form then perhaps\nmaking sure -A file has the same format and suggest its use in\nthe documentation would be nicer\".\n"},{"id":"14606","messageId":"7v8xtkbjnk.fsf@assigned-by-dhcp.cox.net","threadId":"3065","inReplyTo":"7vzmm0g45a.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-cvsimport: Add -A <author-conv-file> option","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-13T08:45:51Z","receivedAt":"2006-01-13T08:45:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Andreas Ericsson <ae@op5.se> writes:\n>\n>> Anyways, I can keep this separate if you don't want to accept it.\n>\n> Oh, I haven't formed an opinion on accept/reject yet.  I was\n> just trying to see if you are aware of that (especially Pasky's\n> message in that thread) and thought about issues like \"if in\n> some repositories CVSROOT/users is in usable form then perhaps\n> making sure -A file has the same format and suggest its use in\n> the documentation would be nicer\".\n\nOK, after a little googling around, I have formed an opinion.  I\nagree to the patch in principle, but at least it would be nicer\nto use \"CVSROOT/users\" compatible format before giving it to the\ngeneral public.\n\n\thttp://computing.ee.ethz.ch/sepp/cvs-1.10-to/cvsbook/main_70.html\n\nseems to indicate that:\n\n - colon ':' is used instead of your '='.\n\n - RHS, if it contains a whitespace, is quoted either with\n   single or double quote.\n\nIt was a bit unclear to me how quote characters are to be\nquoted, so the patch needs a bit of research, quoting (when\nwriting out new records) and unquoting (when reading) in the\nscript, but otherwise I think it is a welcome change.\n\nOpinions from other heavy CVS users?\n"}]}