CVS import: Support new-style .cvspass-file format.
Based on an email from Ralf.Leibold at nuance dot com
--- a/hgext/convert/cvs.py Tue Aug 07 10:24:33 2007 +0200
+++ b/hgext/convert/cvs.py Tue Aug 07 15:56:26 2007 +0200
@@ -107,23 +107,27 @@
user, passw, serv, port, root = m.groups()
if not user:
user = "anonymous"
- rr = ":pserver:" + user + "@" + serv + ":" + root
- if port:
- rr2, port = "-", int(port)
+ if not port:
+ port = 2401
else:
- rr2, port = rr, 2401
- rr += str(port)
+ port = int(port)
+ format0 = ":pserver:%s@%s:%s" % (user, serv, root)
+ format1 = ":pserver:%s@%s:%d%s" % (user, serv, port, root)
if not passw:
passw = "A"
pf = open(os.path.join(os.environ["HOME"], ".cvspass"))
- for l in pf:
- # :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah<Z
- m = re.match(r'(/\d+\s+/)?(.*)', l)
- l = m.group(2)
- w, p = l.split(' ', 1)
- if w in [rr, rr2]:
- passw = p
+ 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()