convert: check existence of ~/.cvspass before reading it
authorEdouard Gomez <ed.gomez@free.fr>
Thu, 27 Nov 2008 10:13:20 +0100
changeset 7442 a14ce129cfcd
parent 7441 4fecd17f2de9
child 7443 1e0677756f60
convert: check existence of ~/.cvspass before reading it
hgext/convert/cvs.py
--- a/hgext/convert/cvs.py	Thu Nov 27 22:04:51 2008 +0100
+++ b/hgext/convert/cvs.py	Thu Nov 27 10:13:20 2008 +0100
@@ -201,20 +201,22 @@
 
                 if not passw:
                     passw = "A"
-                    pf = open(os.path.expanduser("~/.cvspass"))
-                    for line in pf.read().splitlines():
-                        part1, part2 = line.split(' ', 1)
-                        if part1 == '/1':
-                            # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z
-                            part1, part2 = part2.split(' ', 1)
-                            format = format1
-                        else:
-                            # :pserver:user@example.com:/cvsroot/foo Ah<Z
-                            format = format0
-                        if part1 == format:
-                            passw = part2
-                            break
-                    pf.close()
+                    cvspass = os.path.expanduser("~/.cvspass")
+                    if os.path.exists(cvspass):
+                        pf = open(cvspass)
+                        for line in pf.read().splitlines():
+                            part1, part2 = line.split(' ', 1)
+                            if part1 == '/1':
+                                # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z
+                                part1, part2 = part2.split(' ', 1)
+                                format = format1
+                            else:
+                                # :pserver:user@example.com:/cvsroot/foo Ah<Z
+                                format = format0
+                            if part1 == format:
+                                passw = part2
+                                break
+                        pf.close()
 
                 sck = socket.socket()
                 sck.connect((serv, port))