Subject: Re: cvsimport still not working with cvsnt

From: Guy Rouillier <[email-masked]>
Date: Sun, 30 Jan 2011 01:33:57 -0500

Sorry for the delay in following up, work has been busy.

On 1/14/2011 4:49 PM, Junio C Hamano wrote:
> As the general principle, in a "we see two, and we cannot tell which one
> the user wants to use" situation like this, I tend to prefer erroring out
> to _force_ the user to fix the configuration once and for all.

That was my original inclination.  As no other opinions have been posted 
since your message, here is my amended patch, incorporating Martin's 
ideas and dieing if the script finds both CVS and CVSNT password files.
I don't know why diff got tripped up on brace indentation; I used only
tabs and everything looks fine in vi.

--- git-cvsimport.org   2011-01-09 03:52:39.000000000 -0500
+++ git-cvsimport.perl  2011-01-30 00:59:29.000000000 -0500
@@ -260,19 +260,27 @@
                if ($pass) {
                        $pass = $self->_scramble($pass);
                } else {
-                       open(H,$ENV{'HOME'}."/.cvspass") and do {
+                       my @cvspasslocations = ($ENV{'HOME'}."/.cvspass", $ENV{'HOME'}."/.cvs/cvspass");
+                       my $filecount = 0;
+                       foreach my $cvspass (@cvspasslocations) {
+
+                               open(H, $cvspass) and do {
                                # :pserver:[email-masked]:/cvsroot/zmailer Ah<Z
+                                       $filecount++;
                                while (<H>) {
                                        chomp;
                                        s/^\/\d+\s+//;
-                                       my ($w,$p) = split(/\s/,$_,2);
+                                               my ($w,$p) = split(/[\s=]/,$_,2);
                                        if ($w eq $rr or $w eq $rr2) {
                                                $pass = $p;
                                                last;
                                        }
                                }
                        };
-                       $pass = "A" unless $pass;
+                       }
+                       
+                       die("Two CVS password files found: @cvspasslocations, please remove one") if $filecount > 1;
+                       die("Password not found for CVSROOT: $opt_d\n") unless $pass;
                }

                my ($s, $rep);

-- 
Guy Rouillier