diff hgext/convert/cvs.py @ 5082:dc2e512cb89a

CVS import: Support new-style .cvspass-file format. Based on an email from Ralf.Leibold at nuance dot com
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 07 Aug 2007 15:56:26 +0200
parents 30e826bd8ed1
children 7106f4899aa0 a76c61679b71
line wrap: on
line diff
--- 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()