changeset 7442:a14ce129cfcd

convert: check existence of ~/.cvspass before reading it
author Edouard Gomez <ed.gomez@free.fr>
date Thu, 27 Nov 2008 10:13:20 +0100
parents 4fecd17f2de9
children 1e0677756f60
files hgext/convert/cvs.py
diffstat 1 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- 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))