comparison hgext/convert/cvs.py @ 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 f792c7bb2fb3
comparison
equal deleted inserted replaced
7441:4fecd17f2de9 7442:a14ce129cfcd
199 format0 = ":pserver:%s@%s:%s" % (user, serv, root) 199 format0 = ":pserver:%s@%s:%s" % (user, serv, root)
200 format1 = ":pserver:%s@%s:%d%s" % (user, serv, port, root) 200 format1 = ":pserver:%s@%s:%d%s" % (user, serv, port, root)
201 201
202 if not passw: 202 if not passw:
203 passw = "A" 203 passw = "A"
204 pf = open(os.path.expanduser("~/.cvspass")) 204 cvspass = os.path.expanduser("~/.cvspass")
205 for line in pf.read().splitlines(): 205 if os.path.exists(cvspass):
206 part1, part2 = line.split(' ', 1) 206 pf = open(cvspass)
207 if part1 == '/1': 207 for line in pf.read().splitlines():
208 # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z 208 part1, part2 = line.split(' ', 1)
209 part1, part2 = part2.split(' ', 1) 209 if part1 == '/1':
210 format = format1 210 # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z
211 else: 211 part1, part2 = part2.split(' ', 1)
212 # :pserver:user@example.com:/cvsroot/foo Ah<Z 212 format = format1
213 format = format0 213 else:
214 if part1 == format: 214 # :pserver:user@example.com:/cvsroot/foo Ah<Z
215 passw = part2 215 format = format0
216 break 216 if part1 == format:
217 pf.close() 217 passw = part2
218 break
219 pf.close()
218 220
219 sck = socket.socket() 221 sck = socket.socket()
220 sck.connect((serv, port)) 222 sck.connect((serv, port))
221 sck.send("\n".join(["BEGIN AUTH REQUEST", root, user, passw, 223 sck.send("\n".join(["BEGIN AUTH REQUEST", root, user, passw,
222 "END AUTH REQUEST", ""])) 224 "END AUTH REQUEST", ""]))